Skip to content

Commit ba8f32d

Browse files
authored
feat: replace isRegionBeta with isUpgradeable from identity (#5808)
1 parent bf505e4 commit ba8f32d

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/identity/reducers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const initialState: CurrentIdentity = {
3434
type: 'free',
3535
accountCreatedAt: '',
3636
paygCreditStartDate: '',
37+
isUpgradeable: false,
3738
},
3839
status: RemoteDataState.NotStarted,
3940
}
@@ -47,6 +48,7 @@ export default (state = initialState, action: Actions): CurrentIdentity =>
4748
// Store account information from /identity in state.
4849
draftState.account.accountCreatedAt = account.accountCreatedAt
4950
draftState.account.id = account.id
51+
draftState.account.isUpgradeable = account.isUpgradeable
5052
draftState.account.name = account.name
5153
draftState.account.paygCreditStartDate = account.paygCreditStartDate
5254
draftState.account.type = account.type

src/identity/utils/convertIdentityToMe.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ export const convertIdentityToMe = (
2020
accountType: account.type,
2121
paygCreditStartDate: account.paygCreditStartDate,
2222
billingProvider: account.billingProvider ? account.billingProvider : null,
23+
// isRegionBeta in quartz/me has the opposite value of isUpgradeable.
24+
isRegionBeta: account.isUpgradeable
25+
? !Boolean(account.isUpgradeable)
26+
: true,
2327

2428
// Organization Data
2529
clusterHost: org.clusterHost,
2630
regionCode: org.regionCode ? org.regionCode : null,
27-
isRegionBeta: org.isRegionBeta ? org.isRegionBeta : null,
2831
regionName: org.regionName ? org.regionName : null,
2932
}
3033
}

src/shared/containers/GetOrganizations.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {CLOUD} from 'src/shared/constants'
3232
// Utils
3333
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
3434
import {convertStringToEpoch} from 'src/shared/utils/dateTimeUtils'
35-
import {shouldUseQuartzIdentity} from 'src/identity/utils/shouldUseQuartzIdentity'
3635
import {updateReportingContext} from 'src/cloud/utils/reporting'
3736

3837
// Types
@@ -41,13 +40,10 @@ import {PROJECT_NAME} from 'src/flows'
4140
import {RemoteDataState} from 'src/types'
4241

4342
// Thunks
44-
import {
45-
getCurrentOrgDetailsThunk,
46-
getQuartzIdentityThunk,
47-
} from 'src/identity/actions/thunks'
43+
import {getQuartzIdentityThunk} from 'src/identity/actions/thunks'
4844

4945
const canAccessCheckout = (me: Me): boolean => {
50-
if (!!me?.isRegionBeta) {
46+
if (Boolean(me?.isRegionBeta)) {
5147
return false
5248
}
5349
return me?.accountType !== 'pay_as_you_go' && me?.accountType !== 'contract'
@@ -64,14 +60,6 @@ const GetOrganizations: FunctionComponent = () => {
6460

6561
const dispatch = useDispatch()
6662

67-
const identityOrgId = identity.currentIdentity.org.id
68-
69-
useEffect(() => {
70-
if (identityOrgId && shouldUseQuartzIdentity() && !quartzMe?.isRegionBeta) {
71-
dispatch(getCurrentOrgDetailsThunk(identityOrgId))
72-
}
73-
}, [identityOrgId]) // eslint-disable-line react-hooks/exhaustive-deps
74-
7563
// This doesn't require another API call.
7664
useEffect(() => {
7765
if (status === RemoteDataState.NotStarted) {

0 commit comments

Comments
 (0)