Skip to content

Commit

Permalink
Merge pull request #2895 from owid/fix-empty-source-in-explorers
Browse files Browse the repository at this point in the history
fix(explorer): show data source defined in explorer configs
  • Loading branch information
sophiamersmann authored Nov 6, 2023
2 parents 2471fd7 + 2b8c603 commit f08f0df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
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

0 comments on commit f08f0df

Please sign in to comment.