Skip to content

Commit

Permalink
fix: fix rebase issue regarding source metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Nov 16, 2023
1 parent 972e45f commit 289d052
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/@ourworldindata/core-table/src/CoreColumnDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,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
timespan?: string

// Metadata v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,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,
timespan,
origins,
presentation,
Expand Down
11 changes: 8 additions & 3 deletions packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
splitSourceTextIntoFragments,
DisplaySource,
prepareSourcesForDisplay,
OwidSource,
} from "@ourworldindata/utils"
import {
IndicatorKeyData,
Expand Down Expand Up @@ -91,6 +92,10 @@ export class Source extends React.Component<{
return this.props.column.def
}

@computed private get source(): OwidSource {
return this.props.column.source ?? {}
}

@computed private get title(): string {
return this.def.display?.name || this.def.name || ""
}
Expand Down Expand Up @@ -134,12 +139,12 @@ export class Source extends React.Component<{
return (
(this.def.descriptionKey && this.def.descriptionKey.length > 0) ||
!!this.def.descriptionFromProducer ||
!!this.def.source?.additionalInfo
!!this.source.additionalInfo
)
}

@computed private get sourceLinks(): string[] {
return splitSourceTextIntoFragments(this.def.source?.link)
return splitSourceTextIntoFragments(this.source.link)
}

@computed private get sourcesForDisplay(): DisplaySource[] {
Expand Down Expand Up @@ -181,7 +186,7 @@ export class Source extends React.Component<{
attributionShort={
this.def.presentation?.attributionShort
}
additionalInfo={this.def.source?.additionalInfo}
additionalInfo={this.source.additionalInfo}
isEmbeddedInADataPage={this.props.isEmbeddedInADataPage}
/>
)}
Expand Down

0 comments on commit 289d052

Please sign in to comment.