Skip to content

Commit b026c1e

Browse files
committed
fix: add enum ChartStatusType
1 parent 127cdaf commit b026c1e

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

superset-frontend/src/explore/components/SaveModal.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { Radio } from '@superset-ui/core/components/Radio';
4747
import { GRID_COLUMN_COUNT } from 'src/dashboard/util/constants';
4848
import { canUserEditDashboard } from 'src/dashboard/util/permissionUtils';
4949
import { setSaveChartModalVisibility } from 'src/explore/actions/saveModalActions';
50-
import { SaveActionType } from 'src/explore/types';
50+
import { SaveActionType, ChartStatusType } from 'src/explore/types';
5151
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
5252
import {
5353
removeChartState,
@@ -102,7 +102,9 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
102102
this.state = {
103103
newSliceName: props.sliceName,
104104
datasetName: props.datasource?.name,
105-
action: this.canOverwriteSlice() ? 'overwrite' : 'saveas',
105+
action: this.canOverwriteSlice()
106+
? ChartStatusType.overwrite
107+
: ChartStatusType.saveas,
106108
isLoading: false,
107109
dashboard: undefined,
108110
tabsData: [],
@@ -258,7 +260,7 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
258260
: [...sliceDashboards, dashboard.id];
259261
formData.dashboards = sliceDashboards;
260262
if (
261-
this.state.action === 'saveas' &&
263+
this.state.action === ChartStatusType.saveas &&
262264
this.state.selectedTab?.value !== 'OUT_OF_TAB'
263265
) {
264266
selectedTabId = this.state.selectedTab?.value as string;
@@ -603,7 +605,7 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
603605
<Radio
604606
id="saveas-radio"
605607
data-test="saveas-radio"
606-
checked={this.state.action === 'saveas'}
608+
checked={this.state.action === ChartStatusType.saveas}
607609
onChange={() => this.changeAction('saveas')}
608610
>
609611
{t('Save as...')}
@@ -657,7 +659,7 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
657659
}
658660
/>
659661
</FormItem>
660-
{this.state.action === 'saveas' && (
662+
{this.state.action === ChartStatusType.saveas && (
661663
<FormItem
662664
label={t('Add to tabs')}
663665
data-test="save-chart-modal-select-tabs-form"

superset-frontend/src/explore/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ import { Slice } from 'src/types/Chart';
3535

3636
export type SaveActionType = 'overwrite' | 'saveas';
3737

38+
export enum ChartStatusType {
39+
overwrite = 'overwrite',
40+
saveas = 'saveas',
41+
}
42+
3843
export type ChartStatus =
3944
| 'loading'
4045
| 'rendered'

0 commit comments

Comments
 (0)