Skip to content

Commit 312adc0

Browse files
authored
chore: remove granularAdminPermissions flag (#9467)
- removed a flag - deprecated `POST /admin/ui-config` endpoint in favor of `POST /admin/ui-config/cors`
1 parent 7dd8903 commit 312adc0

File tree

8 files changed

+4
-57
lines changed

8 files changed

+4
-57
lines changed

frontend/src/component/admin/cors/CorsForm.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,23 @@ import useToast from 'hooks/useToast';
77
import { formatUnknownError } from 'utils/formatUnknownError';
88
import { useId } from 'hooks/useId';
99
import { ADMIN, UPDATE_CORS } from '@server/types/permissions';
10-
import { useUiFlag } from 'hooks/useUiFlag';
1110

1211
interface ICorsFormProps {
1312
frontendApiOrigins: string[] | undefined;
1413
}
1514

1615
export const CorsForm = ({ frontendApiOrigins }: ICorsFormProps) => {
17-
const { setFrontendSettings, setCors } = useUiConfigApi();
16+
const { setCors } = useUiConfigApi();
1817
const { setToastData, setToastApiError } = useToast();
1918
const [value, setValue] = useState(formatInputValue(frontendApiOrigins));
2019
const inputFieldId = useId();
2120
const helpTextId = useId();
22-
const isGranularPermissionsEnabled = useUiFlag('granularAdminPermissions');
2321

2422
const onSubmit = async (event: React.FormEvent) => {
2523
try {
2624
const split = parseInputValue(value);
2725
event.preventDefault();
28-
if (isGranularPermissionsEnabled) {
29-
await setCors(split);
30-
} else {
31-
await setFrontendSettings(split);
32-
}
26+
await setCors(split);
3327
setValue(formatInputValue(split));
3428
setToastData({ text: 'Settings saved', type: 'success' });
3529
} catch (error) {

frontend/src/component/admin/roles/RoleForm/RolePermissionCategories/RolePermissionCategories.tsx

-9
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ export const RolePermissionCategories = ({
4444
});
4545

4646
const releasePlansEnabled = useUiFlag('releasePlans');
47-
const granularAdminPermissionsEnabled = useUiFlag(
48-
'granularAdminPermissions',
49-
);
5047

5148
const isProjectRole = PROJECT_ROLE_TYPES.includes(type);
5249

@@ -90,12 +87,6 @@ export const RolePermissionCategories = ({
9087
releasePlansEnabled ||
9188
label !== 'Release plan templates',
9289
)
93-
.filter(
94-
({ label }) =>
95-
granularAdminPermissionsEnabled ||
96-
(label !== 'Instance maintenance' &&
97-
label !== 'Authentication'),
98-
)
9990
.map(({ label, type, permissions }) => (
10091
<RolePermissionCategoryAccordion
10192
key={label}

frontend/src/hooks/api/actions/useUiConfigApi/useUiConfigApi.ts

-18
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,6 @@ export const useUiConfigApi = () => {
55
propagateErrors: true,
66
});
77

8-
/**
9-
* @deprecated remove when `granularAdminPermissions` flag is removed
10-
*/
11-
const setFrontendSettings = async (
12-
frontendApiOrigins: string[],
13-
): Promise<void> => {
14-
const payload = {
15-
frontendSettings: { frontendApiOrigins },
16-
};
17-
const req = createRequest(
18-
'api/admin/ui-config',
19-
{ method: 'POST', body: JSON.stringify(payload) },
20-
'setFrontendSettings',
21-
);
22-
await makeRequest(req.caller, req.id);
23-
};
24-
258
const setCors = async (frontendApiOrigins: string[]): Promise<void> => {
269
const req = createRequest(
2710
'api/admin/ui-config/cors',
@@ -32,7 +15,6 @@ export const useUiConfigApi = () => {
3215
};
3316

3417
return {
35-
setFrontendSettings,
3618
setCors,
3719
loading,
3820
errors,

frontend/src/interfaces/uiConfig.ts

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export type UiFlags = {
8989
productivityReportEmail?: boolean;
9090
showUserDeviceCount?: boolean;
9191
flagOverviewRedesign?: boolean;
92-
granularAdminPermissions?: boolean;
9392
consumptionModel?: boolean;
9493
edgeObservability?: boolean;
9594
};

src/lib/routes/admin-api/config.test.ts

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ const uiConfig = {
1919
async function getSetup() {
2020
const base = `/random${Math.round(Math.random() * 1000)}`;
2121
const config = createTestConfig({
22-
experimental: {
23-
flags: {
24-
granularAdminPermissions: true,
25-
},
26-
},
2722
server: { baseUriPath: base },
2823
ui: uiConfig,
2924
});

src/lib/routes/admin-api/config.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class ConfigController extends Controller {
100100
],
101101
});
102102

103-
// TODO: deprecate when removing `granularAdminPermissions` flag
104103
this.route({
105104
method: 'post',
106105
path: '',
@@ -111,10 +110,11 @@ class ConfigController extends Controller {
111110
tags: ['Admin UI'],
112111
summary: 'Set UI configuration',
113112
description:
114-
'Sets the UI configuration for this Unleash instance.',
113+
'Deprecated. Use `./cors` instead. Sets the UI configuration for this Unleash instance.',
115114
operationId: 'setUiConfig',
116115
requestBody: createRequestSchema('setUiConfigSchema'),
117116
responses: { 200: emptyResponse },
117+
deprecated: true,
118118
}),
119119
],
120120
});
@@ -222,14 +222,6 @@ class ConfigController extends Controller {
222222
req: IAuthRequest<void, void, SetCorsSchema>,
223223
res: Response<string>,
224224
): Promise<void> {
225-
const granularAdminPermissions = this.flagResolver.isEnabled(
226-
'granularAdminPermissions',
227-
);
228-
229-
if (!granularAdminPermissions) {
230-
throw new NotFoundError();
231-
}
232-
233225
if (req.body.frontendApiOrigins) {
234226
await this.frontendApiService.setFrontendCorsSettings(
235227
req.body.frontendApiOrigins,

src/lib/types/experimental.ts

-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export type IFlagKey =
5757
| 'flagOverviewRedesign'
5858
| 'showUserDeviceCount'
5959
| 'memorizeStats'
60-
| 'granularAdminPermissions'
6160
| 'streaming'
6261
| 'etagVariant'
6362
| 'deltaApi'
@@ -277,10 +276,6 @@ const flags: IFlags = {
277276
process.env.UNLEASH_EXPERIMENTAL_FLAG_OVERVIEW_REDESIGN,
278277
false,
279278
),
280-
granularAdminPermissions: parseEnvVarBoolean(
281-
process.env.UNLEASH_EXPERIMENTAL_GRANULAR_ADMIN_PERMISSIONS,
282-
false,
283-
),
284279
streaming: parseEnvVarBoolean(
285280
process.env.UNLEASH_EXPERIMENTAL_STREAMING,
286281
false,

src/server-dev.ts

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ process.nextTick(async () => {
5353
releasePlanChangeRequests: false,
5454
showUserDeviceCount: true,
5555
flagOverviewRedesign: true,
56-
granularAdminPermissions: true,
5756
deltaApi: true,
5857
uniqueSdkTracking: true,
5958
filterExistingFlagNames: true,

0 commit comments

Comments
 (0)