mirror of
https://github.com/apache/superset.git
synced 2026-04-28 20:44:24 +00:00
Compare commits
1 Commits
fix-webpac
...
dataset-cr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bfc128e20 |
@@ -18,7 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import Button from 'src/components/Button';
|
import Button from 'src/components/Button';
|
||||||
import { t } from '@superset-ui/core';
|
import { Icons } from 'src/components/Icons';
|
||||||
|
import { Menu } from 'src/components/Menu';
|
||||||
|
import { DropdownButton } from 'src/components/DropdownButton';
|
||||||
|
import { t, useTheme } from '@superset-ui/core';
|
||||||
import { useSingleViewResource } from 'src/views/CRUD/hooks';
|
import { useSingleViewResource } from 'src/views/CRUD/hooks';
|
||||||
import { logEvent } from 'src/logger/actions';
|
import { logEvent } from 'src/logger/actions';
|
||||||
import withToasts from 'src/components/MessageToasts/withToasts';
|
import withToasts from 'src/components/MessageToasts/withToasts';
|
||||||
@@ -85,7 +88,7 @@ function Footer({
|
|||||||
|
|
||||||
const tooltipText = t('Select a database table.');
|
const tooltipText = t('Select a database table.');
|
||||||
|
|
||||||
const onSave = () => {
|
const onSave = (chartRedirect = true) => {
|
||||||
if (datasetObject) {
|
if (datasetObject) {
|
||||||
const data = {
|
const data = {
|
||||||
database: datasetObject.db?.id,
|
database: datasetObject.db?.id,
|
||||||
@@ -97,32 +100,55 @@ function Footer({
|
|||||||
if (!response) {
|
if (!response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof response === 'number') {
|
if (typeof response === 'number' && chartRedirect) {
|
||||||
logEvent(LOG_ACTIONS_DATASET_CREATION_SUCCESS, datasetObject);
|
logEvent(LOG_ACTIONS_DATASET_CREATION_SUCCESS, datasetObject);
|
||||||
// When a dataset is created the response we get is its ID number
|
// When a dataset is created the response we get is its ID number
|
||||||
history.push(`/chart/add/?dataset=${datasetObject.table_name}`);
|
history.push(`/chart/add/?dataset=${datasetObject.table_name}`);
|
||||||
|
} else {
|
||||||
|
history.push('/tablemodelview/list/');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const CREATE_DATASET_TEXT = t('Create dataset and create chart');
|
const onSaveDatasetOnly = () => {
|
||||||
|
onSave(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const CREATE_DATASET_AND_CHART_TEXT = t('Create dataset and create chart');
|
||||||
|
const CREATE_DATASET_TEXT = t('Only create dataset');
|
||||||
|
|
||||||
const disabledCheck =
|
const disabledCheck =
|
||||||
!datasetObject?.table_name ||
|
!datasetObject?.table_name ||
|
||||||
!hasColumns ||
|
!hasColumns ||
|
||||||
datasets?.includes(datasetObject?.table_name);
|
datasets?.includes(datasetObject?.table_name);
|
||||||
|
|
||||||
|
const overlayMenu = (
|
||||||
|
<Menu>
|
||||||
|
<Menu.Item onClick={onSaveDatasetOnly}>{CREATE_DATASET_TEXT}</Menu.Item>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button onClick={cancelButtonOnClick}>{t('Cancel')}</Button>
|
<Button onClick={cancelButtonOnClick}>{t('Cancel')}</Button>
|
||||||
<Button
|
<DropdownButton
|
||||||
buttonStyle="primary"
|
onClick={onSave}
|
||||||
|
dropdownRender={() => overlayMenu}
|
||||||
|
icon={
|
||||||
|
<Icons.DownOutlined
|
||||||
|
iconSize="xs"
|
||||||
|
iconColor={theme.colors.primary.dark2}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
trigger={['click']}
|
||||||
disabled={disabledCheck}
|
disabled={disabledCheck}
|
||||||
tooltip={!datasetObject?.table_name ? tooltipText : undefined}
|
tooltip={!datasetObject?.table_name ? tooltipText : undefined}
|
||||||
onClick={onSave}
|
|
||||||
>
|
>
|
||||||
{CREATE_DATASET_TEXT}
|
{CREATE_DATASET_AND_CHART_TEXT}
|
||||||
</Button>
|
</DropdownButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user