Skip to content

Commit 59eafe1

Browse files
narsaynorathpriscilawebdev
authored andcommitted
feat(dashboard-limits): Add basic and edit flags into planFeature (#97773)
This forces the dashboards-edit and dashboards-basic feature flags to be associated to business and team plans even if they aren't returned by getsentry. This allows us to continue to indicate to the user what the next lowest plan the user needs to upgrade to for the feature. This is so we can migrate off of getsentry and move the flags into Flagpole to more easily switch the flags on when releasing logs. Builds off of #97148 which accomplishes the same thing but for `global-views` on different plans.
1 parent f2fee3e commit 59eafe1

File tree

6 files changed

+59
-7
lines changed

6 files changed

+59
-7
lines changed

static/gsApp/components/features/planFeature.spec.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,52 @@ describe('PlanFeature', () => {
210210
});
211211
});
212212
});
213+
214+
it('returns dashboards-basic in team plan even if response does not include it', async function () {
215+
const mockFn = jest.fn(() => null);
216+
217+
const sub = SubscriptionFixture({
218+
organization,
219+
planTier: PlanTier.MM2,
220+
plan: 'mm2_f',
221+
});
222+
SubscriptionStore.set(organization.slug, sub);
223+
224+
render(
225+
<PlanFeature organization={organization} features={['dashboards-basic']}>
226+
{mockFn}
227+
</PlanFeature>
228+
);
229+
230+
await waitFor(() => {
231+
expect(mockFn).toHaveBeenCalledWith({
232+
plan: PlanDetailsLookupFixture('am2_team'),
233+
tierChange: 'am2',
234+
});
235+
});
236+
});
237+
238+
it('returns dashboards-edit in business plan even if response does not include it', async function () {
239+
const mockFn = jest.fn(() => null);
240+
241+
const sub = SubscriptionFixture({
242+
organization,
243+
planTier: PlanTier.MM2,
244+
plan: 'mm2_f',
245+
});
246+
SubscriptionStore.set(organization.slug, sub);
247+
248+
render(
249+
<PlanFeature organization={organization} features={['dashboards-edit']}>
250+
{mockFn}
251+
</PlanFeature>
252+
);
253+
254+
await waitFor(() => {
255+
expect(mockFn).toHaveBeenCalledWith({
256+
plan: PlanDetailsLookupFixture('am2_business'),
257+
tierChange: 'am2',
258+
});
259+
});
260+
});
213261
});

static/gsApp/components/features/planFeature.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
isAmEnterprisePlan,
1111
isBizPlanFamily,
1212
isDeveloperPlan,
13+
isTeamPlanFamily,
1314
} from 'getsentry/utils/billing';
1415

1516
type RenderProps = {
@@ -119,6 +120,16 @@ function PlanFeature({subscription, features, organization, children}: Props) {
119120
plan.features.push('global-views');
120121
}
121122
}
123+
if (isBizPlanFamily(plan)) {
124+
if (!plan.features.includes('dashboards-edit')) {
125+
plan.features.push('dashboards-edit');
126+
}
127+
}
128+
if (isTeamPlanFamily(plan) || isBizPlanFamily(plan)) {
129+
if (!plan.features.includes('dashboards-basic')) {
130+
plan.features.push('dashboards-basic');
131+
}
132+
}
122133
}
123134

124135
// Locate the first plan that offers these features

tests/js/getsentry-test/fixtures/am1Plans.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const AM1_TEAM_FEATURES = [
5757
...AM1_FREE_FEATURES,
5858
'codecov-integration',
5959
'crash-rate-alerts',
60-
'dashboards-basic',
6160
'discover-basic',
6261
'incidents',
6362
'integrations-issue-basic',
@@ -79,7 +78,6 @@ const AM1_BUSINESS_FEATURES = [
7978
'change-alerts',
8079
'custom-inbound-filters',
8180
'custom-symbol-sources',
82-
'dashboards-edit',
8381
'data-forwarding',
8482
'discard-groups',
8583
'discover-query',

tests/js/getsentry-test/fixtures/am2Plans.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const AM2_TEAM_FEATURES = [
6868
...AM2_FREE_FEATURES,
6969
'codecov-integration',
7070
'crash-rate-alerts',
71-
'dashboards-basic',
7271
'discover-basic',
7372
'incidents',
7473
'integrations-issue-basic',
@@ -90,7 +89,6 @@ const AM2_BUSINESS_FEATURES = [
9089
'change-alerts',
9190
'custom-inbound-filters',
9291
'custom-symbol-sources',
93-
'dashboards-edit',
9492
'data-forwarding',
9593
'discard-groups',
9694
'discover-query',

tests/js/getsentry-test/fixtures/am3Plans.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ const AM3_TEAM_FEATURES = [
9090
...AM3_FREE_FEATURES,
9191
'codecov-integration',
9292
'crash-rate-alerts',
93-
'dashboards-basic',
9493
'discover-basic',
9594
'incidents',
9695
'integrations-issue-basic',
@@ -111,7 +110,6 @@ const AM3_BUSINESS_FEATURES = [
111110
'change-alerts',
112111
'custom-inbound-filters',
113112
'custom-symbol-sources',
114-
'dashboards-edit',
115113
'data-forwarding',
116114
'discard-groups',
117115
'discover-query',

tests/js/getsentry-test/fixtures/mm2Plans.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ const MM2_PLANS: Record<string, Plan> = {
690690
'custom-symbol-sources',
691691
'data-forwarding',
692692
'discard-groups',
693-
'dashboards-basic',
694693
'discover-query',
695694
'integrations-codeowners',
696695
'integrations-event-hooks',

0 commit comments

Comments
 (0)