Skip to content

Commit

Permalink
undo module level showWriteControls
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomThomson committed Sep 14, 2023
1 parent f51b9a7 commit 9d28907
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -61,6 +61,7 @@ import { DashboardPanelState, DashboardContainerInput } from '../../../common';
import { dashboardContainerReducers } from '../state/dashboard_container_reducers';
import { startDiffingDashboardState } from '../state/diffing/dashboard_diffing_integration';
import { combineDashboardFiltersWithControlGroupFilters } from './create/controls/dashboard_control_group_integration';
import { DashboardCapabilitiesService } from '../../services/dashboard_capabilities/types';

export interface InheritedChildInput {
filters: Filter[];
Expand All @@ -83,7 +84,6 @@ type DashboardReduxEmbeddableTools = ReduxEmbeddableTools<
typeof dashboardContainerReducers
>;

const showWriteControls = pluginServices.getServices().dashboardCapabilities.showWriteControls;
export const DashboardContainerContext = createContext<DashboardContainer | null>(null);
export const useDashboardContainer = (): DashboardContainer => {
const dashboard = useContext<DashboardContainer | null>(DashboardContainerContext);
Expand Down Expand Up @@ -123,6 +123,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
// Services that are used in the Dashboard container code
private creationOptions?: DashboardCreationOptions;
private analyticsService: DashboardAnalyticsService;
private showWriteControls: DashboardCapabilitiesService['showWriteControls'];
private theme$;
private chrome;
private customBranding;
Expand Down Expand Up @@ -156,6 +157,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
},
chrome: this.chrome,
customBranding: this.customBranding,
dashboardCapabilities: { showWriteControls: this.showWriteControls },
} = pluginServices.getServices());

this.creationOptions = creationOptions;
Expand Down Expand Up @@ -244,7 +246,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
public updateInput(changes: Partial<DashboardContainerInput>): void {
// block the Dashboard from entering edit mode if this Dashboard is managed.
if (
(this.getState().componentState.managed || !showWriteControls) &&
(this.getState().componentState.managed || !this.showWriteControls) &&
changes.viewMode?.toLowerCase() === ViewMode.EDIT?.toLowerCase()
) {
const { viewMode, ...rest } = changes;
Expand Down
Expand Up @@ -16,9 +16,6 @@ import {
DashboardStateFromSettingsFlyout,
} from '../types';
import { DashboardContainerInput } from '../../../common';
import { pluginServices } from '../../services/plugin_services';

const showWriteControls = pluginServices.getServices().dashboardCapabilities.showWriteControls;

export const dashboardContainerReducers = {
// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -94,7 +91,7 @@ export const dashboardContainerReducers = {
action: PayloadAction<DashboardContainerInput['viewMode']>
) => {
// Managed Dashboards cannot be put into edit mode.
if (state.componentState.managed || !showWriteControls) {
if (state.componentState.managed) {
state.explicitInput.viewMode = ViewMode.VIEW;
return;
}
Expand Down

0 comments on commit 9d28907

Please sign in to comment.