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