-
Notifications
You must be signed in to change notification settings - Fork 364
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: [M3-8837] - Add LKE-E feature flag #11259
Merged
mjac0bs
merged 7 commits into
linode:develop
from
mjac0bs:M3-8837-add-lke-enterprise-feature-flag
Nov 19, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c0c3eb3
Add lkeEnterprise flag, hook, and account beta query
mjac0bs 981132e
Add WIP tests for hook
mjac0bs 52e15f5
Refactor added tests, trying to address failures
mjac0bs 029a229
Different attempt for debugging purposes; will likely revert this
mjac0bs 1286648
Fix the APL test error and some linter warnings
mjac0bs 347b2bd
Add changesets
mjac0bs 7ea9f24
Address feedback: add MSW preset for LKE-E account capability
mjac0bs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/api-v4/.changeset/pr-11259-upcoming-features-1731690339160.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Upcoming Features | ||
--- | ||
|
||
Add v4beta/account endpoint and update Capabilities for LKE-E ([#11259](https://github.com/linode/manager/pull/11259)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11259-upcoming-features-1731690367042.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add feature flag and hook for LKE-E enablement ([#11259](https://github.com/linode/manager/pull/11259)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/manager/src/mocks/presets/extra/account/lkeEnterpriseEnabled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// New file at `src/mocks/presets/extra/account/lkeEnterpriseEnabled.ts` or similar | ||
|
||
import { http } from 'msw'; | ||
|
||
import { accountFactory } from 'src/factories'; | ||
import { makeResponse } from 'src/mocks/utilities/response'; | ||
|
||
import type { MockPresetExtra } from 'src/mocks/types'; | ||
|
||
const mockLkeEnabledCapability = () => { | ||
return [ | ||
http.get('*/v4*/account', async ({ request }) => { | ||
return makeResponse( | ||
accountFactory.build({ | ||
capabilities: [ | ||
// Other account capabilities might be necessary here, too... | ||
// TODO Make a `defaultAccountCapabilities` factory. | ||
'Kubernetes', | ||
'Kubernetes Enterprise', | ||
], | ||
}) | ||
); | ||
}), | ||
]; | ||
}; | ||
|
||
export const lkeEnterpriseEnabledPreset: MockPresetExtra = { | ||
desc: 'Mock account with LKE Enterprise capability', | ||
group: { id: 'Account', type: 'select' }, | ||
handlers: [mockLkeEnabledCapability], | ||
id: 'account:lke-enterprise-enabled', | ||
label: 'LKE Enterprise Enabled', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
import { useSnackbar } from 'notistack'; | ||
|
||
import { useIsTaxIdEnabled } from 'src/features/Account/utils'; | ||
import { useFlags } from 'src/hooks/useFlags'; | ||
import { useGrants, useProfile } from 'src/queries/profile/profile'; | ||
|
||
import { queryPresets } from '../base'; | ||
|
@@ -36,6 +37,21 @@ export const useAccount = () => { | |
}); | ||
}; | ||
|
||
/** | ||
* @TODO LKE-E - M3-8838: Clean up after released to GA, if not otherwise in use | ||
*/ | ||
export const useAccountBeta = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not to be confused with the |
||
const { data: profile } = useProfile(); | ||
const flags = useFlags(); | ||
|
||
return useQuery<Account, APIError[]>({ | ||
...accountQueries.accountBeta, | ||
...queryPresets.oneTimeFetch, | ||
...queryPresets.noRetry, | ||
enabled: !profile?.restricted && flags.lkeEnterprise?.enabled, | ||
}); | ||
}; | ||
|
||
export const useMutateAccount = () => { | ||
const queryClient = useQueryClient(); | ||
const { enqueueSnackbar } = useSnackbar(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to modify this test with the addition of the
useIsLkeEnterpriseEnabled
tests, due to the use of feature flags in both.In the words of the wise @jdamore-linode, the APL test needed to be modified because:
(And so the APL test would fail.)
In the interest of using one mocking solution in this file (not both
server.use
andvi.mock
), I switched this one over to using the queryMocks, as well.