fix: datasource title not editable and ctas disabled on create (#18645)
fix: datasource title not editable on create flow, delete save ctas disabled on rest/graphql form
This commit is contained in:
parent
b7d00d2498
commit
6c498bcbf5
|
|
@ -123,6 +123,8 @@ class DatasourceDBEditor extends JSONtoForm<Props> {
|
||||||
viewMode,
|
viewMode,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
const createFlow = datasourceId === TEMP_DATASOURCE_ID;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
|
|
@ -134,7 +136,7 @@ class DatasourceDBEditor extends JSONtoForm<Props> {
|
||||||
<FormTitleContainer>
|
<FormTitleContainer>
|
||||||
<PluginImage alt="Datasource" src={this.props.pluginImage} />
|
<PluginImage alt="Datasource" src={this.props.pluginImage} />
|
||||||
<FormTitle
|
<FormTitle
|
||||||
disabled={!canManageDatasource}
|
disabled={!createFlow && !canManageDatasource}
|
||||||
focusOnMount={this.props.isNewDatasource}
|
focusOnMount={this.props.isNewDatasource}
|
||||||
/>
|
/>
|
||||||
</FormTitleContainer>
|
</FormTitleContainer>
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,10 @@ import CloseEditor from "components/editorComponents/CloseEditor";
|
||||||
import { updateReplayEntity } from "actions/pageActions";
|
import { updateReplayEntity } from "actions/pageActions";
|
||||||
import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
||||||
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
|
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
|
||||||
|
import {
|
||||||
|
hasDeleteDatasourcePermission,
|
||||||
|
hasManageDatasourcePermission,
|
||||||
|
} from "@appsmith/utils/permissionHelpers";
|
||||||
|
|
||||||
interface DatasourceRestApiEditorProps {
|
interface DatasourceRestApiEditorProps {
|
||||||
initializeReplayEntity: (id: string, data: any) => void;
|
initializeReplayEntity: (id: string, data: any) => void;
|
||||||
|
|
@ -286,9 +290,17 @@ class DatasourceRestAPIEditor extends React.Component<
|
||||||
};
|
};
|
||||||
|
|
||||||
disableSave = (): boolean => {
|
disableSave = (): boolean => {
|
||||||
const { formData } = this.props;
|
const { datasource, datasourceId, formData } = this.props;
|
||||||
|
const createMode = datasourceId === TEMP_DATASOURCE_ID;
|
||||||
|
const canManageDatasource = hasManageDatasourcePermission(
|
||||||
|
datasource?.userPermissions || [],
|
||||||
|
);
|
||||||
if (!formData) return true;
|
if (!formData) return true;
|
||||||
return !formData.url || !this.props.isFormDirty;
|
return (
|
||||||
|
!formData.url ||
|
||||||
|
!this.props.isFormDirty ||
|
||||||
|
(!createMode && !canManageDatasource)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
save = (onSuccess?: ReduxAction<unknown>) => {
|
save = (onSuccess?: ReduxAction<unknown>) => {
|
||||||
|
|
@ -401,12 +413,25 @@ class DatasourceRestAPIEditor extends React.Component<
|
||||||
};
|
};
|
||||||
|
|
||||||
renderHeader = () => {
|
renderHeader = () => {
|
||||||
const { hiddenHeader, isNewDatasource, pluginImage } = this.props;
|
const {
|
||||||
|
datasource,
|
||||||
|
datasourceId,
|
||||||
|
hiddenHeader,
|
||||||
|
isNewDatasource,
|
||||||
|
pluginImage,
|
||||||
|
} = this.props;
|
||||||
|
const createMode = datasourceId === TEMP_DATASOURCE_ID;
|
||||||
|
const canManageDatasource = hasManageDatasourcePermission(
|
||||||
|
datasource?.userPermissions || [],
|
||||||
|
);
|
||||||
return !hiddenHeader ? (
|
return !hiddenHeader ? (
|
||||||
<Header>
|
<Header>
|
||||||
<FormTitleContainer>
|
<FormTitleContainer>
|
||||||
<PluginImage alt="Datasource" src={pluginImage} />
|
<PluginImage alt="Datasource" src={pluginImage} />
|
||||||
<FormTitle focusOnMount={isNewDatasource} />
|
<FormTitle
|
||||||
|
disabled={!createMode && !canManageDatasource}
|
||||||
|
focusOnMount={isNewDatasource}
|
||||||
|
/>
|
||||||
</FormTitleContainer>
|
</FormTitleContainer>
|
||||||
</Header>
|
</Header>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
@ -414,6 +439,10 @@ class DatasourceRestAPIEditor extends React.Component<
|
||||||
|
|
||||||
renderSave = () => {
|
renderSave = () => {
|
||||||
const { datasourceId, hiddenHeader, isDeleting, isSaving } = this.props;
|
const { datasourceId, hiddenHeader, isDeleting, isSaving } = this.props;
|
||||||
|
const createMode = datasourceId === TEMP_DATASOURCE_ID;
|
||||||
|
const canDeleteDatasource = hasDeleteDatasourcePermission(
|
||||||
|
this.props.datasource?.userPermissions || [],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SaveButtonContainer>
|
<SaveButtonContainer>
|
||||||
|
|
@ -421,7 +450,7 @@ class DatasourceRestAPIEditor extends React.Component<
|
||||||
<ActionButton
|
<ActionButton
|
||||||
category={Category.primary}
|
category={Category.primary}
|
||||||
className="t--delete-datasource"
|
className="t--delete-datasource"
|
||||||
disabled={datasourceId === TEMP_DATASOURCE_ID}
|
disabled={createMode || !canDeleteDatasource}
|
||||||
isLoading={isDeleting}
|
isLoading={isDeleting}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.state.confirmDelete
|
this.state.confirmDelete
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,9 @@ class DatasourceSaaSEditor extends JSONtoForm<Props, State> {
|
||||||
const params: string = location.search;
|
const params: string = location.search;
|
||||||
const viewMode =
|
const viewMode =
|
||||||
!hiddenHeader && new URLSearchParams(params).get("viewMode");
|
!hiddenHeader && new URLSearchParams(params).get("viewMode");
|
||||||
|
|
||||||
|
const createFlow = datasourceId === TEMP_DATASOURCE_ID;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<form
|
<form
|
||||||
|
|
@ -266,7 +269,7 @@ class DatasourceSaaSEditor extends JSONtoForm<Props, State> {
|
||||||
<FormTitleContainer>
|
<FormTitleContainer>
|
||||||
<PluginImage alt="Datasource" src={this.props.pluginImage} />
|
<PluginImage alt="Datasource" src={this.props.pluginImage} />
|
||||||
<FormTitle
|
<FormTitle
|
||||||
disabled={!canManageDatasource}
|
disabled={!createFlow && !canManageDatasource}
|
||||||
focusOnMount={this.props.isNewDatasource}
|
focusOnMount={this.props.isNewDatasource}
|
||||||
/>
|
/>
|
||||||
</FormTitleContainer>
|
</FormTitleContainer>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user