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

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

Merged
merged 3 commits into from
Nov 29, 2024
Merged
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
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