Skip to content

Commit c05416a

Browse files
authored
feat: Migrate isEnterprisePlan to GQL Field (#3576)
1 parent ad05f89 commit c05416a

File tree

53 files changed

+237
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+237
-228
lines changed

src/pages/AccountSettings/AccountSettings.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { SentryRoute } from 'sentry'
88
import SidebarLayout from 'layouts/SidebarLayout'
99
import { usePlanData } from 'services/account'
1010
import { useIsCurrentUserAnAdmin, useUser } from 'services/user'
11-
import { isEnterprisePlan } from 'shared/utils/billing'
1211
import LoadingLogo from 'ui/LoadingLogo'
1312

1413
import AccountSettingsSideMenu from './AccountSettingsSideMenu'
@@ -34,7 +33,7 @@ function AccountSettings() {
3433
const { data: currentUser } = useUser()
3534

3635
const { data } = usePlanData({ provider, owner })
37-
const viewOktaAccess = isEnterprisePlan(data?.plan?.value)
36+
const viewOktaAccess = data?.plan?.isEnterprisePlan
3837

3938
const isViewingPersonalSettings =
4039
currentUser?.user?.username?.toLowerCase() === owner?.toLowerCase()

src/pages/AccountSettings/AccountSettings.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ describe('AccountSettings', () => {
161161
plan: {
162162
...mockPlanData,
163163
value: planValue,
164+
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
164165
},
165166
},
166167
},

src/pages/AccountSettings/AccountSettingsSideMenu.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import config from 'config'
44

55
import { usePlanData } from 'services/account'
66
import { useIsCurrentUserAnAdmin, useUser } from 'services/user'
7-
import { isEnterprisePlan } from 'shared/utils/billing'
87
import Sidemenu from 'ui/Sidemenu'
98

109
function defaultLinks({ internalAccessTab, viewOktaAccess }) {
@@ -66,7 +65,7 @@ function AccountSettingsSideMenu() {
6665
currentUser?.user?.username?.toLowerCase() === owner?.toLowerCase()
6766

6867
const { data } = usePlanData({ provider, owner })
69-
const viewOktaAccess = isEnterprisePlan(data?.plan?.value)
68+
const viewOktaAccess = data?.plan?.isEnterprisePlan
7069

7170
const links = generateLinks({
7271
isAdmin,

src/pages/AccountSettings/AccountSettingsSideMenu.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ describe('AccountSettingsSideMenu', () => {
149149
plan: {
150150
...mockPlanData,
151151
value: planValue,
152+
isEnterprisePlan: planValue === Plans.USERS_ENTERPRISEM,
152153
},
153154
},
154155
},

src/pages/DefaultOrgSelector/DefaultOrgSelector.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ describe('DefaultOrgSelector', () => {
212212
hasPrivateRepos: privateRepos,
213213
plan: {
214214
...mockTrialData,
215+
isEnterprisePlan: false,
215216
trialStatus,
216217
value,
217218
},

src/pages/MembersPage/MembersActivation/Activation/Activation.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ function Activation() {
7474
activated members of{' '}
7575
<span className="text-lg font-semibold">{planQuantity}</span> available
7676
seats{' '}
77-
{accountDetails && <ChangePlanLink accountDetails={accountDetails} />}
77+
{accountDetails && (
78+
<ChangePlanLink
79+
accountDetails={accountDetails}
80+
plan={planData?.plan}
81+
/>
82+
)}
7883
</p>
7984
{/* TODO: new feature https://www.figma.com/file/iNTJAiBYGem3A4LmI4gvKX/Plan-and-members?node-id=103%3A1696 */}
8085
</div>

src/pages/MembersPage/MembersActivation/Activation/Activation.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const mockedAccountDetails = {
2626
}
2727

2828
const mockPlanData = {
29+
isEnterprisePlan: false,
2930
baseUnitPrice: 10,
3031
benefits: [],
3132
billingRate: 'monthly',

src/pages/MembersPage/MembersActivation/Activation/ChangePlanLink/ChangePlanLink.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import PropType from 'prop-types'
22

33
import config from 'config'
44

5-
import { CollectionMethods, isEnterprisePlan } from 'shared/utils/billing'
5+
import { CollectionMethods } from 'shared/utils/billing'
66
import A from 'ui/A'
77

8-
function ChangePlanLink({ accountDetails }) {
8+
function ChangePlanLink({ accountDetails, plan }) {
99
const isInvoicedCustomer =
1010
accountDetails?.subscriptionDetail?.collectionMethod ===
1111
CollectionMethods.INVOICED_CUSTOMER_METHOD
12-
const plan = accountDetails?.plan?.value
1312

14-
if (config.IS_SELF_HOSTED || isInvoicedCustomer || isEnterprisePlan(plan)) {
13+
if (config.IS_SELF_HOSTED || isInvoicedCustomer || plan?.isEnterprisePlan) {
1514
return null
1615
}
1716

@@ -27,8 +26,8 @@ function ChangePlanLink({ accountDetails }) {
2726
ChangePlanLink.propTypes = {
2827
accountDetails: PropType.shape({
2928
subscriptionDetail: PropType.shape({ collectionMethod: PropType.string }),
30-
plan: PropType.shape({ value: PropType.string }),
3129
}).isRequired,
30+
plan: PropType.object,
3231
}
3332

3433
export default ChangePlanLink

src/pages/MembersPage/MembersActivation/MembersActivation.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const mockPlanData = {
4040
pretrialUsersCount: 0,
4141
planUserCount: 1,
4242
hasSeatsLeft: true,
43+
isEnterprisePlan: false,
4344
}
4445

4546
const server = setupServer()

src/pages/OwnerPage/HeaderBanners/ExceededUploadsAlert/ExceededUploadsAlert.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const mockPlanDataResponse = {
3737
pretrialUsersCount: 0,
3838
planUserCount: 1,
3939
hasSeatsLeft: true,
40+
isEnterprisePlan: false,
4041
}
4142

4243
beforeAll(() => {

0 commit comments

Comments
 (0)