Skip to content

Add music lab to featured projects#58973

Merged
fisher-alice merged 18 commits into
stagingfrom
alice/music-featured
Jun 4, 2024
Merged

Add music lab to featured projects#58973
fisher-alice merged 18 commits into
stagingfrom
alice/music-featured

Conversation

@fisher-alice

@fisher-alice fisher-alice commented May 29, 2024

Copy link
Copy Markdown
Contributor

This PR allows music lab projects to be added to the featured project gallery. Because thumbnail images are not generated for music lab projects, a customized thumbnail image is used for the featured projects public gallery and the admin featured projects page. However, the music lab image for the public gallery (via the project card) is slightly different in that more space is allowed for the music note.

An aside - at first, I also removed studio type labs from featured project types because it is no longer possible to convert a studio free-play level to a standalone project. But it is still possible to create a studio standalone project 'from scratch' so reverted the removal.

Note that a project still needs to be in a 'published' state in order for it to be displayed in the public featured gallery. Follow-up work includes providing a way for an admin user to publish a project since currently an engineer is needed to publish a project.

This is part 1 for the task: Music: Ability to select featured projects to show on the home page (code.org/music). Part 2 is to retrieve the channel ids of the active music lab featured projects to use for the mini-player at code.org/music.

After update

Screenshot of public featured project gallery:
Screenshot 2024-05-31 at 12 27 51 PM

Screenshot of music lab projects after being added as featured projects at /projects/featured.
music-thumbnails-featured-admin

Links

Slack thread

Testing story

I tested locally by creating two different music lab project, published them, then made them active featured projects using dashboard-console commands.

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@fisher-alice fisher-alice changed the title Add music lab to featured projects Add music lab to featured projects - part 1 May 30, 2024
@fisher-alice fisher-alice changed the title Add music lab to featured projects - part 1 Add music lab to featured projects May 30, 2024
@fisher-alice fisher-alice marked this pull request as ready for review May 30, 2024 23:45
@fisher-alice fisher-alice requested a review from a team May 30, 2024 23:46
Comment thread apps/src/templates/projects/FeaturedProjectsTable.jsx Outdated

@thomasoniii thomasoniii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion about adding an abstraction to getting the thumbnail url, but otherwise lgtm 🚀


export const getThumbnailUrl = (
path: string,
type: keyof typeof PROJECT_DEFAULT_THUMBNAIL_IMAGE_OVERRIDE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Trying to understand TS...isn't type often going to be something other than music (which I think is the only valid value given the contents of the constant)? I guess it compiles but TS confuses me sometimes...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question - I tried string at first and TS didn't like it. I'll ping Sanchit when he's back in office next week to get his thoughts. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tagging @sanchitmalhotra126 now that he's back in office.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm yeah, I think because PROJECT_DEFAULT_THUMBNAIL_IMAGE_OVERRIDE is defined in a JS file, TS is reading its type to be strictly {[key: 'music']: string} rather than a generic {[key: string]: string} and therefore complains when you try to use a string to index into it.

One solution would be to define this constant in TS where you can explicitly type it as a {[key: string]: string} and then you can have the type param be a string. Otherwise it might just be best to cast the param inside the function - have the type param be string and cast it to keyof typeof PROJECT_DEFAULT_THUMBNAIL_IMAGE_OVERRIDE internally.

Using keyof typeof for the type param does technically compile but only because all the references to this function are in JS. If/when a TS file tries to use this function, it will fail to compile unless the provided type is always 'music'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks Sanchit! I converted projectConstants to a .ts file. Lmk what you think.

<ProjectAppTypeArea
labKey="featured"
labName={i18n.featuredProjects()}
labViewMoreString={i18n.projectTypeDanceViewMore()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this change do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The public gallery update included not showing the 'View more of ...' button. So this value is not being used since hideViewMoreLink has the value of true. I left a comment here.

navigateFunction={this.onSelectApp}
isDetailView={false}
hideViewMoreLink={true}
hideWithoutThumbnails={true}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this change have any potential impact on other lab types?

@fisher-alice fisher-alice May 31, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the public gallery only displays curated featured projects, admin will select projects for which thumbnail images are available. At '/projects/featured' (the admin featured projects page), the thumbnail images are displayed alongside a link to the project.

I believe in the past, since any project could be published, this was a way to filter projects without thumbnail images from being included in the public gallery (projects without any content).
As new labs are added, either they'll have a way to generate a corresponding thumbnail OR we'll need to provide a thumbnail image as we are doing for music lab. To my knowledge, legacy labs that are publishable generate thumbnail images.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks!

Comment on lines +82 to +83
// Project data from the channels API.
type project = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, we have a version of this interface in lab2 types (where it's called Channel) and I'm wondering if we want to reuse/consolidate...ideally it would be great to have a single source of truth for these types (so there's a consistent understanding of what a "project" is across the codebase) but probably out of scope of this PR to do that kind of refactor. Maybe ok to keep here for now but add a comment that this type is duplicated in lab2/types? cc @molly-moen

also nit: capitalize Projects

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good to know about Channel interface - thanks Sanchit! I updated the interface adding two optional properties needed for convertChanneslToProjectData. @molly-moen lmk if this looks okay to you. If not, I can revert this commit. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The other option that @sanchitmalhotra126 and I discussed was converting the new projectUtils.ts file to a .js file. 🤷‍♀️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine to add those fields there, they already exist on the channel itself, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, they do. Thanks!

Comment thread apps/src/templates/projects/projectUtils.ts Outdated
@fisher-alice fisher-alice merged commit c3d7773 into staging Jun 4, 2024
@fisher-alice fisher-alice deleted the alice/music-featured branch June 4, 2024 22:52
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.

5 participants