diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index 77b446373b..9fe8647f19 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -900,18 +900,10 @@ export class Grapher } @computed get editUrl(): string | undefined { - const yColumnSlugs = this.yColumnSlugs if (this.showAdminControls) { - // This is a workaround to make the edit button work for MDims. We - // probably want to do this in a more general way. - if ((window as any)._OWID_MULTI_DIM_PROPS) { - const varId = yColumnSlugs[0] - - return `${this.adminBaseUrl ?? ""}/admin/variables/${varId}/config` - } else - return `${this.adminBaseUrl}/admin/${ - this.manager?.editUrl ?? `charts/${this.id}/edit` - }` + return `${this.adminBaseUrl}/admin/${ + this.manager?.editUrl ?? `charts/${this.id}/edit` + }` } return undefined } diff --git a/site/multiDim/MultiDimDataPageContent.tsx b/site/multiDim/MultiDimDataPageContent.tsx index b026e81ef2..2770601326 100644 --- a/site/multiDim/MultiDimDataPageContent.tsx +++ b/site/multiDim/MultiDimDataPageContent.tsx @@ -28,7 +28,7 @@ import { } from "@ourworldindata/utils" import cx from "classnames" import { DebugProvider } from "../gdocs/DebugContext.js" -import { DATA_API_URL } from "../../settings/clientSettings.js" +import { ADMIN_BASE_URL, DATA_API_URL } from "../../settings/clientSettings.js" import { FaqEntryKeyedByGdocIdAndFragmentId, MultiDimDataPageConfigEnriched, @@ -290,17 +290,27 @@ export const MultiDimDataPageContent = ({ } if (!grapherConfigIsReady) return baseConfig + const variables = currentView?.indicators?.["y"] + const editUrl = + variables?.length === 1 + ? `variables/${variables[0]}/config` + : undefined return { ...varGrapherConfig, ...baseConfig, dataApiUrl: DATA_API_URL, - // TODO: The way manager is set here is just a workaround to make the edit button in the - // share menu work. This should be removed before we publish MDims! manager: { canonicalUrl, + editUrl, }, } as GrapherProgrammaticInterface - }, [varGrapherConfig, grapherConfigIsReady, bounds, canonicalUrl]) + }, [ + varGrapherConfig, + grapherConfigIsReady, + bounds, + canonicalUrl, + currentView?.indicators, + ]) const hasTopicTags = !!config.config.topicTags?.length @@ -384,6 +394,7 @@ export const MultiDimDataPageContent = ({ {...grapherConfigComputed} queryStr={queryStr} getGrapherInstance={setGrapherInst} + adminBaseUrl={ADMIN_BASE_URL} />