mirror of https://github.com/buster-so/buster.git
update disable logic for deploying a dataset
This commit is contained in:
parent
2812df14a1
commit
58dc72b9ef
|
@ -14,7 +14,7 @@ import { useDeployDataset } from '@/api/busterv2';
|
||||||
|
|
||||||
export const useDatasetPageContext = ({ datasetId }: { datasetId: string }) => {
|
export const useDatasetPageContext = ({ datasetId }: { datasetId: string }) => {
|
||||||
const segments = useSelectedLayoutSegment() as DatasetApps;
|
const segments = useSelectedLayoutSegment() as DatasetApps;
|
||||||
const { mutate: onUpdateDataset } = useDeployDataset();
|
const { mutate: onUpdateDataset, isPending: isDeployingDataset } = useDeployDataset();
|
||||||
const { dataset, datasetData } = useIndividualDataset({ datasetId });
|
const { dataset, datasetData } = useIndividualDataset({ datasetId });
|
||||||
const originalDatasetSQL = dataset?.data?.sql;
|
const originalDatasetSQL = dataset?.data?.sql;
|
||||||
const datasetYmlFile = dataset?.data?.yml_file;
|
const datasetYmlFile = dataset?.data?.yml_file;
|
||||||
|
@ -27,7 +27,7 @@ export const useDatasetPageContext = ({ datasetId }: { datasetId: string }) => {
|
||||||
const disablePublish = useMemo(() => {
|
const disablePublish = useMemo(() => {
|
||||||
const originalSQL = datasetSQL || '';
|
const originalSQL = datasetSQL || '';
|
||||||
const originalYmlFile = datasetYmlFile || '';
|
const originalYmlFile = datasetYmlFile || '';
|
||||||
return !datasetId || !sql || originalSQL === sql || !ymlFile || originalYmlFile === ymlFile;
|
return !datasetId || !sql || !ymlFile || (originalYmlFile === ymlFile && originalSQL === sql);
|
||||||
}, [datasetSQL, sql, datasetId, datasetYmlFile, ymlFile]);
|
}, [datasetSQL, sql, datasetId, datasetYmlFile, ymlFile]);
|
||||||
|
|
||||||
const isChangedSQL = useMemo(() => {
|
const isChangedSQL = useMemo(() => {
|
||||||
|
@ -40,10 +40,11 @@ export const useDatasetPageContext = ({ datasetId }: { datasetId: string }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const onPublishDataset = useMemoizedFn(async () => {
|
const onPublishDataset = useMemoizedFn(async () => {
|
||||||
|
if (disablePublish || !sql || !ymlFile) return;
|
||||||
onUpdateDataset({
|
onUpdateDataset({
|
||||||
dataset_id: datasetId!,
|
dataset_id: datasetId!,
|
||||||
sql: sql!,
|
sql: sql,
|
||||||
yml: ymlFile!
|
yml: ymlFile
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,7 +70,8 @@ export const useDatasetPageContext = ({ datasetId }: { datasetId: string }) => {
|
||||||
dataset,
|
dataset,
|
||||||
disablePublish,
|
disablePublish,
|
||||||
isChangedSQL,
|
isChangedSQL,
|
||||||
datasetId
|
datasetId,
|
||||||
|
isDeployingDataset
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ export const DatasetsIndividualHeader: React.FC<{}> = React.memo(({}) => {
|
||||||
const selectedApp = useDatasetPageContextSelector((state) => state.selectedApp);
|
const selectedApp = useDatasetPageContextSelector((state) => state.selectedApp);
|
||||||
const dataset = useDatasetPageContextSelector((state) => state.dataset);
|
const dataset = useDatasetPageContextSelector((state) => state.dataset);
|
||||||
const onPublishDataset = useDatasetPageContextSelector((state) => state.onPublishDataset);
|
const onPublishDataset = useDatasetPageContextSelector((state) => state.onPublishDataset);
|
||||||
|
const isDeployingDataset = useDatasetPageContextSelector((state) => state.isDeployingDataset);
|
||||||
const resetDataset = useDatasetPageContextSelector((state) => state.resetDataset);
|
const resetDataset = useDatasetPageContextSelector((state) => state.resetDataset);
|
||||||
const disablePublish = useDatasetPageContextSelector((state) => state.disablePublish);
|
const disablePublish = useDatasetPageContextSelector((state) => state.disablePublish);
|
||||||
const isChangedSQL = useDatasetPageContextSelector((state) => state.isChangedSQL);
|
const isChangedSQL = useDatasetPageContextSelector((state) => state.isChangedSQL);
|
||||||
|
@ -25,7 +26,6 @@ export const DatasetsIndividualHeader: React.FC<{}> = React.memo(({}) => {
|
||||||
const datasetName = dataset?.data?.name;
|
const datasetName = dataset?.data?.name;
|
||||||
|
|
||||||
const isAdmin = useUserConfigContextSelector((state) => state.isAdmin);
|
const isAdmin = useUserConfigContextSelector((state) => state.isAdmin);
|
||||||
const setOpenNewDatasetModal = useDatasetContextSelector((state) => state.setOpenNewDatasetModal);
|
|
||||||
|
|
||||||
const preventNavigation = !disablePublish;
|
const preventNavigation = !disablePublish;
|
||||||
|
|
||||||
|
@ -59,10 +59,14 @@ export const DatasetsIndividualHeader: React.FC<{}> = React.memo(({}) => {
|
||||||
<Divider type="vertical" className="!h-4" />
|
<Divider type="vertical" className="!h-4" />
|
||||||
|
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Button type="text" onClick={onReset} disabled={!isChangedSQL}>
|
<Button type="text" onClick={onReset} disabled={!isChangedSQL || isDeployingDataset}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" disabled={disablePublish} onClick={onPublishDataset}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
disabled={disablePublish}
|
||||||
|
onClick={onPublishDataset}
|
||||||
|
loading={isDeployingDataset}>
|
||||||
Publish
|
Publish
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,7 +16,6 @@ export const BusterList: React.FC<BusterListProps> = ({
|
||||||
onSelectChange,
|
onSelectChange,
|
||||||
emptyState,
|
emptyState,
|
||||||
showHeader = true,
|
showHeader = true,
|
||||||
columnHeaderVariant,
|
|
||||||
contextMenu,
|
contextMenu,
|
||||||
showSelectAll = true
|
showSelectAll = true
|
||||||
}) => {
|
}) => {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const BusterListRowComponentSelector = React.forwardRef<
|
||||||
selectedRowKeys?: string[];
|
selectedRowKeys?: string[];
|
||||||
rows: BusterListRow[];
|
rows: BusterListRow[];
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
columnRowVariant: BusterListProps['columnRowVariant'];
|
columnRowVariant?: BusterListProps['columnRowVariant'];
|
||||||
}
|
}
|
||||||
>(
|
>(
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in New Issue