---------
Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
(cherry picked from commit 6433053479)
This commit is contained in:
@@ -51,9 +51,13 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler {
|
|||||||
|
|
||||||
// If we are not in editing (for example after full page reload)
|
// If we are not in editing (for example after full page reload)
|
||||||
if (!isEditing) {
|
if (!isEditing) {
|
||||||
// Not sure what is best to do here.
|
if (this._scene.state.editable) {
|
||||||
// The reason for the timeout is for this change to happen after the url sync has completed
|
// Not sure what is best to do here.
|
||||||
setTimeout(() => this._scene.onEnterEditMode());
|
// The reason for the timeout is for this change to happen after the url sync has completed
|
||||||
|
setTimeout(() => this._scene.onEnterEditMode());
|
||||||
|
} else {
|
||||||
|
update.editview = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (values.hasOwnProperty('editview')) {
|
} else if (values.hasOwnProperty('editview')) {
|
||||||
update.editview = undefined;
|
update.editview = undefined;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export function ToolbarActions({ dashboard }: Props) {
|
|||||||
meta,
|
meta,
|
||||||
editview,
|
editview,
|
||||||
editPanel,
|
editPanel,
|
||||||
|
editable,
|
||||||
hasCopiedPanel: copiedPanel,
|
hasCopiedPanel: copiedPanel,
|
||||||
} = dashboard.useState();
|
} = dashboard.useState();
|
||||||
const { isPlaying } = playlistSrv.useState();
|
const { isPlaying } = playlistSrv.useState();
|
||||||
@@ -326,7 +327,7 @@ export function ToolbarActions({ dashboard }: Props) {
|
|||||||
|
|
||||||
toolbarActions.push({
|
toolbarActions.push({
|
||||||
group: 'main-buttons',
|
group: 'main-buttons',
|
||||||
condition: !isEditing && dashboard.canEditDashboard() && !isViewingPanel && !isPlaying,
|
condition: !isEditing && dashboard.canEditDashboard() && !isViewingPanel && !isPlaying && editable,
|
||||||
render: () => (
|
render: () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -344,6 +345,27 @@ export function ToolbarActions({ dashboard }: Props) {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
toolbarActions.push({
|
||||||
|
group: 'main-buttons',
|
||||||
|
condition: !isEditing && dashboard.canEditDashboard() && !isViewingPanel && !isPlaying && !editable,
|
||||||
|
render: () => (
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
dashboard.onEnterEditMode();
|
||||||
|
dashboard.setState({ editable: true, meta: { ...meta, canEdit: true } });
|
||||||
|
}}
|
||||||
|
tooltip="This dashboard was marked as read only"
|
||||||
|
key="edit"
|
||||||
|
className={styles.buttonWithExtraMargin}
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
data-testid={selectors.components.NavToolbar.editDashboard.editButton}
|
||||||
|
>
|
||||||
|
Make editable
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
toolbarActions.push({
|
toolbarActions.push({
|
||||||
group: 'settings',
|
group: 'settings',
|
||||||
condition: isEditing && dashboard.canEditDashboard() && isShowingDashboard,
|
condition: isEditing && dashboard.canEditDashboard() && isShowingDashboard,
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ export function panelMenuBehavior(menu: VizPanelMenu, isRepeat = false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dashboard.canEditDashboard() && !isRepeat && !isEditingPanel) {
|
if (dashboard.canEditDashboard() && dashboard.state.editable && !isRepeat && !isEditingPanel) {
|
||||||
// We could check isEditing here but I kind of think this should always be in the menu,
|
// We could check isEditing here but I kind of think this should always be in the menu,
|
||||||
// and going into panel edit should make the dashboard go into edit mode is it's not already
|
// and going into panel edit should make the dashboard go into edit mode is it's not already
|
||||||
items.push({
|
items.push({
|
||||||
text: t('panel.header-menu.edit', `Edit`),
|
text: t('panel.header-menu.edit', `Edit`),
|
||||||
iconClassName: 'eye',
|
iconClassName: 'edit',
|
||||||
shortcut: 'e',
|
shortcut: 'e',
|
||||||
onClick: () => DashboardInteractions.panelMenuItemClicked('edit'),
|
onClick: () => DashboardInteractions.panelMenuItemClicked('edit'),
|
||||||
href: getEditPanelUrl(getPanelIdForVizPanel(panel)),
|
href: getEditPanelUrl(getPanelIdForVizPanel(panel)),
|
||||||
|
|||||||
@@ -64,14 +64,6 @@ export function useDashboardEditPageNav(dashboard: DashboardScene, currentEditVi
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dashboard.state.meta.canMakeEditable) {
|
|
||||||
pageNav.children!.push({
|
|
||||||
text: t('dashboard-settings.general.title', 'General'),
|
|
||||||
url: locationUtil.getUrlForPartial(location, { editview: 'settings', editIndex: null }),
|
|
||||||
active: currentEditView === 'settings',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dashboard.state.id && dashboard.state.meta.canSave) {
|
if (dashboard.state.id && dashboard.state.meta.canSave) {
|
||||||
pageNav.children!.push({
|
pageNav.children!.push({
|
||||||
text: t('dashboard-settings.versions.title', 'Versions'),
|
text: t('dashboard-settings.versions.title', 'Versions'),
|
||||||
|
|||||||
Reference in New Issue
Block a user