Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

[dashboard transition] Cherry pick fix for dashboard force v2 edit #63

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Controls extends React.PureComponent {
}
/>
{dashboard.dash_save_perm &&
!dashboard.forceV2Edit &&
<SaveModal
dashboard={dashboard}
filters={filters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Logger,
ActionLog,
DASHBOARD_EVENT_NAMES,
LOG_ACTIONS_PREVIEW_V2,
LOG_ACTIONS_MOUNT_DASHBOARD,
LOG_ACTIONS_EXPLORE_DASHBOARD_CHART,
LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART,
Expand Down Expand Up @@ -68,6 +69,7 @@ class Dashboard extends React.PureComponent {
unsavedChanges: false,
};
this.handleSetEditMode = this.handleSetEditMode.bind(this);
this.handleConvertToV2 = this.handleConvertToV2.bind(this);

this.rerenderCharts = this.rerenderCharts.bind(this);
this.updateDashboardTitle = this.updateDashboardTitle.bind(this);
Expand Down Expand Up @@ -346,6 +348,21 @@ class Dashboard extends React.PureComponent {
exportChart(formData, 'csv');
}

handleConvertToV2(editMode) {
Logger.append(
LOG_ACTIONS_PREVIEW_V2,
{
force_v2_edit: this.props.dashboard.forceV2Edit,
edit_mode: editMode === true,
},
true,
);
const url = new URL(window.location); // eslint-disable-line
url.searchParams.set('version', 'v2');
if (editMode === true) url.searchParams.set('edit', true);
window.location = url; // eslint-disable-line
}

handleSetEditMode(nextEditMode) {
if (this.props.dashboard.forceV2Edit) {
this.handleConvertToV2(true);
Expand Down Expand Up @@ -386,6 +403,7 @@ class Dashboard extends React.PureComponent {
addSlicesToDashboard={this.addSlicesToDashboard}
editMode={this.props.editMode}
setEditMode={this.handleSetEditMode}
handleConvertToV2={this.handleConvertToV2}
/>
</div>
<div id="grid-container" className="slice-grid gridster">
Expand Down
19 changes: 2 additions & 17 deletions superset/assets/src/dashboard/deprecated/v1/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import InfoTooltipWithTrigger from '../../../../components/InfoTooltipWithTrigge
import PromptV2ConversionModal from '../../PromptV2ConversionModal';
import {
Logger,
LOG_ACTIONS_PREVIEW_V2,
LOG_ACTIONS_DISMISS_V2_PROMPT,
LOG_ACTIONS_SHOW_V2_INFO_PROMPT,
} from '../../../../logger';
Expand All @@ -31,6 +30,7 @@ const propTypes = {
updateDashboardTitle: PropTypes.func,
editMode: PropTypes.bool.isRequired,
setEditMode: PropTypes.func.isRequired,
handleConvertToV2: PropTypes.func.isRequired,
unsavedChanges: PropTypes.bool.isRequired,
};

Expand All @@ -43,25 +43,10 @@ class Header extends React.PureComponent {
showV2PromptModal: props.dashboard.promptV2Conversion,
};
this.toggleShowV2PromptModal = this.toggleShowV2PromptModal.bind(this);
this.handleConvertToV2 = this.handleConvertToV2.bind(this);
}
handleSaveTitle(title) {
this.props.updateDashboardTitle(title);
}
handleConvertToV2(editMode) {
Logger.append(
LOG_ACTIONS_PREVIEW_V2,
{
force_v2_edit: this.props.dashboard.forceV2Edit,
edit_mode: editMode === true,
},
true,
);
const url = new URL(window.location); // eslint-disable-line
url.searchParams.set('version', 'v2');
if (editMode === true) url.searchParams.set('edit', true);
window.location = url; // eslint-disable-line
}
toggleEditMode() {
this.props.setEditMode(!this.props.editMode);
}
Expand Down Expand Up @@ -169,7 +154,7 @@ class Header extends React.PureComponent {
!this.props.editMode && (
<PromptV2ConversionModal
onClose={this.toggleShowV2PromptModal}
handleConvertToV2={this.handleConvertToV2}
handleConvertToV2={this.props.handleConvertToV2}
forceV2Edit={dashboard.forceV2Edit}
v2AutoConvertDate={dashboard.v2AutoConvertDate}
v2FeedbackUrl={dashboard.v2FeedbackUrl}
Expand Down
2 changes: 2 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,8 @@ def dashboard(self, dashboard_id):
else:
dashboard_view = 'v1'
prompt_v2_conversion = not force_v1
if force_v2_edit:
dash_edit_perm = False

# Hack to log the dashboard_id properly, even when getting a slug
@log_this
Expand Down