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: Announcement feature flag per page #4218

Merged
merged 7 commits into from
Jun 28, 2024

Conversation

novakzaballa
Copy link
Contributor

@novakzaballa novakzaballa commented Jun 24, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  • Now the UI can read a list of pages from the announcement_per_page feature flag and display the announcement only on those pages, this is the pages name list:

    login
    not-found
    signup
    home
    github-setup
    maintenance
    password-reset
    features
    change-requests
    scheduled-changes
    change-request
    scheduled-change
    widget
    invite
    invite-link
    broken
    oauth
    saml
    environment-settings
    sdk-keys
    integrations
    users
    user-id
    user
    create-environment
    project-settings-in-environment
    compare
    feature-history
    feature-history-detail
    project-settings
    permissions
    segments
    organisation-settings
    organisation-permissions
    organisation-usage
    organisation-settings-redirect
    organisation-projects
    account-settings
    audit-log
    organisations
    audit-log-item
    create-organisation
    project-redirect
    account

How did you test this code?

  • Update the announcement_per_page FF with a new key named "pages", and add it the page names for example: ["segments", "users"]

@novakzaballa novakzaballa requested a review from a team as a code owner June 24, 2024 16:24
@novakzaballa novakzaballa requested review from kyle-ssg and removed request for a team June 24, 2024 16:24
Copy link

vercel bot commented Jun 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2024 4:10pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2024 4:10pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jun 27, 2024 4:10pm

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard feature New feature or request labels Jun 24, 2024
Copy link
Contributor

github-actions bot commented Jun 24, 2024

Uffizzi Preview deployment-53413 was deleted.

@matthewelwell
Copy link
Contributor

@novakzaballa I think we discussed creating a different component for this. What made you change your mind? If we stick with the announcement feature, I think we want to consider a couple of extra things:

  1. Should we allow the value to be a list as well as an object, and handle the typing in the code? This would be a bit ugly, but it would allow us flexibility in the future while maintaining backwards compatibility.
  2. Should we add another new attribute which is e.g. "allow_dismiss" that we can set to false for announcements that we want to ensure are permanent?

@@ -350,12 +351,27 @@ const App = class extends Component {
return <div>{this.props.children}</div>
}
const announcementValue = Utils.getFlagsmithJSONValue('announcement', null)
const announcementPerPageDismissed = flagsmith.getTrait(
Copy link
Member

Choose a reason for hiding this comment

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

No need to pollute app with this logic, can go in the component

Copy link
Member

Choose a reason for hiding this comment

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

Also on this, does a page-specific announcement take priority over the announcement banner? It makes sense to combine all of this into 1 component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to keep them separated so we can show both at the same time, a general announcement and a page-specific announcement. Of course, I'll resume as much logic as possible, however, these components are very simple, anyway.

@@ -409,6 +425,12 @@ const App = class extends Component {
</div>
</div>
)}
{user && showAnnouncementPerPage && announcementInPage && (
<AnnouncementPerPage
Copy link
Member

Choose a reason for hiding this comment

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

Might make more sense to just call this <Announcement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned before I prefer to have 2 different components.

const dismissed = flagsmith.getTrait('dismissed_announcement')
const showBanner =
announcementValue &&
(!dismissed || dismissed !== announcementValue.id) &&
Utils.getFlagsmithHasFeature('announcement') &&
this.state.showAnnouncement
const announcementInPage = announcementPerPageValue?.pages?.some((page) =>
Copy link
Member

@kyle-ssg kyle-ssg Jun 25, 2024

Choose a reason for hiding this comment

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

Hmm, would this work for urls with ids or does this need to match in a more detailed way?

If it's the latter, note examples like this

 matchPath(pathname, {
      exact: false,
      path: '/project/:projectId',
      strict: false,
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand this should target a specific page and not particular entities.
Maybe in the future if we need it at some point.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm I don't understand how this will work, how would this target a page in remote config?

Nearly every page has ids in the pathname e.g.
'/project/x/environment/y/features'

@github-actions github-actions bot removed the feature New feature or request label Jun 26, 2024
@kyle-ssg kyle-ssg added this pull request to the merge queue Jun 28, 2024
Merged via the queue into main with commit 3bfad05 Jun 28, 2024
24 checks passed
@kyle-ssg kyle-ssg deleted the feat/announcement-feature-flag-per-page branch June 28, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants