Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding display settings of indicators in mdims #4460

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

rakyi
Copy link
Contributor

@rakyi rakyi commented Jan 16, 2025

We now normalize the indicators to a list of objects, which can have an optional display property. See IndicatorConfig.

Resolves #4040

@rakyi rakyi requested a review from marcelgerber January 16, 2025 10:45
@rakyi rakyi force-pushed the mdim-display-override branch from 719bf31 to 8aa0683 Compare January 16, 2025 10:45
We now normalize the indicators to a list of objects, which can have an
optional `display` property. See `IndicatorConfig`.
@rakyi rakyi force-pushed the mdim-display-override branch from 8aa0683 to 646349a Compare January 16, 2025 10:49
@owidbot
Copy link
Contributor

owidbot commented Jan 16, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-mdim-display-override

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2025-01-16 11:07:03 UTC
Execution time: 1.18 seconds

Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, and easier than expected!


type IndicatorConfigBeforePreProcessing = Omit<IndicatorConfig, "id"> & {
// Indicator ID or catalog path
id: number | string
Copy link
Member

@marcelgerber marcelgerber Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if now, we should be using catalogPath here specifically when referring to these variables by path?
In the past, I opted to have them as a union type precisely because it was a flat property and not an object. But now that we have this as an object either way, this all doesn't apply any more, and maybe the logic gets easier if we don't have to have so many type-based conditionals on it?

Ideally, we'd want to have a union type, like

{ id: number } | { catalogPath: string }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changed.

case "object": {
if (isIndicatorConfig(indicator)) return indicator
if (typeof indicator.id === "string") {
const id = catalogPathToIndicatorIdMap.get(indicator.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to change the definition of allCatalogPaths above also, so that catalogPathToIndicatorIdMap actually contains the correct mapping for when indicator is an object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I was relying too much on type checking. Fixed.

@rakyi rakyi requested a review from marcelgerber January 17, 2025 10:18
Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@rakyi rakyi merged commit 437e7c6 into master Jan 20, 2025
26 checks passed
@rakyi rakyi deleted the mdim-display-override branch January 20, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add overriding of the display settings of indicators so that colors, the display name etc could be set
3 participants