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

fix(explorer): show data source defined in explorer configs #2895

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/@ourworldindata/core-table/src/CoreColumnDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
OwidVariableDisplayConfigInterface,
ToleranceStrategy,
OwidOrigin,
OwidSource,
OwidVariablePresentation,
} from "@ourworldindata/utils"
import { CoreValueType, Color } from "./CoreTableConstants.js"
Expand Down Expand Up @@ -75,7 +74,12 @@ export interface CoreColumnDef extends ColumnColorScale {
color?: Color // A column can have a fixed color for use in charts where the columns are series

// Source information used for display only
source?: OwidSource
sourceName?: string
sourceLink?: string
dataPublishedBy?: string
dataPublisherSource?: string
retrievedDate?: string
additionalInfo?: string
timespanFromMetadata?: string

// Metadata v2
Expand Down
10 changes: 9 additions & 1 deletion packages/@ourworldindata/core-table/src/CoreTableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,15 @@ export abstract class AbstractCoreColumn<JS_TYPE extends PrimitiveType> {
}

get source(): OwidSource {
return this.def.source ?? {}
const { def } = this
return {
name: def.sourceName,
link: def.sourceLink,
dataPublishedBy: def.dataPublishedBy,
dataPublisherSource: def.dataPublisherSource,
retrievedDate: def.retrievedDate,
additionalInfo: def.additionalInfo,
}
}

// todo: remove. should not be on coretable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,12 @@ const columnDefFromOwidVariable = (
datasetName,
display,
nonRedistributable,
source,
sourceLink: source?.link,
sourceName: source?.name,
dataPublishedBy: source?.dataPublishedBy,
dataPublisherSource: source?.dataPublisherSource,
retrievedDate: source?.retrievedDate,
additionalInfo: source?.additionalInfo,
timespanFromMetadata: timespan,
origins,
presentation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class DownloadModal extends React.Component<DownloadModalProps> {
| undefined
if (!def) return undefined
return (
def.source?.link ??
def.sourceLink ??
(def.origins && def.origins.length > 0
? def.origins[0].urlMain
: undefined)
Expand Down