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: Infer artist series when creating alert form artwork screen #9631

Conversation

olerichter00
Copy link
Contributor

@olerichter00 olerichter00 commented Dec 6, 2023

This PR resolves ONYX-566

Description

This change adds artist series as an initial criterion when creating the alert from the artwork screen.

Simulator Screenshot - iPhone 15 Plus - 2023-12-08 at 12 37 19 Simulator Screenshot - iPhone 15 Plus - 2023-12-08 at 12 36 59

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

  • Infer artist series when creating alert form artwork screen - ole

iOS user-facing changes

Android user-facing changes

Dev changes

Need help with something? Have a look at our docs, or get in touch with us.

@olerichter00 olerichter00 self-assigned this Dec 6, 2023
@olerichter00 olerichter00 marked this pull request as draft December 6, 2023 15:21
@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Dec 6, 2023

This PR contains the following changes:

  • Cross-platform user-facing changes (Infer artist series when creating alert form artwork screen - ole)

Generated by 🚫 dangerJS against 4dd602e

@@ -30,6 +31,13 @@ export const CreateArtworkAlertModal: React.FC<CreateArtworkAlertModalProps> = (
const data = useFragment<CreateArtworkAlertModalProps["artwork"]>(
graphql`
fragment CreateArtworkAlertModal_artwork on Artwork {
artistSeriesConnection(first: 5) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using 5 as the maximum number of artist series used when creating an alert would cover 99.98% of the cases.(context: artsy/force#13244 (comment))

Comment on lines +71 to +74
if (!artworkAlert) {
return null
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring this component to be able to remove the forbidden non-null assertions.

export const extractPillFromArtistSeriesIDs = (values: string[]): SavedSearchPill[] => {
return values.map((value) => {
return {
label: toTitleCase(value.replaceAll("-", " ")),
Copy link
Contributor Author

@olerichter00 olerichter00 Dec 8, 2023

Choose a reason for hiding this comment

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

This isn't ideal, but it should be good enough for now. We have already moved the pill/label generation to Metaphysics and will remove this code soon in favor of using the backend-generated labels.

Because of this, I have decided not to write any additional code to make the name of the artist series accessible here and use this quick workaround until removing this code.

Screenshot 2023-12-08 at 12 30 02

Copy link
Member

Choose a reason for hiding this comment

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

Agree with this, let's push to work on the migration asap.
A small adjustment I would suggest here is to rename values to slugs and also value to slug. It would be nice to rename the method as well since you are querying for slugs instead of ids but I will leave that to you to decide since we do the same thing in other areas

Copy link
Member

Choose a reason for hiding this comment

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

also, do you mind if you add a test for this as we do for other existing extractors

@olerichter00 olerichter00 force-pushed the olerichter00/ONYX-566/infer-artist-series-when-creating-alert-form-artwork-screen branch from dcc3003 to 4dd602e Compare December 8, 2023 11:36
@olerichter00 olerichter00 marked this pull request as ready for review December 8, 2023 11:38
artwork: CreateArtworkAlertModal_artwork$data | BrowseSimilarWorks_artwork$data
) => {
const enableArtistSeriesFilter = useFeatureFlag("AREnableArtistSeriesFilter")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still an open discussion whether to use a second feature flag here (Slack Thread)

Copy link
Member

@MounirDhahri MounirDhahri left a comment

Choose a reason for hiding this comment

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

LGTM! small comments none are blocking

@@ -11,6 +12,10 @@ jest.mock("app/Components/Artist/ArtistArtworks/CreateSavedSearchModal", () => (
CreateSavedSearchModal: () => "CreateSavedSearchModal",
}))

jest.mock("app/utils/hooks/useFeatureFlag", () => ({
useFeatureFlag: () => true,
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I would avoid this in favour of using our own __globalStoreTestUtils__?.injectFeatureFlags helper.

export const extractPillFromArtistSeriesIDs = (values: string[]): SavedSearchPill[] => {
return values.map((value) => {
return {
label: toTitleCase(value.replaceAll("-", " ")),
Copy link
Member

Choose a reason for hiding this comment

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

Agree with this, let's push to work on the migration asap.
A small adjustment I would suggest here is to rename values to slugs and also value to slug. It would be nice to rename the method as well since you are querying for slugs instead of ids but I will leave that to you to decide since we do the same thing in other areas

export const extractPillFromArtistSeriesIDs = (values: string[]): SavedSearchPill[] => {
return values.map((value) => {
return {
label: toTitleCase(value.replaceAll("-", " ")),
Copy link
Member

Choose a reason for hiding this comment

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

also, do you mind if you add a test for this as we do for other existing extractors

@olerichter00
Copy link
Contributor Author

Closing this PR because we only want to suggest artist series (Slack Thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants