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

🎉 (admin) data insight index page / TAS-845 #4490

Open
wants to merge 26 commits into
base: gdoc-di-props
Choose a base branch
from

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Jan 27, 2025

Adds an index page for data insights in the admin.

Summary

  • The /dataInsights endpoint returns all data insights, enriched with information that is surfaced on the index page (e.g. image, topic tags, chart type)
  • The index page has a list and gallery layout (top right) and allows to filter by publication status.

Notes

  • The data insights query assumes the image block comes first
  • Because we're now surfacing the grapher-url, I added some validation for it. As far as I know, the grapher-url should be a valid grapher or explorer link, but maybe I'm forgetting something?
  • Search includes the body text. I just grabbed the markdown column for that because it was easiest. What's a little weird about that is that the markdown contains image filenames (and maybe other stuff), which sometimes leads to weird search results. I don't think that's too bad but if it's straight-forward to concat all text elements instead, let me know and I'm happy to rewrite
  • Data insight images that are not squared get squished in the gallery (see screenshot below)
Screenshots

Screenshot 2025-01-30 at 10 42 08


This is part 2 of 3 in a stack made with GitButler:

@owidbot
Copy link
Contributor

owidbot commented Jan 27, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-di-index-page

SVG tester:

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

Edited: 2025-01-27 09:54:56 UTC
Execution time: 1.23 seconds

@sophiamersmann sophiamersmann changed the title 🎉 (admin) data insight index page 🎉 (admin) data insight index page / TAS-845 Jan 28, 2025
Copy link

@sophiamersmann sophiamersmann force-pushed the di-index-page branch 2 times, most recently from 46f4507 to 3d44a47 Compare January 29, 2025 16:12
@sophiamersmann sophiamersmann marked this pull request as ready for review January 29, 2025 16:15
@sophiamersmann sophiamersmann requested a review from ikesau January 30, 2025 09:35
Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

Really nicely done!

I've left quite a few comments but none of them are blocking, I don't think. I do think it'd be nice to get EditableTags working, though I realize that'll probably be a headache to fit in the table. 🙂

adminSiteClient/AdminApp.tsx Outdated Show resolved Hide resolved
adminSiteClient/AdminSidebar.tsx Show resolved Hide resolved
dataIndex: "tags",
key: "tags",
render: (tags: DbPlainTag[]) =>
tags.map((tag) => (
Copy link
Member

Choose a reason for hiding this comment

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

Could we use EditableTags here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that's a good idea! it hadn't crossed my mind

dataInsight: RequiredBy<OwidGdocDataInsightIndexItem, "image">
) {
const { cloudflareId, originalWidth } = dataInsight.image
return `${CLOUDFLARE_IMAGES_URL}/${cloudflareId}/w=${originalWidth}`
Copy link
Member

Choose a reason for hiding this comment

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

May as well make this w=530 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

somehow I thought this has be to be the original width, lol

adminSiteClient/DataInsightIndexPage.tsx Outdated Show resolved Hide resolved
LEFT JOIN chart_configs cc_chartView
ON cc_chartView.id = cw.chartConfigId

-- join the images table by filename (only works for data insights where the image block comes first)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think any author has ever not done this, but this will be the first time we explicitly hinge business logic on this assumption - so maybe we should now add validation to assert this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a good idea! I was debating whether it's okay to make this assumption here. I finally settled on this because writing more code to cover cases outside our guidelines didn't make much sense to me. Good call to make it explicit!

adminSiteServer/apiRoutes/dataInsights.ts Outdated Show resolved Hide resolved
adminSiteServer/apiRoutes/dataInsights.ts Outdated Show resolved Hide resolved
adminSiteClient/DataInsightIndexPage.tsx Outdated Show resolved Hide resolved
@sophiamersmann
Copy link
Member Author

Thanks for the review, @ikesau! Making the tags editable is a very good idea, and I hope dropping the chart type column helps to make it fit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staging-viz Let SVG tester fail silently in CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants