fix (dataset editor): allow Source tab readOnly mode (#11781)

* fix (dataset editor) add read-only mode for Source tab

* add feature flag, add unit tests

* rebase and fix comment

* add message for padlock

* move padlock to the bottom of tab
This commit is contained in:
Grace Guo
2020-12-01 17:10:33 -08:00
committed by GitHub
parent ac9761c730
commit f292015ccd
7 changed files with 152 additions and 23 deletions

View File

@@ -64,6 +64,7 @@ interface DatabaseSelectorProps {
onDbChange?: (db: any) => void;
onSchemaChange?: (arg0?: any) => {};
onSchemasLoad?: (schemas: Array<object>) => void;
readOnly?: boolean;
schema?: string;
sqlLabMode?: boolean;
onChange?: ({
@@ -87,6 +88,7 @@ export default function DatabaseSelector({
onDbChange,
onSchemaChange,
onSchemasLoad,
readOnly = false,
schema,
sqlLabMode = false,
}: DatabaseSelectorProps) {
@@ -237,7 +239,7 @@ export default function DatabaseSelector({
mutator={dbMutator}
placeholder={t('Select a database')}
autoSelect
isDisabled={!isDatabaseSelectEnabled}
isDisabled={!isDatabaseSelectEnabled || readOnly}
/>,
null,
);
@@ -245,7 +247,7 @@ export default function DatabaseSelector({
function renderSchemaSelect() {
const value = schemaOptions.filter(({ value }) => currentSchema === value);
const refresh = !formMode && (
const refresh = !formMode && !readOnly && (
<RefreshLabel
onClick={() => changeDataBase({ id: dbId }, true)}
tooltipContent={t('Force refresh schema list')}
@@ -266,6 +268,7 @@ export default function DatabaseSelector({
isLoading={schemaLoading}
autosize={false}
onChange={item => changeSchema(item)}
isDisabled={readOnly}
/>,
refresh,
);