Skip to content

Commit

Permalink
🚧 Temporary feature merge branch for x-mas features (as a base for gr…
Browse files Browse the repository at this point in the history
…apher refactorings)
  • Loading branch information
danyx23 committed Jan 7, 2025
4 parents c8cf78e + fa3bde8 + dbe1aa1 + be8aa57 commit 4a1e753
Show file tree
Hide file tree
Showing 60 changed files with 4,958 additions and 3,859 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG VARIANT=18
ARG VARIANT=22
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:dev-${VARIANT}

COPY .tmux.conf /home/node/.tmux.conf
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
22.12.0
2 changes: 1 addition & 1 deletion adminSiteClient/AdminSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const AdminSidebar = (): React.ReactElement => (
{chartViewsFeatureEnabled && (
<li>
<Link to="/chartViews">
<FontAwesomeIcon icon={faPanorama} /> Narrative views
<FontAwesomeIcon icon={faPanorama} /> Narrative charts
</Link>
</li>
)}
Expand Down
4 changes: 2 additions & 2 deletions adminSiteClient/ChartEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ export class ChartEditor extends AbstractChartEditor<ChartEditorManager> {
)
}

async saveAsNarrativeView(): Promise<void> {
async saveAsChartView(): Promise<void> {
const { patchConfig, grapher } = this

const chartJson = omit(patchConfig, CHART_VIEW_PROPS_TO_OMIT)

const suggestedName = grapher.title ? slugify(grapher.title) : undefined

const name = prompt(
"Please enter a programmatic name for the narrative view. Note that this name cannot be changed later.",
"Please enter a programmatic name for the narrative chart. Note that this name cannot be changed later.",
suggestedName
)

Expand Down
5 changes: 3 additions & 2 deletions adminSiteClient/ChartViewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
References,
type EditorTab,
} from "./AbstractChartEditor.js"
import { ENV } from "../settings/clientSettings.js"
import { BAKED_BASE_URL, ENV } from "../settings/clientSettings.js"
import {
CHART_VIEW_PROPS_TO_OMIT,
CHART_VIEW_PROPS_TO_PERSIST,
Expand All @@ -16,7 +16,8 @@ import { diffGrapherConfigs, omit, pick } from "@ourworldindata/utils"
// Don't yet show chart views in the admin interface
// This is low-stakes - if it shows up anyhow (e.g. on staging servers), it's not a big deal.
// TODO: Remove this flag once we're launching this feature
export const chartViewsFeatureEnabled = ENV === "development"
export const chartViewsFeatureEnabled =
ENV === "development" || BAKED_BASE_URL.includes("narrative-")

export interface Chart {
id: number
Expand Down
6 changes: 3 additions & 3 deletions adminSiteClient/ChartViewIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AdminAppContext } from "./AdminAppContext.js"
import { Timeago } from "./Forms.js"
import { ColumnsType } from "antd/es/table/InternalTable.js"
import { ApiChartViewOverview } from "../adminShared/AdminTypes.js"
import { BAKED_GRAPHER_URL } from "../settings/clientSettings.js"
import { GRAPHER_DYNAMIC_THUMBNAIL_URL } from "../settings/clientSettings.js"
import { Link } from "./Link.js"
import {
buildSearchWordsFromSearchString,
Expand All @@ -28,7 +28,7 @@ function createColumns(
width: 200,
render: (chartConfigId) => (
<img
src={`${BAKED_GRAPHER_URL}/by-uuid/${chartConfigId}.svg`}
src={`${GRAPHER_DYNAMIC_THUMBNAIL_URL}/by-uuid/${chartConfigId}.svg`}
style={{ maxWidth: 200, maxHeight: 200 }}
/>
),
Expand Down Expand Up @@ -135,7 +135,7 @@ export function ChartViewIndexPage() {
}, [admin])

return (
<AdminLayout title="Narrative views">
<AdminLayout title="Narrative charts">
<main className="ChartViewIndexPage">
<Flex justify="space-between">
<Input
Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/EditorReferencesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ReferencesSection = (props: {

const chartViews = !!props.references?.chartViews?.length && (
<>
<p>Narrative views based on this chart</p>
<p>Narrative charts based on this chart</p>
<ul className="list-group">
{props.references.chartViews.map((chartView) => (
<li key={chartView.id} className="list-group-item">
Expand Down
8 changes: 4 additions & 4 deletions adminSiteClient/SaveButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class SaveButtonsForChart extends Component<{
void this.props.editor.saveAsNewGrapher()
}

@action.bound onSaveAsNarrativeView() {
void this.props.editor.saveAsNarrativeView()
@action.bound onSaveAsChartView() {
void this.props.editor.saveAsChartView()
}

@action.bound onPublishToggle() {
Expand Down Expand Up @@ -120,10 +120,10 @@ class SaveButtonsForChart extends Component<{
<div className="mt-2">
<button
className="btn btn-primary"
onClick={this.onSaveAsNarrativeView}
onClick={this.onSaveAsChartView}
disabled={isSavingDisabled}
>
Save as narrative view
Save as narrative chart
</button>
</div>
)}
Expand Down
Loading

0 comments on commit 4a1e753

Please sign in to comment.