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

15831 Replaced boolean correction flag with array flag #484

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

severinbeauvais
Copy link
Collaborator

Issue #: bcgov/entity#15831

Description of changes:

  • app version = 4.2.11
  • deleted old boolean FF
  • added new array FF
  • deleted old FF check
  • added new FF check

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the bcrs-entities-create-ui license (Apache 2.0).

- deleted old FF
- added new FF
- deleted old FF check
- added new FF check
'restoration-ui-enabled': false,
'sentry-enable': false, // by default, no sentry logs
'banner-text': '' // by default, there is no banner text
'supported-correction-entities': []
Copy link
Collaborator Author

@severinbeauvais severinbeauvais Apr 19, 2023

Choose a reason for hiding this comment

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

In case LD can't be reached (esp in Prod), this is a safe fallback.

If you forget to add the dev LD key to your .env file, you get this value too 😁 Otherwise, your local and dev will have the same flags.


/** Emits Have Data event. */
@Emit('haveData')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private emitHaveData (haveData = true): void {}
Copy link
Collaborator Author

@severinbeauvais severinbeauvais Apr 19, 2023

Choose a reason for hiding this comment

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

I got rid of these because my TS/Vue extensions gives me errors that the template can't see these methods because they're private or protected (and yet it works). But it doesn't do this with all components and I don't know why...

@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #484 (c9361d3) into main (eaf687f) will increase coverage by 0.02%.
The diff coverage is 88.99%.

@@            Coverage Diff             @@
##             main     #484      +/-   ##
==========================================
+ Coverage   85.70%   85.72%   +0.01%     
==========================================
  Files         177      195      +18     
  Lines        3289     3651     +362     
  Branches      524      445      -79     
==========================================
+ Hits         2819     3130     +311     
- Misses        468      508      +40     
- Partials        2       13      +11     
Impacted Files Coverage Δ
src/components/common/ErrorContact.vue 100.00% <ø> (ø)
...ourCompany/NameTranslations/AddNameTranslation.vue 100.00% <ø> (ø)
...nents/common/YourCompany/NameTranslations/index.ts 100.00% <ø> (ø)
src/dialogs/StaffPaymentErrorDialog.vue 100.00% <ø> (ø)
...-interfaces/PeopleAndRoles/org-person-interface.ts 100.00% <ø> (ø)
...erfaces/state-interfaces/name-request-interface.ts 100.00% <ø> (ø)
src/mixins/common-mixin.ts 69.69% <ø> (-7.05%) ⬇️
src/services/legal-services.ts 93.51% <0.00%> (-6.49%) ⬇️
src/utils/feature-flag-utils.ts 47.05% <ø> (+31.26%) ⬆️
src/views/auth/Signout.vue 100.00% <ø> (ø)
... and 123 more

... and 16 files with indirect coverage changes

Comment on lines +124 to +131
// NB: specific entities are targeted via LaunchDarkly
if (!GetFeatureFlag('supported-correction-entities')?.includes(this.getEntityType)) {
window.alert('Corrections for this entity type are not available at the moment.\n' +
'Please check again later.')
this.$root.$emit('go-to-dashboard', true)
return
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding the LD check to VueRouter as a guard using the route meta data to set the flag like this:

{
    path: '/correction',
    name: RouteNames.CORRECTION,
    component: Correction,
    meta: {
      launchDarklyFlag: 'supported-correction-entities',
      requiresAuth: true,
      isStaffOnly: true,
      filingType: FilingTypes.CORRECTION
    }
  }

This approach would avoid duplicating the launch darkly check in each view and it also simplifies our testing since the view can be tested without having to write workaround for the launch darkly check.

Copy link
Collaborator Author

@severinbeauvais severinbeauvais Apr 20, 2023

Choose a reason for hiding this comment

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

That's a very good idea and I was already thinking how to implement it, but this page/route doesn't know the entity type until it loads the draft filing.

Unless we change that.

Copy link
Collaborator Author

@severinbeauvais severinbeauvais Apr 20, 2023

Choose a reason for hiding this comment

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

If we fetched the business info earlier then we would already know the entity type, but there is no "earlier" since this is the route we start on.

I'll keep thinking about this.

As for testing, it's actually easy to mock the feature flag call. See https://github.com/bcgov/business-filings-ui/blob/85c73c51a7db0eece1d4a2a8f097dca9a5f6fb5c/tests/unit/allowable-actions-mixin.spec.ts#L23

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, without putting logic in App.vue (to load the business info), I don't see how the router can do the FF check in this case. Do you have any ideas?

Copy link
Contributor

@jonathan-longe jonathan-longe Apr 20, 2023

Choose a reason for hiding this comment

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

Ah, good point. If I understand correctly, launch darkly returns an array of entity types when given a launch darkly flag -- right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the FF is an array of allowable entity types (for the given filing, eg, correction).

We could include entity type as an URL parameter. It seems a bit redundant since Edit UI can look it up but I do like the idea of the router being the "gatekeeper".

Note that we have different types of feature flags (eg, boolean, string, array), so the router would need to understand what each flag tests (ie, is specific to flag). What do you think about this?

Copy link
Contributor

@jonathan-longe jonathan-longe Apr 20, 2023

Choose a reason for hiding this comment

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

If you like the idea of router acting as a gatekeeper using FF, I suggest the cleanest way to implement this is to have the FF always return a Boolean. In edit-ui, it looks like all other feature flags (besides the one in this PR) return Booleans. If FF always return Booleans, it's easy to write a router guard that checks the appropriate FF. For corrections, you could use the same pattern by adding the filing type to the flag like this:

  • supported-correction-entities-BEN-enabled
  • supported-correction-entities-SP-enabled
  • supported-correction-entities-GP-enabled

Not sure, the wording above is the best, but I hope it illustrates the point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It illustrates the point, but ouch. We have many filing-array flags, and I think it's desirable to keep the number of flags to a minimum (but let me check with Patrick).

Do you want any changes in this PR?

Copy link
Collaborator Author

@severinbeauvais severinbeauvais Apr 20, 2023

Choose a reason for hiding this comment

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

Patrick says we can add dozens of new FF without impact to our LaunchDarkly plan.

But Thor says the number of flags matters (and it's unclear)... 🤷‍♂️

Future concern - new ticket.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great discussion Sev. I'll create a ticket to refactor the FF to use a VueRouter guard.

@jonathan-longe jonathan-longe self-requested a review April 20, 2023 21:02
@severinbeauvais severinbeauvais merged commit 6fac7f4 into bcgov:main Apr 20, 2023
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.

4 participants