Skip to content

Commit

Permalink
🔨 fix the mdim edit hack
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Nov 4, 2024
1 parent 17e34b8 commit cd7bcf8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions site/multiDim/MultiDimDataPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -372,6 +382,7 @@ export const MultiDimDataPageContent = ({
{...grapherConfigComputed}
queryStr={queryStr}
getGrapherInstance={setGrapherInst}
adminBaseUrl={ADMIN_BASE_URL}
/>
</figure>
</div>
Expand Down

0 comments on commit cd7bcf8

Please sign in to comment.