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