- {`${t('Parameters')} `}
-
- {!isValid && (
-
- )}
-
+
+
+ {`${t('Parameters')} `}
+
+ {!isValid && (
+
+ )}
+
+
}
modalBody={modalBody}
/>
);
}
-TemplateParamsEditor.propTypes = propTypes;
-TemplateParamsEditor.defaultProps = defaultProps;
-
export default TemplateParamsEditor;
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.js b/superset-frontend/src/SqlLab/reducers/getInitialState.js
index bd74580d0c021..8052476f9bd61 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.js
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.js
@@ -74,13 +74,13 @@ export default function getInitialState({
id: id.toString(),
loaded: true,
title: activeTab.label,
- sql: activeTab.sql,
- selectedText: null,
+ sql: activeTab.sql || undefined,
+ selectedText: undefined,
latestQueryId: activeTab.latest_query
? activeTab.latest_query.id
: null,
autorun: activeTab.autorun,
- templateParams: activeTab.template_params,
+ templateParams: activeTab.template_params || undefined,
dbId: activeTab.database_id,
functionNames: [],
schema: activeTab.schema,
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.test.ts b/superset-frontend/src/SqlLab/reducers/getInitialState.test.ts
index e08443b0598d4..94a0c6a85ec6a 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.test.ts
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.test.ts
@@ -36,8 +36,19 @@ const apiData = {
username: 'some name',
},
};
+const apiDataWithTabState = {
+ ...apiData,
+ tab_state_ids: [{ id: 1 }],
+ active_tab: { id: 1, table_schemas: [] },
+};
describe('getInitialState', () => {
it('should output the user that is passed in', () => {
expect(getInitialState(apiData).sqlLab.user.userId).toEqual(1);
});
+ it('should return undefined instead of null for templateParams', () => {
+ expect(
+ getInitialState(apiDataWithTabState).sqlLab.queryEditors[0]
+ .templateParams,
+ ).toBeUndefined();
+ });
});
diff --git a/superset-frontend/src/components/AsyncAceEditor/index.tsx b/superset-frontend/src/components/AsyncAceEditor/index.tsx
index 0d394d9f3d492..2a5683574a85d 100644
--- a/superset-frontend/src/components/AsyncAceEditor/index.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/index.tsx
@@ -119,6 +119,8 @@ export default function AsyncAceEditor(
mode = inferredMode,
theme = inferredTheme,
tabSize = defaultTabSize,
+ defaultValue = '',
+ value = '',
...props
},
ref,
@@ -150,6 +152,8 @@ export default function AsyncAceEditor(
mode={mode}
theme={theme}
tabSize={tabSize}
+ defaultValue={defaultValue}
+ value={value || ''}
{...props}
/>
);