geido commented on code in PR #30903:
URL: https://github.com/apache/superset/pull/30903#discussion_r1880094091
##########
superset-frontend/src/explore/components/controls/TextAreaControl.jsx:
##########
@@ -94,31 +100,44 @@ class TextAreaControl extends Component {
if (this.props.readOnly) {
style.backgroundColor = '#f2f2f2';
}
+ const codeEditor = (
+ <div>
Review Comment:
What is this `div` for?
##########
superset-frontend/src/explore/components/controls/TextAreaControl.jsx:
##########
@@ -94,31 +100,44 @@ class TextAreaControl extends Component {
if (this.props.readOnly) {
style.backgroundColor = '#f2f2f2';
}
+ const codeEditor = (
+ <div>
+ <TextAreaEditor
+ mode={this.props.language}
+ style={style}
+ minLines={minLines}
+ maxLines={inModal ? 1000 : this.props.maxLines}
+ editorProps={{ $blockScrolling: true }}
+ defaultValue={this.props.initialValue}
+ readOnly={this.props.readOnly}
+ key={this.props.name}
+ {...this.props}
+ onChange={this.onAreaEditorChange.bind(this)}
+ />
+ </div>
+ );
+
+ if (this.props.tooltipOptions) {
+ return <Tooltip {...this.props.tooltipOptions}>{codeEditor}</Tooltip>;
+ }
+ return codeEditor;
+ }
- return (
- <TextAreaEditor
- mode={this.props.language}
- style={style}
- minLines={minLines}
- maxLines={inModal ? 1000 : this.props.maxLines}
- editorProps={{ $blockScrolling: true }}
+ const textArea = (
+ <div>
Review Comment:
Same for this `div`, what is this for?
##########
superset-frontend/src/components/Datasource/utils.js:
##########
@@ -40,3 +43,86 @@ export function recurseReactClone(children, type,
propExtender) {
return newChild;
});
}
+
+export function updateColumns(prevCols, newCols, addSuccessToast) {
+ // cols: Array<{column_name: string; is_dttm: boolean; type: string;}>
+ const databaseColumnNames = newCols.map(col => col.column_name);
+ const currentCols = prevCols.reduce((agg, col) => {
+ // eslint-disable-next-line no-param-reassign
+ agg[col.column_name] = col;
+ return agg;
+ }, {});
+ const columnChanges = {
+ added: [],
+ modified: [],
+ removed: prevCols
+ .map(col => col.column_name)
+ .filter(col => !databaseColumnNames.includes(col)),
+ finalColumns: [],
+ };
+ newCols.forEach(col => {
+ const currentCol = currentCols[col.column_name];
+ if (!currentCol) {
+ // new column
+ columnChanges.finalColumns.push({
+ id: nanoid(),
+ column_name: col.column_name,
+ type: col.type,
+ groupby: true,
+ filterable: true,
+ is_dttm: col.is_dttm,
+ });
+ columnChanges.added.push(col.column_name);
+ } else if (
+ currentCol.type !== col.type ||
+ currentCol.is_dttm !== col.is_dttm
+ ) {
+ // modified column
+ columnChanges.finalColumns.push({
+ ...currentCol,
+ type: col.type,
+ is_dttm: currentCol.is_dttm || col.is_dttm,
+ });
+ columnChanges.modified.push(col.column_name);
+ } else {
+ // unchanged
+ columnChanges.finalColumns.push(currentCol);
+ }
+ });
+ if (columnChanges.modified.length) {
Review Comment:
I am wondering if this is an opportunity to improve the user experience here
and just show a generic message. From your sample video it looks really bad and
possibly useless for the user to see such big success toasts with a bunch of
columns in them. cc @kasiazjc
##########
superset-frontend/packages/superset-ui-chart-controls/src/types.ts:
##########
@@ -84,6 +84,12 @@ export interface Dataset {
filter_select?: boolean;
filter_select_enabled?: boolean;
column_names?: string[];
+ catalog?: string;
+ schema?: string;
+ table_name?: string;
+ database?: Record<string, unknown>;
Review Comment:
@fisjac +1 for this
##########
superset-frontend/src/components/Datasource/DatasourceModal.tsx:
##########
@@ -110,124 +122,139 @@ const DatasourceModal:
FunctionComponent<DatasourceModalProps> = ({
const [isEditing, setIsEditing] = useState<boolean>(false);
const dialog = useRef<any>(null);
const [modal, contextHolder] = Modal.useModal();
-
- const onConfirmSave = () => {
+ const buildPayload = (datasource: Record<string, any>) => ({
+ table_name: datasource.table_name,
+ database_id: datasource.database?.id,
+ sql: datasource.sql,
+ filter_select_enabled: datasource.filter_select_enabled,
+ fetch_values_predicate: datasource.fetch_values_predicate,
+ schema:
+ datasource.tableSelector?.schema ||
+ datasource.databaseSelector?.schema ||
+ datasource.schema,
+ description: datasource.description,
+ main_dttm_col: datasource.main_dttm_col,
+ normalize_columns: datasource.normalize_columns,
+ always_filter_main_dttm: datasource.always_filter_main_dttm,
+ offset: datasource.offset,
+ default_endpoint: datasource.default_endpoint,
+ cache_timeout:
+ datasource.cache_timeout === '' ? null : datasource.cache_timeout,
+ is_sqllab_view: datasource.is_sqllab_view,
+ template_params: datasource.template_params,
+ extra: datasource.extra,
+ is_managed_externally: datasource.is_managed_externally,
+ external_url: datasource.external_url,
+ metrics: datasource?.metrics?.map((metric: Record<string, unknown>) => {
+ const metricBody: any = {
+ expression: metric.expression,
+ description: metric.description,
+ metric_name: metric.metric_name,
+ metric_type: metric.metric_type,
+ d3format: metric.d3format || null,
+ currency: !isDefined(metric.currency)
+ ? null
+ : JSON.stringify(metric.currency),
+ verbose_name: metric.verbose_name,
+ warning_text: metric.warning_text,
+ uuid: metric.uuid,
+ extra: buildExtraJsonObject(metric),
+ };
+ if (!Number.isNaN(Number(metric.id))) {
+ metricBody.id = metric.id;
+ }
+ return metricBody;
+ }),
+ columns: datasource?.columns?.map((column: Record<string, unknown>) => ({
Review Comment:
@fisjac should not be too hard to find out what the right type is? Maybe we
need a partial type or to update the original type if a property appears to be
missing. It defeats the purpose of using typescript if we opt for unknown types
##########
superset-frontend/cypress-base/cypress/e2e/explore/control.test.ts:
##########
@@ -1,276 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-// ***********************************************
-// Tests for setting controls in the UI
-// ***********************************************
-import { interceptChart } from 'cypress/utils';
Review Comment:
Is it intentional that we are deleting these E2E tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]