mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat: Group schema updates (#4258)
This commit is contained in:
parent
34aeca2418
commit
276261c913
@ -27,7 +27,6 @@ import { formatUnknownError } from 'utils/formatUnknownError';
|
|||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
import { PlaygroundEditor } from './PlaygroundEditor/PlaygroundEditor';
|
import { PlaygroundEditor } from './PlaygroundEditor/PlaygroundEditor';
|
||||||
import { parseDateValue, parseValidDate } from 'component/common/util';
|
import { parseDateValue, parseValidDate } from 'component/common/util';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
||||||
import { isStringOrStringArray } from '../../playground.utils';
|
import { isStringOrStringArray } from '../../playground.utils';
|
||||||
interface IPlaygroundCodeFieldsetProps {
|
interface IPlaygroundCodeFieldsetProps {
|
||||||
context: string | undefined;
|
context: string | undefined;
|
||||||
@ -39,8 +38,6 @@ export const PlaygroundCodeFieldset: VFC<IPlaygroundCodeFieldsetProps> = ({
|
|||||||
setContext,
|
setContext,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { uiConfig } = useUiConfig();
|
|
||||||
const isAdvancedPlayground = Boolean(uiConfig.flags.advancedPlayground);
|
|
||||||
|
|
||||||
const { setToastData } = useToast();
|
const { setToastData } = useToast();
|
||||||
const { context: contextData } = useUnleashContext();
|
const { context: contextData } = useUnleashContext();
|
||||||
@ -123,27 +120,23 @@ export const PlaygroundCodeFieldset: VFC<IPlaygroundCodeFieldsetProps> = ({
|
|||||||
setContextValue(newValue);
|
setContextValue(newValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveAutocompleteValue = (): string | string[] | null => {
|
const resolveAutocompleteValue = (): string[] => {
|
||||||
//This is needed for clearing the Autocomplete Chips when changing the context field
|
//This is needed for clearing the Autocomplete Chips when changing the context field
|
||||||
//and the new field also has legal values
|
//and the new field also has legal values
|
||||||
if (!contextValue || contextValue === '') {
|
if (!contextValue || contextValue === '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdvancedPlayground) {
|
// Split comma separated strings to array for fields with legal values
|
||||||
// Split comma separated strings to array for fields with legal values
|
const foundField = contextData.find(
|
||||||
const foundField = contextData.find(
|
contextData => contextData.name === contextField
|
||||||
contextData => contextData.name === contextField
|
);
|
||||||
);
|
const hasLegalValues = (foundField?.legalValues || []).length > 1;
|
||||||
const hasLegalValues = (foundField?.legalValues || []).length > 1;
|
if (contextValue.includes(',') && hasLegalValues) {
|
||||||
if (contextValue.includes(',') && hasLegalValues) {
|
return contextValue.split(',');
|
||||||
return contextValue.split(',');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [contextValue as string];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return contextValue;
|
return [contextValue as string];
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveInput = () => {
|
const resolveInput = () => {
|
||||||
@ -195,12 +188,12 @@ export const PlaygroundCodeFieldset: VFC<IPlaygroundCodeFieldsetProps> = ({
|
|||||||
value={resolveAutocompleteValue()}
|
value={resolveAutocompleteValue()}
|
||||||
onChange={changeContextValue}
|
onChange={changeContextValue}
|
||||||
options={options}
|
options={options}
|
||||||
multiple={isAdvancedPlayground}
|
multiple={true}
|
||||||
sx={{ width: 370, maxWidth: '100%' }}
|
sx={{ width: 370, maxWidth: '100%' }}
|
||||||
renderInput={(params: any) => (
|
renderInput={(params: any) => (
|
||||||
<TextField {...params} label="Value" />
|
<TextField {...params} label="Value" />
|
||||||
)}
|
)}
|
||||||
disableCloseOnSelect={isAdvancedPlayground!}
|
disableCloseOnSelect={false}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -210,9 +203,7 @@ export const PlaygroundCodeFieldset: VFC<IPlaygroundCodeFieldsetProps> = ({
|
|||||||
label="Value"
|
label="Value"
|
||||||
id="context-value"
|
id="context-value"
|
||||||
sx={{ width: 370, maxWidth: '100%' }}
|
sx={{ width: 370, maxWidth: '100%' }}
|
||||||
placeholder={
|
placeholder={'value1,value2,value3'}
|
||||||
isAdvancedPlayground ? 'value1,value2,value3' : 'value1'
|
|
||||||
}
|
|
||||||
size="small"
|
size="small"
|
||||||
value={contextValue}
|
value={contextValue}
|
||||||
onChange={event => setContextValue(event.target.value || '')}
|
onChange={event => setContextValue(event.target.value || '')}
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
useTheme,
|
useTheme,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
||||||
import { renderOption } from '../renderOption';
|
import { renderOption } from '../renderOption';
|
||||||
|
|
||||||
interface IPlaygroundConnectionFieldsetProps {
|
interface IPlaygroundConnectionFieldsetProps {
|
||||||
@ -35,9 +34,6 @@ export const PlaygroundConnectionFieldset: VFC<
|
|||||||
availableEnvironments,
|
availableEnvironments,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { uiConfig } = useUiConfig();
|
|
||||||
|
|
||||||
const isAdvancedPlayground = uiConfig.flags.advancedPlayground;
|
|
||||||
|
|
||||||
const { projects: availableProjects = [] } = useProjects();
|
const { projects: availableProjects = [] } = useProjects();
|
||||||
const projectsOptions = [
|
const projectsOptions = [
|
||||||
@ -102,9 +98,9 @@ export const PlaygroundConnectionFieldset: VFC<
|
|||||||
const isAllProjects =
|
const isAllProjects =
|
||||||
projects.length === 0 || (projects.length === 1 && projects[0] === '*');
|
projects.length === 0 || (projects.length === 1 && projects[0] === '*');
|
||||||
|
|
||||||
const envValue = isAdvancedPlayground
|
const envValue = environmentOptions.filter(({ id }) =>
|
||||||
? environmentOptions.filter(({ id }) => environments.includes(id))
|
environments.includes(id)
|
||||||
: environmentOptions.filter(({ id }) => environments.includes(id))[0];
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ pb: 2 }}>
|
<Box sx={{ pb: 2 }}>
|
||||||
@ -122,7 +118,7 @@ export const PlaygroundConnectionFieldset: VFC<
|
|||||||
disablePortal
|
disablePortal
|
||||||
limitTags={3}
|
limitTags={3}
|
||||||
id="environment"
|
id="environment"
|
||||||
multiple={isAdvancedPlayground}
|
multiple={true}
|
||||||
options={environmentOptions}
|
options={environmentOptions}
|
||||||
sx={{ flex: 1 }}
|
sx={{ flex: 1 }}
|
||||||
renderInput={params => (
|
renderInput={params => (
|
||||||
@ -130,7 +126,7 @@ export const PlaygroundConnectionFieldset: VFC<
|
|||||||
)}
|
)}
|
||||||
renderOption={renderOption}
|
renderOption={renderOption}
|
||||||
getOptionLabel={({ label }) => label}
|
getOptionLabel={({ label }) => label}
|
||||||
disableCloseOnSelect={isAdvancedPlayground!}
|
disableCloseOnSelect={false}
|
||||||
size="small"
|
size="small"
|
||||||
value={envValue}
|
value={envValue}
|
||||||
onChange={onEnvironmentsChange}
|
onChange={onEnvironmentsChange}
|
||||||
|
@ -92,9 +92,6 @@ const metaRules: Rule[] = [
|
|||||||
knownExceptions: [
|
knownExceptions: [
|
||||||
'createInvitedUserSchema',
|
'createInvitedUserSchema',
|
||||||
'featureStrategySegmentSchema',
|
'featureStrategySegmentSchema',
|
||||||
'groupSchema',
|
|
||||||
'groupsSchema',
|
|
||||||
'groupUserModelSchema',
|
|
||||||
'maintenanceSchema',
|
'maintenanceSchema',
|
||||||
'toggleMaintenanceSchema',
|
'toggleMaintenanceSchema',
|
||||||
'patchSchema',
|
'patchSchema',
|
||||||
@ -132,9 +129,6 @@ const metaRules: Rule[] = [
|
|||||||
'createInvitedUserSchema',
|
'createInvitedUserSchema',
|
||||||
'dateSchema',
|
'dateSchema',
|
||||||
'featureStrategySegmentSchema',
|
'featureStrategySegmentSchema',
|
||||||
'groupSchema',
|
|
||||||
'groupsSchema',
|
|
||||||
'groupUserModelSchema',
|
|
||||||
'maintenanceSchema',
|
'maintenanceSchema',
|
||||||
'toggleMaintenanceSchema',
|
'toggleMaintenanceSchema',
|
||||||
'patchSchema',
|
'patchSchema',
|
||||||
|
@ -7,49 +7,67 @@ export const groupSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: true,
|
additionalProperties: true,
|
||||||
required: ['name'],
|
required: ['name'],
|
||||||
|
description: 'A detailed information about a user group',
|
||||||
properties: {
|
properties: {
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
description: 'The group id',
|
||||||
|
type: 'integer',
|
||||||
|
example: 1,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
|
description: 'The name of the group',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
example: 'DX team',
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
|
description: 'A custom description of the group',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
example: 'Current members of the DX squad',
|
||||||
},
|
},
|
||||||
mappingsSSO: {
|
mappingsSSO: {
|
||||||
|
description:
|
||||||
|
'A list of SSO groups that should map to this Unleash group',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
example: ['SSOGroup1', 'SSOGroup2'],
|
||||||
},
|
},
|
||||||
rootRole: {
|
rootRole: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description:
|
description:
|
||||||
'A role id that is used as the root role for all users in this group. This can be either the id of the Editor or Admin role.',
|
'A role id that is used as the root role for all users in this group. This can be either the id of the Viewer, Editor or Admin role.',
|
||||||
|
example: 1,
|
||||||
},
|
},
|
||||||
createdBy: {
|
createdBy: {
|
||||||
|
description: 'A user who created this group',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
example: 'admin',
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
|
description: 'When was this group created',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
format: 'date-time',
|
format: 'date-time',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
example: '2023-06-30T11:41:00.123Z',
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
|
description: 'A list of users belonging to this group',
|
||||||
items: {
|
items: {
|
||||||
$ref: '#/components/schemas/groupUserModelSchema',
|
$ref: '#/components/schemas/groupUserModelSchema',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
projects: {
|
projects: {
|
||||||
|
description: 'A list of projects where this group is used',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
example: ['default', 'my-project'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -6,14 +6,20 @@ export const groupUserModelSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ['user'],
|
required: ['user'],
|
||||||
|
description: 'Details for a single user belonging to a group',
|
||||||
properties: {
|
properties: {
|
||||||
joinedAt: {
|
joinedAt: {
|
||||||
|
description: 'The date when the user joined the group',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
format: 'date-time',
|
format: 'date-time',
|
||||||
|
example: '2023-06-30T11:41:00.123Z',
|
||||||
},
|
},
|
||||||
createdBy: {
|
createdBy: {
|
||||||
|
description:
|
||||||
|
'The username of the user who added this user to this group',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
example: 'admin',
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
$ref: '#/components/schemas/userSchema',
|
$ref: '#/components/schemas/userSchema',
|
||||||
|
@ -7,8 +7,11 @@ export const groupsSchema = {
|
|||||||
$id: '#/components/schemas/groupsSchema',
|
$id: '#/components/schemas/groupsSchema',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description:
|
||||||
|
'A list of [user groups](https://docs.getunleash.io/reference/rbac#user-groups)',
|
||||||
properties: {
|
properties: {
|
||||||
groups: {
|
groups: {
|
||||||
|
description: 'A list of groups',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
$ref: '#/components/schemas/groupSchema',
|
$ref: '#/components/schemas/groupSchema',
|
||||||
|
Loading…
Reference in New Issue
Block a user