Skip to content

Commit

Permalink
✨ Take user to variable edit page instead of dataset when clicking on…
Browse files Browse the repository at this point in the history
… a pencil (#4231)

* ✨ Take user to variable edit page instead of dataset when clicking on a pencil

---------

Co-authored-by: sophiamersmann <[email protected]>
  • Loading branch information
Marigold and sophiamersmann authored Nov 29, 2024
1 parent c5edf06 commit d1c6b0d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class SourcesModal extends React.Component<

@computed private get editBaseUrl(): string | undefined {
if (!this.manager.showAdminControls) return undefined
return `${this.props.manager.adminBaseUrl}/admin/datasets`
return `${this.props.manager.adminBaseUrl}/admin`
}

@computed private get columns(): CoreColumn[] {
Expand Down Expand Up @@ -359,9 +359,20 @@ export class Source extends React.Component<{
}

@computed private get editUrl(): string | undefined {
// there will not be a datasetId for explorers that define the FASTT in TSV
if (!this.props.editBaseUrl || !this.def.datasetId) return undefined
return `${this.props.editBaseUrl}/${this.def.datasetId}`
if (!this.props.editBaseUrl) return undefined

// point user directly to the variable edit page if possible
if (this.def.owidVariableId) {
return `${this.props.editBaseUrl}/variables/${this.def.owidVariableId}`
}

// if that's not possible, point user to the dataset edit page
if (this.def.datasetId) {
return `${this.props.editBaseUrl}/datasets/${this.def.datasetId}`
}

// we can't link to an edit page for explorers that define the FASTT in TSV
return undefined
}

@computed private get producers(): string[] {
Expand Down

0 comments on commit d1c6b0d

Please sign in to comment.