Skip to content

Commit

Permalink
change: [M3-8928] - Switch from v4beta to v4 account endpoint for L…
Browse files Browse the repository at this point in the history
…KE-E (#11413)

* Clean up account beta endpoint and query

* Fix test to mock no LKE-E capability when expected

* Add changesets
  • Loading branch information
mjac0bs authored Dec 12, 2024
1 parent 15992df commit 4f19394
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 45 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11413-removed-1734030444142.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Removed
---

getAccountInfoBeta endpoint ([#11413](https://github.com/linode/manager/pull/11413))
12 changes: 0 additions & 12 deletions packages/api-v4/src/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ export const getAccountInfo = () => {
return Request<Account>(setURL(`${API_ROOT}/account`), setMethod('GET'));
};

/**
* getAccountInfoBeta
*
* Return beta endpoint account information,
* including contact and billing info.
*
* @TODO LKE-E - M3-8838: Clean up after released to GA, if not otherwise in use
*/
export const getAccountInfoBeta = () => {
return Request<Account>(setURL(`${BETA_API_ROOT}/account`), setMethod('GET'));
};

/**
* getNetworkUtilization
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Switch from v4beta to v4 account endpoint for LKE-E ([#11413](https://github.com/linode/manager/pull/11413))
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,13 @@ describe('LKE Cluster Creation with LKE-E', () => {
});

it('disables the Cluster Type selection without the LKE-E account capability', () => {
mockGetAccount(
accountFactory.build({
capabilities: [],
})
).as('getAccount');
cy.visitWithLogin('/kubernetes/clusters');
cy.wait(['@getAccount']);

ui.button
.findByTitle('Create Cluster')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';

import { DocsLink } from 'src/components/DocsLink/DocsLink';
import { SelectionCard } from 'src/components/SelectionCard/SelectionCard';
import { useAccountBeta } from 'src/queries/account/account';
import { useAccount } from 'src/queries/account/account';

import { StyledDocsLinkContainer } from './CreateCluster.styles';

Expand All @@ -19,7 +19,7 @@ interface Props {
export const ClusterTypePanel = (props: Props) => {
const { handleClusterTypeSelection, selectedTier } = props;

const { data: account } = useAccountBeta();
const { data: account } = useAccount();

const mdDownBreakpoint = useMediaQuery((theme: Theme) =>
theme.breakpoints.down('md')
Expand Down
10 changes: 5 additions & 5 deletions packages/manager/src/features/Kubernetes/kubeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './kubeUtils';

const queryMocks = vi.hoisted(() => ({
useAccountBeta: vi.fn().mockReturnValue({}),
useAccount: vi.fn().mockReturnValue({}),
useAccountBetaQuery: vi.fn().mockReturnValue({}),
useFlags: vi.fn().mockReturnValue({}),
}));
Expand All @@ -25,7 +25,7 @@ vi.mock('src/queries/account/account', () => {
const actual = vi.importActual('src/queries/account/account');
return {
...actual,
useAccountBeta: queryMocks.useAccountBeta,
useAccount: queryMocks.useAccount,
};
});

Expand Down Expand Up @@ -165,7 +165,7 @@ describe('helper functions', () => {

describe('useIsLkeEnterpriseEnabled', () => {
it('returns false for feature enablement if the account does not have the capability', () => {
queryMocks.useAccountBeta.mockReturnValue({
queryMocks.useAccount.mockReturnValue({
data: {
capabilities: [],
},
Expand All @@ -188,7 +188,7 @@ describe('useIsLkeEnterpriseEnabled', () => {
});

it('returns true for LA feature enablement if the account has the capability + enabled LA feature flag values', () => {
queryMocks.useAccountBeta.mockReturnValue({
queryMocks.useAccount.mockReturnValue({
data: {
capabilities: ['Kubernetes Enterprise'],
},
Expand All @@ -211,7 +211,7 @@ describe('useIsLkeEnterpriseEnabled', () => {
});

it('returns true for GA feature enablement if the account has the capability + enabled GA feature flag values', () => {
queryMocks.useAccountBeta.mockReturnValue({
queryMocks.useAccount.mockReturnValue({
data: {
capabilities: ['Kubernetes Enterprise'],
},
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/features/Kubernetes/kubeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useFlags } from 'src/hooks/useFlags';
import { useAccountBeta } from 'src/queries/account/account';
import { useAccount } from 'src/queries/account/account';
import { useAccountBetaQuery } from 'src/queries/account/betas';
import { isFeatureEnabledV2 } from 'src/utilities/accountCapabilities';
import { getBetaStatus } from 'src/utilities/betaUtils';
Expand Down Expand Up @@ -195,7 +195,7 @@ export const getLatestVersion = (
*/
export const useIsLkeEnterpriseEnabled = () => {
const flags = useFlags();
const { data: account } = useAccountBeta();
const { data: account } = useAccount();

const isLkeEnterpriseLAFlagEnabled = Boolean(
flags?.lkeEnterprise?.enabled && flags.lkeEnterprise.la
Expand Down
16 changes: 0 additions & 16 deletions packages/manager/src/queries/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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';
Expand All @@ -37,21 +36,6 @@ export const useAccount = () => {
});
};

/**
* @TODO LKE-E - M3-8838: Clean up after released to GA, if not otherwise in use
*/
export const useAccountBeta = () => {
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();
Expand Down
8 changes: 0 additions & 8 deletions packages/manager/src/queries/account/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
getAccountBeta,
getAccountBetas,
getAccountInfo,
getAccountInfoBeta,
getAccountLogins,
getAccountMaintenance,
getAccountSettings,
Expand Down Expand Up @@ -33,13 +32,6 @@ export const accountQueries = createQueryKeys('account', {
queryFn: getAccountInfo,
queryKey: null,
},
/**
* @TODO LKE-E - M3-8838: Clean up after released to GA, if not otherwise in use
*/
accountBeta: {
queryFn: getAccountInfoBeta,
queryKey: null,
},
agreements: {
queryFn: getAccountAgreements,
queryKey: null,
Expand Down

0 comments on commit 4f19394

Please sign in to comment.