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

✨ "Archive" label in dataset, link to Dataset preview in Wizard #4356

Merged
merged 13 commits into from
Jan 6, 2025
128 changes: 86 additions & 42 deletions adminSiteClient/DatasetEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import { SourceList } from "./SourceList.js"
import { VariableList, VariableListItem } from "./VariableList.js"
import { AdminAppContext, AdminAppContextType } from "./AdminAppContext.js"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { faDownload } from "@fortawesome/free-solid-svg-icons"
import { faDownload, faHatWizard } from "@fortawesome/free-solid-svg-icons"
import { faGithub } from "@fortawesome/free-brands-svg-icons"

import { ETL_WIZARD_URL } from "../settings/clientSettings.js"
import { Button } from "antd"
interface DatasetPageData {
id: number
name: string
Expand All @@ -28,6 +29,7 @@ interface DatasetPageData {
shortName: string
version: string
isPrivate: boolean
isArchived: boolean
nonRedistributable: boolean
updatePeriodDays: number

Expand Down Expand Up @@ -212,15 +214,23 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
const { dataset } = this.props
const { newDataset } = this
const isBulkImport = dataset.namespace !== "owid"

return (
<main className="DatasetEditPage">
<Prompt
when={this.isModified}
message="Are you sure you want to leave? Unsaved changes will be lost."
/>

{/* HEADER */}
<section>
<h1>{dataset.name}</h1>
{dataset.isArchived ? (
<h1>
<span style={{ color: "red" }}>Archived:</span>{" "}
{dataset.name}
</h1>
) : (
<h1>{dataset.name}</h1>
)}
{dataset.shortName && (
<h4 style={{ color: "gray" }}>
{dataset.namespace}/{dataset.version}/
Expand All @@ -234,13 +244,29 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
by={dataset.dataEditedByUserName}
/>
</p>

<Link
native
to={`/datasets/${dataset.id}.csv`}
className="btn btn-primary"
>
<FontAwesomeIcon icon={faDownload} /> Download CSV
</Link>
{/* Link to Wizard dataset preview */}
<a
href={`${ETL_WIZARD_URL}datasets?datasetId=${dataset.id}`}
target="_blank"
className="btn btn-tertiary"
rel="noopener"
>
<Button
type="default"
icon={<FontAwesomeIcon icon={faHatWizard} />}
>
Explore in Wizard
</Button>
</a>
{/* View on GitHub link (old) */}
{!isBulkImport && !dataset.isPrivate && (
<a
href={this.gitHistoryUrl}
Expand All @@ -251,6 +277,7 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
<FontAwesomeIcon icon={faGithub} /> View on GitHub
</a>
)}
{/* Download additional content (old) */}
{dataset.zipFile && (
<Link
native
Expand All @@ -262,6 +289,8 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
</Link>
)}
</section>

{/* DATASET METADATA */}
<section>
<h3>Dataset metadata</h3>
<form
Expand Down Expand Up @@ -334,21 +363,29 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
/>
</form>
</section>

{/* ORIGINS */}
<section>
<h3>Origins</h3>
<OriginList origins={dataset.origins || []} />
</section>

{/* SOURCES */}
{dataset.variableSources &&
dataset.variableSources.length > 0 && (
<section>
<h3>Sources</h3>
<SourceList sources={dataset.variableSources} />
</section>
)}

{/* INDICATORS */}
<section>
<h3>Indicators</h3>
<VariableList variables={dataset.variables} fields={[]} />
</section>

{/* CHARTS */}
<section>
<button
className="btn btn-primary float-right"
Expand All @@ -359,46 +396,53 @@ class DatasetEditor extends React.Component<{ dataset: DatasetPageData }> {
<h3>Charts</h3>
<ChartList charts={dataset.charts} />
</section>
<section>
<h3>Archive</h3>
<p>
Archive this grapher dataset to remove it from the main
list of active datasets.
</p>
{dataset.charts && dataset.charts.length > 0 ? (
<p>
<strong>
This dataset cannot be archived because it
contains charts.
</strong>
</p>
) : (

{/* ARCHIVE DATASET */}
{!dataset.isArchived && (
<section>
<h3>Archive</h3>
<p>
<strong>Before archiving, ensure that:</strong>
<ul>
<li>
The corresponding ETL grapher step has been
archived:{" "}
<code>
grapher/{dataset.namespace}/
{dataset.version}/{dataset.shortName}
</code>
</li>
<li>
The dataset is not used in any
indicator-based explorers.
</li>
</ul>
Archive this grapher dataset to remove it from the
main list of active datasets.
</p>
)}
<button
className="btn btn-outline-danger"
onClick={() => this.archive()}
disabled={dataset.charts && dataset.charts.length > 0}
>
Archive dataset
</button>
</section>
{dataset.charts && dataset.charts.length > 0 ? (
<p>
<strong>
This dataset cannot be archived because it
contains charts.
</strong>
</p>
) : (
<p>
<strong>Before archiving, ensure that:</strong>
<ul>
<li>
The corresponding ETL grapher step has
been archived:{" "}
<code>
grapher/{dataset.namespace}/
{dataset.version}/
{dataset.shortName}
</code>
</li>
<li>
The dataset is not used in any
indicator-based explorers.
</li>
</ul>
</p>
)}
<button
className="btn btn-outline-danger"
onClick={() => this.archive()}
disabled={
dataset.charts && dataset.charts.length > 0
}
>
Archive dataset
</button>
</section>
)}
</main>
)
}
Expand Down
1 change: 1 addition & 0 deletions adminSiteClient/VariableEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class VariableEditor extends React.Component<{
target="_blank"
rel="noopener"
>
{" "}
garden level
</a>
,{" "}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"s-expression": "^3.1.1",
"safe-stable-stringify": "^2.4.1",
"search-insights": "^2.14.0",
"sharp": "^0.32.5",
"sharp": "^0.33.5",
"shell-quote": "^1.7.3",
"shelljs": "^0.8.5",
"simple-git": "^3.16.1",
Expand Down
Loading
Loading