From 002577c7dc050e89460bae70f4bc642aa62b8d53 Mon Sep 17 00:00:00 2001 From: Marigold Date: Thu, 28 Nov 2024 20:26:54 +0100 Subject: [PATCH 1/3] :sparkles: Take user to variable edit page instead of dataset when clicking on a pencil --- .../@ourworldindata/grapher/src/modal/SourcesModal.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx index 79bd1d5a2cc..c4a31a49882 100644 --- a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx +++ b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx @@ -361,7 +361,13 @@ 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}` + + // point user directly to the variable edit page if possible + if (this.def.owidVariableId) { + return `${this.props.editBaseUrl.replace("datasets/", "variables/")}/${this.def.owidVariableId}` + } else { + return `${this.props.editBaseUrl}/${this.def.datasetId}` + } } @computed private get producers(): string[] { From c91fe66848034f0bf458e7a3b22af56b10a4b683 Mon Sep 17 00:00:00 2001 From: Marigold Date: Thu, 28 Nov 2024 20:35:53 +0100 Subject: [PATCH 2/3] wip --- packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx index c4a31a49882..6726b2e5077 100644 --- a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx +++ b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx @@ -364,7 +364,7 @@ export class Source extends React.Component<{ // point user directly to the variable edit page if possible if (this.def.owidVariableId) { - return `${this.props.editBaseUrl.replace("datasets/", "variables/")}/${this.def.owidVariableId}` + return `${this.props.editBaseUrl.replace("datasets", "variables")}/${this.def.owidVariableId}` } else { return `${this.props.editBaseUrl}/${this.def.datasetId}` } From 98cd27735cc7dd83992be3ad947d8f21399d89cd Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Fri, 29 Nov 2024 09:44:58 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=A8=20(sources=20modal)=20small=20?= =?UTF-8?q?refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/modal/SourcesModal.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx index 6726b2e5077..049449ea53a 100644 --- a/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx +++ b/packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx @@ -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[] { @@ -359,15 +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 + if (!this.props.editBaseUrl) return undefined // point user directly to the variable edit page if possible if (this.def.owidVariableId) { - return `${this.props.editBaseUrl.replace("datasets", "variables")}/${this.def.owidVariableId}` - } else { - return `${this.props.editBaseUrl}/${this.def.datasetId}` + 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[] {