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

feat(admin): Admin for narrative views #4208

Merged
merged 13 commits into from
Dec 5, 2024
Merged

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Nov 22, 2024

This PR introduces most of the basic admin functionality needed for narrative views, but not quite all of it just yet. But I think this is ready for a review for at this point, anyhow.

Part of #4128.

Features:

  • Rename chart_views#slug column to #name
  • A new page listing all narrative views, under /admin/chartViews (based on antd table)
  • Create a new chart view based on a parent chart
  • Have chart views included in Refs tab
  • Show diff between parent chart and view

Open questions:

  • For indicators, the children charts are listed in the "Inheritance" tab. For charts, I have now opted to unify all uses of a chart in the "Refs" tab. Does this make sense, or do we want to unify that?
Screenshots

CleanShot 2024-11-30 at 23 45 17
CleanShot 2024-11-30 at 23 46 53

@marcelgerber marcelgerber changed the title feat(admin): enable "Save as narrative view" feat(admin): Admin for narrative views Nov 22, 2024
Base automatically changed from narrative-views-api to master November 22, 2024 17:02
@owidbot
Copy link
Contributor

owidbot commented Nov 22, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-narrative-views-admin

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-11-22 17:22:01 UTC
Execution time: 1.24 seconds

@marcelgerber marcelgerber force-pushed the narrative-views-admin branch 2 times, most recently from ef1d8d3 to 07ce35f Compare November 28, 2024 12:22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 13 changed files in this pull request and generated no suggestions.

Files not reviewed (8)
  • adminSiteClient/ChartEditor.ts: Evaluated as low risk
  • adminSiteClient/ChartViewEditor.ts: Evaluated as low risk
  • packages/@ourworldindata/types/src/dbTypes/ChartViews.ts: Evaluated as low risk
  • adminShared/AdminTypes.ts: Evaluated as low risk
  • db/migration/1733004083678-RenameChartViewsSlug.ts: Evaluated as low risk
  • adminSiteClient/AdminSidebar.tsx: Evaluated as low risk
  • adminSiteClient/AdminApp.tsx: Evaluated as low risk
  • adminSiteClient/EditorReferencesTab.tsx: Evaluated as low risk
Comments skipped due to low confidence (2)

adminSiteClient/SaveButtons.tsx:224

  • [nitpick] The button text 'Go to parent chart' could be more descriptive. Consider renaming it to 'Edit parent chart' for clarity.
Go to parent chart

adminSiteClient/SaveButtons.tsx:127

  • [nitpick] The button text 'Save as narrative view' could be more descriptive. Consider renaming it to 'Create narrative view' for consistency with other button texts.
Save as narrative view
@marcelgerber marcelgerber requested a review from danyx23 December 2, 2024 14:21
@marcelgerber marcelgerber marked this pull request as ready for review December 2, 2024 14:21
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work, Marcel! I left a few minor comments but this is coming along nicely :). A way to delete narrative views that are not referenced would be good to add.

adminSiteServer/apiRouter.ts Show resolved Hide resolved
adminSiteServer/apiRouter.ts Outdated Show resolved Hide resolved
adminSiteClient/ChartViewIndexPage.tsx Outdated Show resolved Hide resolved

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

const name = prompt(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: we could allow changing the name as long as there are no active references. We don't have to do this now but if typos happen then this might be nice.

return (
<div>
<Section name="Config">
<textarea
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a squiggly line here that this needs a label. It's debug functionality but maybe worth it for a cleaner editor experience :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be some kind of editor (accessibility?) plugin that you have and I don't?
Anyhow, I tried quickly adding one and then the layout broke, and I couldn't be arsed 😀

adminSiteServer/apiRouter.ts Show resolved Hide resolved
adminSiteClient/ChartEditor.ts Outdated Show resolved Hide resolved
adminSiteClient/EditorDebugTab.tsx Outdated Show resolved Hide resolved
width: 200,
render: (chartConfigId) => (
<img
src={`${BAKED_GRAPHER_URL}/by-uuid/${chartConfigId}.svg`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work on prod but not on staging servers, right? Could we make this work now that we have CF preview deploys?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this will also work on staging sites, as long as that config is available.

See http://staging-site-marcel/grapher/by-uuid/0191b6c7-364e-7cf2-be6e-8cee8e073203.svg, for example!

@marcelgerber marcelgerber merged commit e585c7d into master Dec 5, 2024
22 checks passed
@marcelgerber marcelgerber deleted the narrative-views-admin branch December 5, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants