mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
chore: remove granularAdminPermissions flag (#9467)
- removed a flag - deprecated `POST /admin/ui-config` endpoint in favor of `POST /admin/ui-config/cors`
This commit is contained in:
parent
7dd89034aa
commit
312adc0c1a
@ -7,29 +7,23 @@ import useToast from 'hooks/useToast';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import { useId } from 'hooks/useId';
|
||||
import { ADMIN, UPDATE_CORS } from '@server/types/permissions';
|
||||
import { useUiFlag } from 'hooks/useUiFlag';
|
||||
|
||||
interface ICorsFormProps {
|
||||
frontendApiOrigins: string[] | undefined;
|
||||
}
|
||||
|
||||
export const CorsForm = ({ frontendApiOrigins }: ICorsFormProps) => {
|
||||
const { setFrontendSettings, setCors } = useUiConfigApi();
|
||||
const { setCors } = useUiConfigApi();
|
||||
const { setToastData, setToastApiError } = useToast();
|
||||
const [value, setValue] = useState(formatInputValue(frontendApiOrigins));
|
||||
const inputFieldId = useId();
|
||||
const helpTextId = useId();
|
||||
const isGranularPermissionsEnabled = useUiFlag('granularAdminPermissions');
|
||||
|
||||
const onSubmit = async (event: React.FormEvent) => {
|
||||
try {
|
||||
const split = parseInputValue(value);
|
||||
event.preventDefault();
|
||||
if (isGranularPermissionsEnabled) {
|
||||
await setCors(split);
|
||||
} else {
|
||||
await setFrontendSettings(split);
|
||||
}
|
||||
await setCors(split);
|
||||
setValue(formatInputValue(split));
|
||||
setToastData({ text: 'Settings saved', type: 'success' });
|
||||
} catch (error) {
|
||||
|
@ -44,9 +44,6 @@ export const RolePermissionCategories = ({
|
||||
});
|
||||
|
||||
const releasePlansEnabled = useUiFlag('releasePlans');
|
||||
const granularAdminPermissionsEnabled = useUiFlag(
|
||||
'granularAdminPermissions',
|
||||
);
|
||||
|
||||
const isProjectRole = PROJECT_ROLE_TYPES.includes(type);
|
||||
|
||||
@ -90,12 +87,6 @@ export const RolePermissionCategories = ({
|
||||
releasePlansEnabled ||
|
||||
label !== 'Release plan templates',
|
||||
)
|
||||
.filter(
|
||||
({ label }) =>
|
||||
granularAdminPermissionsEnabled ||
|
||||
(label !== 'Instance maintenance' &&
|
||||
label !== 'Authentication'),
|
||||
)
|
||||
.map(({ label, type, permissions }) => (
|
||||
<RolePermissionCategoryAccordion
|
||||
key={label}
|
||||
|
@ -5,23 +5,6 @@ export const useUiConfigApi = () => {
|
||||
propagateErrors: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* @deprecated remove when `granularAdminPermissions` flag is removed
|
||||
*/
|
||||
const setFrontendSettings = async (
|
||||
frontendApiOrigins: string[],
|
||||
): Promise<void> => {
|
||||
const payload = {
|
||||
frontendSettings: { frontendApiOrigins },
|
||||
};
|
||||
const req = createRequest(
|
||||
'api/admin/ui-config',
|
||||
{ method: 'POST', body: JSON.stringify(payload) },
|
||||
'setFrontendSettings',
|
||||
);
|
||||
await makeRequest(req.caller, req.id);
|
||||
};
|
||||
|
||||
const setCors = async (frontendApiOrigins: string[]): Promise<void> => {
|
||||
const req = createRequest(
|
||||
'api/admin/ui-config/cors',
|
||||
@ -32,7 +15,6 @@ export const useUiConfigApi = () => {
|
||||
};
|
||||
|
||||
return {
|
||||
setFrontendSettings,
|
||||
setCors,
|
||||
loading,
|
||||
errors,
|
||||
|
@ -89,7 +89,6 @@ export type UiFlags = {
|
||||
productivityReportEmail?: boolean;
|
||||
showUserDeviceCount?: boolean;
|
||||
flagOverviewRedesign?: boolean;
|
||||
granularAdminPermissions?: boolean;
|
||||
consumptionModel?: boolean;
|
||||
edgeObservability?: boolean;
|
||||
};
|
||||
|
@ -19,11 +19,6 @@ const uiConfig = {
|
||||
async function getSetup() {
|
||||
const base = `/random${Math.round(Math.random() * 1000)}`;
|
||||
const config = createTestConfig({
|
||||
experimental: {
|
||||
flags: {
|
||||
granularAdminPermissions: true,
|
||||
},
|
||||
},
|
||||
server: { baseUriPath: base },
|
||||
ui: uiConfig,
|
||||
});
|
||||
|
@ -100,7 +100,6 @@ class ConfigController extends Controller {
|
||||
],
|
||||
});
|
||||
|
||||
// TODO: deprecate when removing `granularAdminPermissions` flag
|
||||
this.route({
|
||||
method: 'post',
|
||||
path: '',
|
||||
@ -111,10 +110,11 @@ class ConfigController extends Controller {
|
||||
tags: ['Admin UI'],
|
||||
summary: 'Set UI configuration',
|
||||
description:
|
||||
'Sets the UI configuration for this Unleash instance.',
|
||||
'Deprecated. Use `./cors` instead. Sets the UI configuration for this Unleash instance.',
|
||||
operationId: 'setUiConfig',
|
||||
requestBody: createRequestSchema('setUiConfigSchema'),
|
||||
responses: { 200: emptyResponse },
|
||||
deprecated: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
@ -222,14 +222,6 @@ class ConfigController extends Controller {
|
||||
req: IAuthRequest<void, void, SetCorsSchema>,
|
||||
res: Response<string>,
|
||||
): Promise<void> {
|
||||
const granularAdminPermissions = this.flagResolver.isEnabled(
|
||||
'granularAdminPermissions',
|
||||
);
|
||||
|
||||
if (!granularAdminPermissions) {
|
||||
throw new NotFoundError();
|
||||
}
|
||||
|
||||
if (req.body.frontendApiOrigins) {
|
||||
await this.frontendApiService.setFrontendCorsSettings(
|
||||
req.body.frontendApiOrigins,
|
||||
|
@ -57,7 +57,6 @@ export type IFlagKey =
|
||||
| 'flagOverviewRedesign'
|
||||
| 'showUserDeviceCount'
|
||||
| 'memorizeStats'
|
||||
| 'granularAdminPermissions'
|
||||
| 'streaming'
|
||||
| 'etagVariant'
|
||||
| 'deltaApi'
|
||||
@ -277,10 +276,6 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_FLAG_OVERVIEW_REDESIGN,
|
||||
false,
|
||||
),
|
||||
granularAdminPermissions: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_GRANULAR_ADMIN_PERMISSIONS,
|
||||
false,
|
||||
),
|
||||
streaming: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_STREAMING,
|
||||
false,
|
||||
|
@ -53,7 +53,6 @@ process.nextTick(async () => {
|
||||
releasePlanChangeRequests: false,
|
||||
showUserDeviceCount: true,
|
||||
flagOverviewRedesign: true,
|
||||
granularAdminPermissions: true,
|
||||
deltaApi: true,
|
||||
uniqueSdkTracking: true,
|
||||
filterExistingFlagNames: true,
|
||||
|
Loading…
Reference in New Issue
Block a user