From cd7bcf823302b6c37744995b3ac2afaac1bf827b Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Mon, 4 Nov 2024 10:51:41 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20fix=20the=20mdim=20edit=20hack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/multiDim/MultiDimDataPageContent.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/site/multiDim/MultiDimDataPageContent.tsx b/site/multiDim/MultiDimDataPageContent.tsx index 38f3c38b44..5de7edbffd 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 { MultiDimDataPageProps, MultiDimDimensionChoices, @@ -278,17 +278,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 @@ -372,6 +382,7 @@ export const MultiDimDataPageContent = ({ {...grapherConfigComputed} queryStr={queryStr} getGrapherInstance={setGrapherInst} + adminBaseUrl={ADMIN_BASE_URL} />