1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-18 01:18:23 +02:00

refactor: expect existing TS errors (#767)

* refactor: expect existing TS errors

* refactor: fail build on new TS errors
This commit is contained in:
olav 2022-03-03 10:01:04 +01:00 committed by GitHub
parent cd764a1d99
commit b3bf86ca84
67 changed files with 253 additions and 47 deletions

View File

@ -1 +0,0 @@
TSC_COMPILE_ON_ERROR=true

View File

@ -33,6 +33,7 @@ export const AddonParameter = ({
}: IAddonParameterProps) => { }: IAddonParameterProps) => {
const value = config.parameters[definition.name] || ''; const value = config.parameters[definition.name] || '';
const type = resolveType(definition, value); const type = resolveType(definition, value);
// @ts-expect-error
const error = errors.parameters[definition.name]; const error = errors.parameters[definition.name];
return ( return (
@ -51,6 +52,7 @@ export const AddonParameter = ({
}} }}
value={value} value={value}
error={error} error={error}
// @ts-expect-error
onChange={setParameterValue(definition.name)} onChange={setParameterValue(definition.name)}
variant="outlined" variant="outlined"
helperText={definition.description} helperText={definition.description}

View File

@ -30,6 +30,7 @@ export const AddonParameters = ({
</p> </p>
) : null} ) : null}
{provider.parameters.map(parameter => ( {provider.parameters.map(parameter => (
// @ts-expect-error
<AddonParameter <AddonParameter
key={parameter.name} key={parameter.name}
definition={parameter} definition={parameter}

View File

@ -26,7 +26,8 @@ export const EditAddon = () => {
(addon: IAddon) => addon.id === Number(addonId) (addon: IAddon) => addon.id === Number(addonId)
) || { ...cloneDeep(DEFAULT_DATA) }; ) || { ...cloneDeep(DEFAULT_DATA) };
const provider = addon const provider = addon
? providers.find(provider => provider.name === addon.provider) ? // @ts-expect-error
providers.find(provider => provider.name === addon.provider)
: undefined; : undefined;
return ( return (

View File

@ -92,6 +92,7 @@ const ApiTokenForm: React.FC<IApiTokenFormProps> = ({
label="Token Type" label="Token Type"
id="api_key_type" id="api_key_type"
name="type" name="type"
// @ts-expect-error
IconComponent={KeyboardArrowDownOutlined} IconComponent={KeyboardArrowDownOutlined}
className={styles.selectInput} className={styles.selectInput}
/> />
@ -104,6 +105,7 @@ const ApiTokenForm: React.FC<IApiTokenFormProps> = ({
options={selectableProjects} options={selectableProjects}
onChange={e => setProject(e.target.value as string)} onChange={e => setProject(e.target.value as string)}
label="Project" label="Project"
// @ts-expect-error
IconComponent={KeyboardArrowDownOutlined} IconComponent={KeyboardArrowDownOutlined}
className={styles.selectInput} className={styles.selectInput}
/> />
@ -118,6 +120,7 @@ const ApiTokenForm: React.FC<IApiTokenFormProps> = ({
label="Environment" label="Environment"
id="api_key_environment" id="api_key_environment"
name="environment" name="environment"
// @ts-expect-error
IconComponent={KeyboardArrowDownOutlined} IconComponent={KeyboardArrowDownOutlined}
className={styles.selectInput} className={styles.selectInput}
/> />

View File

@ -42,6 +42,7 @@ const EditProjectRole = () => {
useEffect(() => { useEffect(() => {
const initialCheckedPermissions = role?.permissions?.reduce( const initialCheckedPermissions = role?.permissions?.reduce(
(acc: { [key: string]: IPermission }, curr: IPermission) => { (acc: { [key: string]: IPermission }, curr: IPermission) => {
// @ts-expect-error
acc[getRoleKey(curr)] = curr; acc[getRoleKey(curr)] = curr;
return acc; return acc;
}, },

View File

@ -61,6 +61,7 @@ const ProjectRoleList = () => {
name={role.name} name={role.name}
type={role.type} type={role.type}
description={role.description} description={role.description}
// @ts-expect-error
setCurrentRole={setCurrentRole} setCurrentRole={setCurrentRole}
setDelDialog={setDelDialog} setDelDialog={setDelDialog}
/> />
@ -94,6 +95,7 @@ const ProjectRoleList = () => {
</Table> </Table>
<br /> <br />
<ProjectRoleDeleteConfirm <ProjectRoleDeleteConfirm
// @ts-expect-error
role={currentRole} role={currentRole}
open={delDialog} open={delDialog}
setDeldialogue={setDelDialog} setDeldialogue={setDelDialog}

View File

@ -51,6 +51,7 @@ const RoleListItem = ({
<PermissionIconButton <PermissionIconButton
data-loading data-loading
aria-label="Edit" aria-label="Edit"
// @ts-expect-error
disabled={type === BUILTIN_ROLE_TYPE} disabled={type === BUILTIN_ROLE_TYPE}
onClick={() => { onClick={() => {
history.push(`/admin/roles/${id}/edit`); history.push(`/admin/roles/${id}/edit`);
@ -62,8 +63,10 @@ const RoleListItem = ({
<PermissionIconButton <PermissionIconButton
data-loading data-loading
aria-label="Remove role" aria-label="Remove role"
// @ts-expect-error
disabled={type === BUILTIN_ROLE_TYPE} disabled={type === BUILTIN_ROLE_TYPE}
onClick={() => { onClick={() => {
// @ts-expect-error
setCurrentRole({ id, name, description }); setCurrentRole({ id, name, description });
setDelDialog(true); setDelDialog(true);
}} }}

View File

@ -43,6 +43,7 @@ const useProjectRoleForm = (
) => { ) => {
const formattedInitialCheckedPermissions = const formattedInitialCheckedPermissions =
isAllEnvironmentPermissionsChecked( isAllEnvironmentPermissionsChecked(
// @ts-expect-error
isAllProjectPermissionsChecked(initialCheckedPermissions) isAllProjectPermissionsChecked(initialCheckedPermissions)
); );
@ -59,6 +60,7 @@ const useProjectRoleForm = (
}); });
if (isAllChecked) { if (isAllChecked) {
// @ts-expect-error
initialCheckedPermissions[PROJECT_CHECK_ALL_KEY] = true; initialCheckedPermissions[PROJECT_CHECK_ALL_KEY] = true;
} else { } else {
delete initialCheckedPermissions[PROJECT_CHECK_ALL_KEY]; delete initialCheckedPermissions[PROJECT_CHECK_ALL_KEY];
@ -82,6 +84,7 @@ const useProjectRoleForm = (
const key = `${ENVIRONMENT_CHECK_ALL_KEY}-${env.name}`; const key = `${ENVIRONMENT_CHECK_ALL_KEY}-${env.name}`;
if (isAllChecked) { if (isAllChecked) {
// @ts-expect-error
initialCheckedPermissions[key] = true; initialCheckedPermissions[key] = true;
} else { } else {
delete initialCheckedPermissions[key]; delete initialCheckedPermissions[key];
@ -109,10 +112,12 @@ const useProjectRoleForm = (
} }
if (type === 'project') { if (type === 'project') {
// @ts-expect-error
checkedPermissionsCopy = isAllProjectPermissionsChecked( checkedPermissionsCopy = isAllProjectPermissionsChecked(
checkedPermissionsCopy checkedPermissionsCopy
); );
} else { } else {
// @ts-expect-error
checkedPermissionsCopy = isAllEnvironmentPermissionsChecked( checkedPermissionsCopy = isAllEnvironmentPermissionsChecked(
checkedPermissionsCopy checkedPermissionsCopy
); );
@ -141,6 +146,7 @@ const useProjectRoleForm = (
}; };
if (lastItem) { if (lastItem) {
// @ts-expect-error
checkedPermissionsCopy[PROJECT_CHECK_ALL_KEY] = true; checkedPermissionsCopy[PROJECT_CHECK_ALL_KEY] = true;
} }
} }
@ -173,6 +179,7 @@ const useProjectRoleForm = (
}; };
if (lastItem) { if (lastItem) {
// @ts-expect-error
checkedPermissionsCopy[environmentCheckAllKey] = true; checkedPermissionsCopy[environmentCheckAllKey] = true;
} }
} }
@ -204,6 +211,7 @@ const useProjectRoleForm = (
try { try {
await validateRole(payload); await validateRole(payload);
} catch (e) { } catch (e) {
// @ts-expect-error
if (e.toString().includes(NAME_EXISTS_ERROR)) { if (e.toString().includes(NAME_EXISTS_ERROR)) {
setErrors(prev => ({ setErrors(prev => ({
...prev, ...prev,

View File

@ -51,6 +51,7 @@ const UserForm: React.FC<IUserForm> = ({
const { roles } = useUsers(); const { roles } = useUsers();
const { bootstrap } = useUiBootstrap(); const { bootstrap } = useUiBootstrap();
// @ts-expect-error
const sortRoles = (a, b) => { const sortRoles = (a, b) => {
if (b.name[0] < a.name[0]) { if (b.name[0] < a.name[0]) {
return 1; return 1;
@ -102,6 +103,7 @@ const UserForm: React.FC<IUserForm> = ({
onChange={e => setRootRole(+e.target.value)} onChange={e => setRootRole(+e.target.value)}
data-loading data-loading
> >
{/* @ts-expect-error */}
{roles.sort(sortRoles).map(role => ( {roles.sort(sortRoles).map(role => (
<FormControlLabel <FormControlLabel
key={`role-${role.id}`} key={`role-${role.id}`}

View File

@ -29,6 +29,7 @@ const ChangePassword = ({
const [validPassword, setValidPassword] = useState(false); const [validPassword, setValidPassword] = useState(false);
const commonStyles = useCommonStyles(); const commonStyles = useCommonStyles();
// @ts-expect-error
const updateField = e => { const updateField = e => {
setError({}); setError({});
setData({ setData({
@ -37,10 +38,12 @@ const ChangePassword = ({
}); });
}; };
// @ts-expect-error
const submit = async e => { const submit = async e => {
e.preventDefault(); e.preventDefault();
if (!validPassword) { if (!validPassword) {
// @ts-expect-error
if (!data.password || data.password.length < 8) { if (!data.password || data.password.length < 8) {
setError({ setError({
password: password:
@ -48,6 +51,7 @@ const ChangePassword = ({
}); });
return; return;
} }
// @ts-expect-error
if (!(data.password === data.confirm)) { if (!(data.password === data.confirm)) {
setError({ confirm: 'Passwords does not match' }); setError({ confirm: 'Passwords does not match' });
return; return;
@ -55,15 +59,18 @@ const ChangePassword = ({
} }
try { try {
// @ts-expect-error
await changePassword(user, data.password); await changePassword(user, data.password);
setData({}); setData({});
closeDialog(); closeDialog();
} catch (error) { } catch (error) {
// @ts-expect-error
const msg = error.message || 'Could not update password'; const msg = error.message || 'Could not update password';
setError({ general: msg }); setError({ general: msg });
} }
}; };
// @ts-expect-error
const onCancel = e => { const onCancel = e => {
e.preventDefault(); e.preventDefault();
setData({}); setData({});
@ -111,6 +118,7 @@ const ChangePassword = ({
</Typography> </Typography>
</div> </div>
<PasswordChecker <PasswordChecker
// @ts-expect-error
password={data.password} password={data.password}
callback={setValidPassword} callback={setValidPassword}
/> />
@ -118,6 +126,7 @@ const ChangePassword = ({
label="New password" label="New password"
name="password" name="password"
type="password" type="password"
// @ts-expect-error
value={data.password} value={data.password}
helperText={error.password} helperText={error.password}
onChange={updateField} onChange={updateField}
@ -128,6 +137,7 @@ const ChangePassword = ({
label="Confirm password" label="Confirm password"
name="confirm" name="confirm"
type="password" type="password"
// @ts-expect-error
value={data.confirm} value={data.confirm}
error={error.confirm !== undefined} error={error.confirm !== undefined}
helperText={error.confirm} helperText={error.confirm}
@ -136,7 +146,9 @@ const ChangePassword = ({
size="small" size="small"
/> />
<PasswordMatcher <PasswordMatcher
// @ts-expect-error
started={data.password && data.confirm} started={data.password && data.confirm}
// @ts-expect-error
matchingPasswords={data.password === data.confirm} matchingPasswords={data.password === data.confirm}
/> />
</form> </form>

View File

@ -73,6 +73,7 @@ const UsersList = () => {
const onDeleteUser = async () => { const onDeleteUser = async () => {
try { try {
// @ts-expect-error
await removeUser(delUser); await removeUser(delUser);
setToastData({ setToastData({
title: `${delUser?.name} has been deleted`, title: `${delUser?.name} has been deleted`,
@ -113,6 +114,7 @@ const UsersList = () => {
return page.map(user => { return page.map(user => {
return ( return (
<UserListItem <UserListItem
// @ts-expect-error
key={user.id} key={user.id}
user={user} user={user}
openPwDialog={openPwDialog} openPwDialog={openPwDialog}
@ -162,8 +164,10 @@ const UsersList = () => {
<ChangePassword <ChangePassword
showDialog={pwDialog.open} showDialog={pwDialog.open}
closeDialog={closePwDialog} closeDialog={closePwDialog}
// @ts-expect-error
changePassword={changePassword} changePassword={changePassword}
validatePassword={validatePassword} validatePassword={validatePassword}
// @ts-expect-error
user={pwDialog.user} user={pwDialog.user}
/> />

View File

@ -54,6 +54,7 @@ const useCreateUserForm = (
}; };
const validateEmail = () => { const validateEmail = () => {
// @ts-expect-error
if (users.some(user => user['email'] === email)) { if (users.some(user => user['email'] === email)) {
setErrors(prev => ({ ...prev, email: 'Email already exists' })); setErrors(prev => ({ ...prev, email: 'Email already exists' }));
return false; return false;

View File

@ -23,6 +23,7 @@ const EnvironmentStrategyDialog = ({
const strategiesLink = `/projects/${projectId}/features/${featureId}/strategies?environment=${environmentName}&addStrategy=true`; const strategiesLink = `/projects/${projectId}/features/${featureId}/strategies?environment=${environmentName}&addStrategy=true`;
return ( return (
// @ts-expect-error
<Dialogue <Dialogue
open={open} open={open}
maxWidth="sm" maxWidth="sm"

View File

@ -32,6 +32,7 @@ const Input = ({
return ( return (
<div className={styles.inputContainer} data-loading> <div className={styles.inputContainer} data-loading>
<TextField <TextField
// @ts-expect-error
size="small" size="small"
variant="outlined" variant="outlined"
label={label} label={label}
@ -43,6 +44,7 @@ const Input = ({
value={value} value={value}
onChange={onChange} onChange={onChange}
FormHelperTextProps={{ FormHelperTextProps={{
// @ts-expect-error
['data-test']: INPUT_ERROR_TEXT, ['data-test']: INPUT_ERROR_TEXT,
classes: { classes: {
root: styles.helperText, root: styles.helperText,

View File

@ -17,6 +17,7 @@ const ListPlaceholder = ({ text, link, linkText }: IListPlaceholderProps) => {
{text} {text}
<ConditionallyRender <ConditionallyRender
condition={Boolean(link && linkText)} condition={Boolean(link && linkText)}
// @ts-expect-error
show={<Link to={link}>Add your first toggle</Link>} show={<Link to={link}>Add your first toggle</Link>}
/> />
</ListItem> </ListItem>

View File

@ -48,6 +48,7 @@ const NoItemsStrategies = ({
condition={Boolean(onClick)} condition={Boolean(onClick)}
show={ show={
<PermissionButton <PermissionButton
// @ts-expect-error
variant="contained" variant="contained"
permission={CREATE_FEATURE_STRATEGY} permission={CREATE_FEATURE_STRATEGY}
projectId={projectId} projectId={projectId}

View File

@ -65,6 +65,7 @@ const PermissionButton: React.FC<IPermissionButtonProps> = ({
onClick={onClick} onClick={onClick}
disabled={disabled || !access} disabled={disabled || !access}
variant="contained" variant="contained"
// @ts-expect-error
color="primary" color="primary"
{...rest} {...rest}
endIcon={ endIcon={

View File

@ -46,6 +46,7 @@ const PermissionIconButton: React.FC<IPermissionIconButtonProps> = ({
return ( return (
<Tooltip title={tooltipText} arrow> <Tooltip title={tooltipText} arrow>
<span> <span>
{/* @ts-expect-error */}
<IconButton onClick={onClick} disabled={!access} {...rest}> <IconButton onClick={onClick} disabled={!access} {...rest}>
{children} {children}
</IconButton> </IconButton>

View File

@ -35,6 +35,7 @@ const ResponsiveButton: React.FC<IResponsiveButtonProps> = ({
condition={smallScreen} condition={smallScreen}
show={ show={
<PermissionIconButton <PermissionIconButton
// @ts-expect-error
disabled={disabled} disabled={disabled}
onClick={onClick} onClick={onClick}
permission={permission} permission={permission}
@ -53,6 +54,7 @@ const ResponsiveButton: React.FC<IResponsiveButtonProps> = ({
permission={permission} permission={permission}
projectId={projectId} projectId={projectId}
color="primary" color="primary"
// @ts-expect-error
variant="contained" variant="contained"
disabled={disabled} disabled={disabled}
environmentId={environmentId} environmentId={environmentId}

View File

@ -17,15 +17,18 @@ const TagSelect = ({ value, onChange, ...rest }: ITagSelect) => {
})); }));
return ( return (
<GeneralSelect <>
label="Tag type" {/* @ts-expect-error */}
name="tag-select" <GeneralSelect
id="tag-select" label="Tag type"
options={options} name="tag-select"
value={value} id="tag-select"
onChange={onChange} options={options}
{...rest} value={value}
/> onChange={onChange}
{...rest}
/>
</>
); );
}; };

View File

@ -122,6 +122,7 @@ const EnvironmentListItem = ({
} }
return ( return (
// @ts-expect-error
<ListItem <ListItem
style={{ position: 'relative', opacity }} style={{ position: 'relative', opacity }}
ref={ref} ref={ref}

View File

@ -45,6 +45,7 @@ const CreateFeature = () => {
if (validToggleName) { if (validToggleName) {
const payload = getTogglePayload(); const payload = getTogglePayload();
try { try {
// @ts-expect-error
await createFeatureToggle(project, payload); await createFeatureToggle(project, payload);
history.push(`/projects/${project}/features/${name}`); history.push(`/projects/${project}/features/${name}`);
setToastData({ setToastData({

View File

@ -92,6 +92,7 @@ const FeatureForm: React.FC<IFeatureToggleForm> = ({
</p> </p>
<FeatureTypeSelect <FeatureTypeSelect
value={type} value={type}
// @ts-expect-error
onChange={(e: React.ChangeEvent) => setType(e.target.value)} onChange={(e: React.ChangeEvent) => setType(e.target.value)}
label={'Toggle type'} label={'Toggle type'}
id="feature-type-select" id="feature-type-select"
@ -121,6 +122,7 @@ const FeatureForm: React.FC<IFeatureToggleForm> = ({
}} }}
enabled={editable} enabled={editable}
filter={projectFilterGenerator(permissions, CREATE_FEATURE)} filter={projectFilterGenerator(permissions, CREATE_FEATURE)}
// @ts-expect-error
IconComponent={KeyboardArrowDownOutlined} IconComponent={KeyboardArrowDownOutlined}
className={styles.selectInput} className={styles.selectInput}
/> />

View File

@ -113,6 +113,7 @@ const FeatureToggleListNewItem = ({
onClick={onClick} onClick={onClick}
> >
<Link <Link
// @ts-expect-error
to={getTogglePath(projectId, name, uiConfig.flags.E)} to={getTogglePath(projectId, name, uiConfig.flags.E)}
className={styles.link} className={styles.link}
> >

View File

@ -43,9 +43,12 @@ const FeatureOverviewEnvSwitch = ({
callback(); callback();
} }
} catch (e) { } catch (e) {
// @ts-expect-error
if (e.message === ENVIRONMENT_STRATEGY_ERROR) { if (e.message === ENVIRONMENT_STRATEGY_ERROR) {
// @ts-expect-error
showInfoBox(true); showInfoBox(true);
} else { } else {
// @ts-expect-error
setToastApiError(e.message); setToastApiError(e.message);
} }
} }

View File

@ -73,6 +73,7 @@ const FeatureOverviewEnvironment = ({
} else { } else {
acc[current.name] = { acc[current.name] = {
count: 1, count: 1,
// @ts-expect-error
Icon: getFeatureStrategyIcon(current.name), Icon: getFeatureStrategyIcon(current.name),
}; };
} }
@ -146,6 +147,7 @@ const FeatureOverviewEnvironment = ({
styles.strategyIconContainer styles.strategyIconContainer
} }
> >
{/* @ts-expect-error */}
<Icon <Icon
className={ className={
styles.strategyIcon styles.strategyIcon
@ -184,10 +186,12 @@ const FeatureOverviewEnvironment = ({
/> />
<ConditionallyRender <ConditionallyRender
condition={ condition={
// @ts-expect-error
featureEnvironment?.strategies?.length > 0 featureEnvironment?.strategies?.length > 0
} }
show={ show={
<FeatureOverviewEnvironmentFooter <FeatureOverviewEnvironmentFooter
// @ts-expect-error
env={env} env={env}
environmentMetric={environmentMetric} environmentMetric={environmentMetric}
/> />

View File

@ -54,6 +54,7 @@ const FeatureOverviewEnvironmentMetrics = ({
</p> </p>
</div> </div>
<PercentageCircle <PercentageCircle
// @ts-expect-error
className={styles.percentageCircle} className={styles.percentageCircle}
percentage={percentage} percentage={percentage}
data-loading data-loading

View File

@ -39,6 +39,7 @@ const FeatureOverviewEnvironmentStrategy = ({
permission={UPDATE_FEATURE_STRATEGY} permission={UPDATE_FEATURE_STRATEGY}
environmentId={environmentName} environmentId={environmentName}
projectId={projectId} projectId={projectId}
// @ts-expect-error
component={Link} component={Link}
to={`/projects/${projectId}/features/${featureId}/strategies?environment=${environmentName}`} to={`/projects/${projectId}/features/${featureId}/strategies?environment=${environmentName}`}
> >

View File

@ -39,6 +39,7 @@ const FeatureOverviewMetaData = () => {
Project: {project} Project: {project}
</span> </span>
<ConditionallyRender <ConditionallyRender
// @ts-expect-error
condition={description} condition={description}
show={ show={
<span className={styles.bodyItem} data-loading> <span className={styles.bodyItem} data-loading>
@ -48,6 +49,7 @@ const FeatureOverviewMetaData = () => {
<PermissionIconButton <PermissionIconButton
projectId={projectId} projectId={projectId}
permission={UPDATE_FEATURE} permission={UPDATE_FEATURE}
// @ts-expect-error
component={Link} component={Link}
to={`/projects/${projectId}/features/${featureId}/settings`} to={`/projects/${projectId}/features/${featureId}/settings`}
> >
@ -63,6 +65,7 @@ const FeatureOverviewMetaData = () => {
<PermissionIconButton <PermissionIconButton
projectId={projectId} projectId={projectId}
permission={UPDATE_FEATURE} permission={UPDATE_FEATURE}
// @ts-expect-error
component={Link} component={Link}
to={`/projects/${projectId}/features/${featureId}/settings`} to={`/projects/${projectId}/features/${featureId}/settings`}
> >

View File

@ -98,6 +98,7 @@ const FeatureOverviewTags: React.FC<IFeatureOverviewTagsProps> = ({
} }
}; };
// @ts-expect-error
const renderTag = t => ( const renderTag = t => (
<Chip <Chip
icon={tagIcon(t.type)} icon={tagIcon(t.type)}
@ -118,29 +119,32 @@ const FeatureOverviewTags: React.FC<IFeatureOverviewTagsProps> = ({
); );
return ( return (
<div className={styles.container} {...rest}> <>
<Dialogue {/* @ts-expect-error */}
open={showDelDialog} <div className={styles.container} {...rest}>
onClose={() => { <Dialogue
setShowDelDialog(false); open={showDelDialog}
setSelectedTag({ type: '', value: '' }); onClose={() => {
}} setShowDelDialog(false);
onClick={() => { setSelectedTag({ type: '', value: '' });
setShowDelDialog(false); }}
handleDelete(); onClick={() => {
setSelectedTag({ type: '', value: '' }); setShowDelDialog(false);
}} handleDelete();
title="Are you sure you want to delete this tag?" setSelectedTag({ type: '', value: '' });
/> }}
title="Are you sure you want to delete this tag?"
<div className={styles.tagContent}>
<ConditionallyRender
condition={tags.length > 0}
show={tags.map(renderTag)}
elseShow={<p data-loading>No tags to display</p>}
/> />
<div className={styles.tagContent}>
<ConditionallyRender
condition={tags.length > 0}
show={tags.map(renderTag)}
elseShow={<p data-loading>No tags to display</p>}
/>
</div>
</div> </div>
</div> </>
); );
}; };

View File

@ -65,6 +65,7 @@ const FeatureSettingsMetadata = () => {
<FeatureTypeSelect <FeatureTypeSelect
value={type} value={type}
id="feature-type-select" id="feature-type-select"
// @ts-expect-error
onChange={e => setType(e.target.value)} onChange={e => setType(e.target.value)}
label="Feature type" label="Feature type"
editable={editable} editable={editable}

View File

@ -4,10 +4,15 @@ import GeneralSelect, {
} from '../../../../../common/GeneralSelect/GeneralSelect'; } from '../../../../../common/GeneralSelect/GeneralSelect';
const FeatureTypeSelect = ({ const FeatureTypeSelect = ({
// @ts-expect-error
editable, editable,
// @ts-expect-error
value, value,
// @ts-expect-error
id, id,
// @ts-expect-error
label, label,
// @ts-expect-error
onChange, onChange,
...rest ...rest
}) => { }) => {
@ -24,15 +29,18 @@ const FeatureTypeSelect = ({
} }
return ( return (
<GeneralSelect <>
disabled={!editable} {/* @ts-expect-error */}
options={options} <GeneralSelect
value={value} disabled={!editable}
onChange={onChange} options={options}
label={label} value={value}
id={id} onChange={onChange}
{...rest} label={label}
/> id={id}
{...rest}
/>
</>
); );
}; };

View File

@ -36,18 +36,22 @@ const FeatureProjectSelect = ({
.filter(project => { .filter(project => {
return filter(project.id); return filter(project.id);
}) })
// @ts-expect-error
.map(formatOption); .map(formatOption);
} else { } else {
// @ts-expect-error
options = projects.map(formatOption); options = projects.map(formatOption);
} }
if (value && !options.find(o => o.key === value)) { if (value && !options.find(o => o.key === value)) {
// @ts-expect-error
options.push({ key: value, label: value }); options.push({ key: value, label: value });
} }
return ( return (
<GeneralSelect <GeneralSelect
label="Project" label="Project"
// @ts-expect-error
options={options} options={options}
value={value} value={value}
onChange={onChange} onChange={onChange}

View File

@ -93,6 +93,7 @@ const FeatureSettingsProject = () => {
<FeatureProjectSelect <FeatureProjectSelect
value={project} value={project}
onChange={e => setProject(e.target.value)} onChange={e => setProject(e.target.value)}
// @ts-expect-error
label="Project" label="Project"
enabled={editable} enabled={editable}
filter={filterProjects()} filter={filterProjects()}

View File

@ -50,6 +50,7 @@ const FeatureSettingsProjectConfirm = ({
incompatible = [...incompatible, env]; incompatible = [...incompatible, env];
} }
}); });
// @ts-expect-error
setIncompatibleEnvs(incompatible); setIncompatibleEnvs(incompatible);
}; };
@ -77,6 +78,7 @@ const FeatureSettingsProjectConfirm = ({
</Dialogue> </Dialogue>
} }
elseShow={ elseShow={
// @ts-expect-error
<Dialogue <Dialogue
open={open} open={open}
onClose={onClose} onClose={onClose}

View File

@ -35,11 +35,17 @@ const FeatureStrategiesConfigure = () => {
); );
const styles = useStyles(); const styles = useStyles();
const { const {
// @ts-expect-error
activeEnvironment, activeEnvironment,
// @ts-expect-error
setConfigureNewStrategy, setConfigureNewStrategy,
// @ts-expect-error
configureNewStrategy, configureNewStrategy,
// @ts-expect-error
setExpandedSidebar, setExpandedSidebar,
// @ts-expect-error
featureCache, featureCache,
// @ts-expect-error
setFeatureCache, setFeatureCache,
} = useContext(FeatureStrategiesUIContext); } = useContext(FeatureStrategiesUIContext);
@ -83,6 +89,7 @@ const FeatureStrategiesConfigure = () => {
const feature = cloneDeep(featureCache); const feature = cloneDeep(featureCache);
const environment = feature.environments.find( const environment = feature.environments.find(
// @ts-expect-error
env => env.name === activeEnvironment.name env => env.name === activeEnvironment.name
); );
@ -123,6 +130,7 @@ const FeatureStrategiesConfigure = () => {
<FeatureStrategyAccordion <FeatureStrategyAccordion
strategy={configureNewStrategy} strategy={configureNewStrategy}
expanded expanded
// @ts-expect-error
hideActions hideActions
parameters={strategyParams} parameters={strategyParams}
constraints={strategyConstraints} constraints={strategyConstraints}

View File

@ -6,6 +6,7 @@ import { useStyles } from './FeatureStrategiesCreateHeader.styles';
const FeatureStrategiesCreateHeader = () => { const FeatureStrategiesCreateHeader = () => {
const styles = useStyles(); const styles = useStyles();
// @ts-expect-error
const { expandedSidebar, configureNewStrategy, activeEnvironment } = const { expandedSidebar, configureNewStrategy, activeEnvironment } =
useContext(FeatureStrategiesUIContext); useContext(FeatureStrategiesUIContext);

View File

@ -52,6 +52,7 @@ const FeatureStrategiesEnvironmentList = ({
featureId, featureId,
activeEnvironment, activeEnvironment,
updateFeatureEnvironmentCache, updateFeatureEnvironmentCache,
// @ts-expect-error
} = useFeatureStrategiesEnvironmentList(strategies); } = useFeatureStrategiesEnvironmentList(strategies);
const [{ isOver }, drop] = useDrop({ const [{ isOver }, drop] = useDrop({
@ -86,19 +87,26 @@ const FeatureStrategiesEnvironmentList = ({
const productionGuardMarkup = useProductionGuardMarkup({ const productionGuardMarkup = useProductionGuardMarkup({
show: productionGuard.show, show: productionGuard.show,
onClick: () => { onClick: () => {
// @ts-expect-error
updateStrategy(productionGuard.strategy); updateStrategy(productionGuard.strategy);
// @ts-expect-error
productionGuard.callback(); productionGuard.callback();
setProductionGuard({ setProductionGuard({
show: false, show: false,
// @ts-expect-error
strategy: null, strategy: null,
}); });
}, },
onClose: () => onClose: () =>
// @ts-expect-error
setProductionGuard({ show: false, strategy: null, callback: null }), setProductionGuard({ show: false, strategy: null, callback: null }),
}); });
// @ts-expect-error
const resolveUpdateStrategy = (strategy: IFeatureStrategy, callback) => { const resolveUpdateStrategy = (strategy: IFeatureStrategy, callback) => {
// @ts-expect-error
if (activeEnvironmentsRef?.current?.type === PRODUCTION && !dontShow) { if (activeEnvironmentsRef?.current?.type === PRODUCTION && !dontShow) {
// @ts-expect-error
setProductionGuard({ show: true, strategy, callback }); setProductionGuard({ show: true, strategy, callback });
return; return;
} }
@ -115,6 +123,7 @@ const FeatureStrategiesEnvironmentList = ({
<FeatureStrategyEditable <FeatureStrategyEditable
currentStrategy={strategy} currentStrategy={strategy}
setDelDialog={setDelDialog} setDelDialog={setDelDialog}
// @ts-expect-error
updateStrategy={resolveUpdateStrategy} updateStrategy={resolveUpdateStrategy}
index={index} index={index}
/> />
@ -128,6 +137,7 @@ const FeatureStrategiesEnvironmentList = ({
key={strategy.id} key={strategy.id}
setDelDialog={setDelDialog} setDelDialog={setDelDialog}
currentStrategy={strategy} currentStrategy={strategy}
// @ts-expect-error
updateStrategy={resolveUpdateStrategy} updateStrategy={resolveUpdateStrategy}
index={index} index={index}
/> />
@ -141,6 +151,7 @@ const FeatureStrategiesEnvironmentList = ({
}); });
const strategiesContainerClasses = classnames({ const strategiesContainerClasses = classnames({
// @ts-expect-error
[styles.strategiesContainer]: !expandedSidebar, [styles.strategiesContainer]: !expandedSidebar,
}); });
@ -153,7 +164,7 @@ const FeatureStrategiesEnvironmentList = ({
condition={!expandedSidebar} condition={!expandedSidebar}
show={ show={
<div className={styles.headerContainer}> <div className={styles.headerContainer}>
<div className={styles.headerInnerContainer}> <div>
<FeatureOverviewEnvSwitch <FeatureOverviewEnvSwitch
text={ text={
activeEnvironment.enabled activeEnvironment.enabled

View File

@ -19,12 +19,19 @@ const useFeatureStrategiesEnvironmentList = () => {
useFeatureStrategyApi(); useFeatureStrategyApi();
const { const {
// @ts-expect-error
setConfigureNewStrategy, setConfigureNewStrategy,
// @ts-expect-error
configureNewStrategy, configureNewStrategy,
// @ts-expect-error
activeEnvironment, activeEnvironment,
// @ts-expect-error
setExpandedSidebar, setExpandedSidebar,
// @ts-expect-error
expandedSidebar, expandedSidebar,
// @ts-expect-error
setFeatureCache, setFeatureCache,
// @ts-expect-error
featureCache, featureCache,
} = useContext(FeatureStrategiesUIContext); } = useContext(FeatureStrategiesUIContext);
@ -78,10 +85,12 @@ const useFeatureStrategiesEnvironmentList = () => {
const feature = cloneDeep(featureCache); const feature = cloneDeep(featureCache);
const environment = feature.environments.find( const environment = feature.environments.find(
// @ts-expect-error
env => env.name === activeEnvironment.name env => env.name === activeEnvironment.name
); );
const strategy = environment.strategies.find( const strategy = environment.strategies.find(
// @ts-expect-error
strategy => strategy.id === updatedStrategy.id strategy => strategy.id === updatedStrategy.id
); );
@ -106,9 +115,11 @@ const useFeatureStrategiesEnvironmentList = () => {
const feature = cloneDeep(featureCache); const feature = cloneDeep(featureCache);
const environment = feature.environments.find( const environment = feature.environments.find(
// @ts-expect-error
env => env.name === environmentId env => env.name === environmentId
); );
const strategyIdx = environment.strategies.findIndex( const strategyIdx = environment.strategies.findIndex(
// @ts-expect-error
strategy => strategy.id === strategyId strategy => strategy.id === strategyId
); );

View File

@ -42,12 +42,19 @@ const FeatureStrategiesEnvironments = () => {
const { a11yProps, activeTabIdx, setActiveTab } = useTabs(startingTabId); const { a11yProps, activeTabIdx, setActiveTab } = useTabs(startingTabId);
const { const {
// @ts-expect-error
setActiveEnvironment, setActiveEnvironment,
// @ts-expect-error
activeEnvironment, activeEnvironment,
// @ts-expect-error
configureNewStrategy, configureNewStrategy,
// @ts-expect-error
expandedSidebar, expandedSidebar,
// @ts-expect-error
setExpandedSidebar, setExpandedSidebar,
// @ts-expect-error
featureCache, featureCache,
// @ts-expect-error
setFeatureCache, setFeatureCache,
} = useContext(FeatureStrategiesUIContext); } = useContext(FeatureStrategiesUIContext);
@ -105,6 +112,7 @@ const FeatureStrategiesEnvironments = () => {
if (!feature) return null; if (!feature) return null;
const renderTabs = () => { const renderTabs = () => {
// @ts-expect-error
return featureCache?.environments?.map((env, index) => { return featureCache?.environments?.map((env, index) => {
return ( return (
<Tab <Tab
@ -132,6 +140,7 @@ const FeatureStrategiesEnvironments = () => {
feature?.environments?.forEach(env => { feature?.environments?.forEach(env => {
const cachedEnv = featureCache?.environments?.find( const cachedEnv = featureCache?.environments?.find(
// @ts-expect-error
cacheEnv => cacheEnv.name === env.name cacheEnv => cacheEnv.name === env.name
); );
@ -140,6 +149,7 @@ const FeatureStrategiesEnvironments = () => {
return; return;
} }
// If displayName is different // If displayName is different
// @ts-expect-error
if (env?.displayName !== cachedEnv?.displayName) { if (env?.displayName !== cachedEnv?.displayName) {
equal = false; equal = false;
return; return;
@ -155,6 +165,7 @@ const FeatureStrategiesEnvironments = () => {
feature?.environments?.forEach(env => { feature?.environments?.forEach(env => {
const cachedEnv = featureCache?.environments?.find( const cachedEnv = featureCache?.environments?.find(
// @ts-expect-error
cachedEnv => cachedEnv.name === env.name cachedEnv => cachedEnv.name === env.name
); );
@ -167,14 +178,17 @@ const FeatureStrategiesEnvironments = () => {
env?.strategies?.forEach(strategy => { env?.strategies?.forEach(strategy => {
const cachedStrategy = cachedEnv?.strategies?.find( const cachedStrategy = cachedEnv?.strategies?.find(
// @ts-expect-error
cachedStrategy => cachedStrategy.id === strategy.id cachedStrategy => cachedStrategy.id === strategy.id
); );
// Check stickiness // Check stickiness
// @ts-expect-error
if (cachedStrategy?.stickiness !== strategy?.stickiness) { if (cachedStrategy?.stickiness !== strategy?.stickiness) {
equal = false; equal = false;
return; return;
} }
// @ts-expect-error
if (cachedStrategy?.groupId !== strategy?.groupId) { if (cachedStrategy?.groupId !== strategy?.groupId) {
equal = false; equal = false;
return; return;
@ -256,6 +270,7 @@ const FeatureStrategiesEnvironments = () => {
), ),
}); });
// @ts-expect-error
return featureCache?.environments?.map((env, index) => { return featureCache?.environments?.map((env, index) => {
return ( return (
<TabPanel <TabPanel
@ -274,6 +289,7 @@ const FeatureStrategiesEnvironments = () => {
className={styles.addStrategyButton} className={styles.addStrategyButton}
data-test={ADD_NEW_STRATEGY_ID} data-test={ADD_NEW_STRATEGY_ID}
onClick={() => onClick={() =>
// @ts-expect-error
setExpandedSidebar(prev => !prev) setExpandedSidebar(prev => !prev)
} }
Icon={Add} Icon={Add}
@ -307,6 +323,7 @@ const FeatureStrategiesEnvironments = () => {
envName={env.name} envName={env.name}
onClick={() => onClick={() =>
setExpandedSidebar( setExpandedSidebar(
// @ts-expect-error
prev => !prev prev => !prev
) )
} }

View File

@ -44,6 +44,7 @@ const FeatureStrategyEditable = ({
const { loading } = useFeatureApi(); const { loading } = useFeatureApi();
const { projectId, featureId } = useParams<IFeatureViewParams>(); const { projectId, featureId } = useParams<IFeatureViewParams>();
// @ts-expect-error
const { activeEnvironment, featureCache, dirty, setDirty } = useContext( const { activeEnvironment, featureCache, dirty, setDirty } = useContext(
FeatureStrategiesUIContext FeatureStrategiesUIContext
); );
@ -71,15 +72,18 @@ const FeatureStrategyEditable = ({
mutate(FEATURE_STRATEGY_CACHE_KEY, { ...updatedStrategy }, false); mutate(FEATURE_STRATEGY_CACHE_KEY, { ...updatedStrategy }, false);
const dirtyParams = isDirtyParams(parameters); const dirtyParams = isDirtyParams(parameters);
// @ts-expect-error
setDirty(prev => ({ ...prev, [strategy.id]: dirtyParams })); setDirty(prev => ({ ...prev, [strategy.id]: dirtyParams }));
}; };
const updateFeatureStrategy = () => { const updateFeatureStrategy = () => {
const cleanup = () => { const cleanup = () => {
setStrategyCache(cloneDeep(strategy)); setStrategyCache(cloneDeep(strategy));
// @ts-expect-error
setDirty(prev => ({ ...prev, [strategy.id]: false })); setDirty(prev => ({ ...prev, [strategy.id]: false }));
}; };
// @ts-expect-error
updateStrategy(strategy, cleanup); updateStrategy(strategy, cleanup);
}; };
@ -109,6 +113,7 @@ const FeatureStrategyEditable = ({
}; };
const discardChanges = () => { const discardChanges = () => {
// @ts-expect-error
setDirty(prev => ({ ...prev, [strategy.id]: false })); setDirty(prev => ({ ...prev, [strategy.id]: false }));
mutate(FEATURE_STRATEGY_CACHE_KEY, { ...strategyCache }, false); mutate(FEATURE_STRATEGY_CACHE_KEY, { ...strategyCache }, false);
}; };
@ -117,6 +122,7 @@ const FeatureStrategyEditable = ({
const updatedStrategy = cloneDeep(strategy); const updatedStrategy = cloneDeep(strategy);
updatedStrategy.constraints = [...cloneDeep(constraints)]; updatedStrategy.constraints = [...cloneDeep(constraints)];
// @ts-expect-error
setDirty(prev => ({ ...prev, [strategy.id]: true })); setDirty(prev => ({ ...prev, [strategy.id]: true }));
mutate(FEATURE_STRATEGY_CACHE_KEY, { ...updatedStrategy }, false); mutate(FEATURE_STRATEGY_CACHE_KEY, { ...updatedStrategy }, false);
}; };
@ -136,6 +142,7 @@ const FeatureStrategyEditable = ({
data-test={`${STRATEGY_ACCORDION_ID}-${strategy.name}`} data-test={`${STRATEGY_ACCORDION_ID}-${strategy.name}`}
strategy={strategy} strategy={strategy}
setStrategyParams={setStrategyParams} setStrategyParams={setStrategyParams}
// @ts-expect-error
setStrategyConstraints={setStrategyConstraints} setStrategyConstraints={setStrategyConstraints}
dirty={dirty[strategy.id]} dirty={dirty[strategy.id]}
actions={ actions={
@ -147,6 +154,7 @@ const FeatureStrategyEditable = ({
data-test={`${DELETE_STRATEGY_ID}-${strategy.name}`} data-test={`${DELETE_STRATEGY_ID}-${strategy.name}`}
onClick={e => { onClick={e => {
e.stopPropagation(); e.stopPropagation();
// @ts-expect-error
setDelDialog({ setDelDialog({
strategyId: strategy.id, strategyId: strategy.id,
show: true, show: true,
@ -167,6 +175,7 @@ const FeatureStrategyEditable = ({
permission={UPDATE_FEATURE_STRATEGY} permission={UPDATE_FEATURE_STRATEGY}
projectId={projectId} projectId={projectId}
environmentId={activeEnvironment?.name} environmentId={activeEnvironment?.name}
// @ts-expect-error
variant="contained" variant="contained"
color="primary" color="primary"
className={styles.editButton} className={styles.editButton}
@ -181,6 +190,7 @@ const FeatureStrategyEditable = ({
className={styles.editButton} className={styles.editButton}
disabled={loading} disabled={loading}
color="tertiary" color="tertiary"
// @ts-expect-error
variant="text" variant="text"
permission={UPDATE_FEATURE_STRATEGY} permission={UPDATE_FEATURE_STRATEGY}
projectId={projectId} projectId={projectId}

View File

@ -9,6 +9,7 @@ import ConditionallyRender from '../../../../common/ConditionallyRender';
const FeatureStrategiesList = () => { const FeatureStrategiesList = () => {
const smallScreen = useMediaQuery('(max-width:700px)'); const smallScreen = useMediaQuery('(max-width:700px)');
// @ts-expect-error
const { expandedSidebar, setExpandedSidebar } = useContext( const { expandedSidebar, setExpandedSidebar } = useContext(
FeatureStrategiesUIContext FeatureStrategiesUIContext
); );
@ -32,6 +33,7 @@ const FeatureStrategiesList = () => {
}; };
const toggleSidebar = () => { const toggleSidebar = () => {
// @ts-expect-error
setExpandedSidebar(prev => !prev); setExpandedSidebar(prev => !prev);
}; };

View File

@ -37,6 +37,7 @@ const FeatureStrategyCard = ({
const { featureId, projectId } = useParams<IFeatureViewParams>(); const { featureId, projectId } = useParams<IFeatureViewParams>();
const { strategies } = useStrategies(); const { strategies } = useStrategies();
// @ts-expect-error
const { setConfigureNewStrategy, setExpandedSidebar, activeEnvironment } = const { setConfigureNewStrategy, setExpandedSidebar, activeEnvironment } =
useContext(FeatureStrategiesUIContext); useContext(FeatureStrategiesUIContext);
const { hasAccess } = useContext(AccessContext); const { hasAccess } = useContext(AccessContext);
@ -81,7 +82,7 @@ const FeatureStrategyCard = ({
{<Icon className={styles.icon} />} {<Icon className={styles.icon} />}
</div> </div>
</div> </div>
<div className={styles.rightSection}> <div>
<PermissionIconButton <PermissionIconButton
className={styles.addButton} className={styles.addButton}
onClick={handleClick} onClick={handleClick}

View File

@ -83,6 +83,7 @@ const FeatureStrategyAccordion: React.FC<IFeatureStrategyAccordionProps> = ({
</div> </div>
</AccordionSummary> </AccordionSummary>
<AccordionDetails className={styles.accordionDetails}> <AccordionDetails className={styles.accordionDetails}>
{/* @ts-expect-error */}
<FeatureStrategyAccordionBody <FeatureStrategyAccordionBody
strategy={{ ...strategy, parameters }} strategy={{ ...strategy, parameters }}
updateParameters={updateParameters} updateParameters={updateParameters}

View File

@ -53,6 +53,7 @@ const FeatureStrategyAccordionBody: React.FC<
const { uiConfig } = useUiConfig(); const { uiConfig } = useUiConfig();
const [showConstraints, setShowConstraints] = useState(false); const [showConstraints, setShowConstraints] = useState(false);
const { hasAccess } = useContext(AccessContext); const { hasAccess } = useContext(AccessContext);
// @ts-expect-error
const { activeEnvironment } = useContext(FeatureStrategiesUIContext); const { activeEnvironment } = useContext(FeatureStrategiesUIContext);
const { context } = useUnleashContext(); const { context } = useUnleashContext();
@ -164,6 +165,7 @@ const FeatureStrategyAccordionBody: React.FC<
<PermissionButton <PermissionButton
className={styles.addConstraintBtn} className={styles.addConstraintBtn}
onClick={toggleConstraints} onClick={toggleConstraints}
// @ts-expect-error
variant={'text'} variant={'text'}
data-test={ADD_CONSTRAINT_ID} data-test={ADD_CONSTRAINT_ID}
permission={[ permission={[
@ -192,14 +194,18 @@ const FeatureStrategyAccordionBody: React.FC<
<StrategyConstraints <StrategyConstraints
updateConstraints={updateConstraints} updateConstraints={updateConstraints}
constraints={constraints || []} constraints={constraints || []}
// @ts-expect-error
constraintError={constraintError} constraintError={constraintError}
// @ts-expect-error
setConstraintError={setConstraintError} setConstraintError={setConstraintError}
/> />
</Dialogue> </Dialogue>
<Type <Type
parameters={parameters} parameters={parameters}
// @ts-expect-error
updateParameter={updateParameters} updateParameter={updateParameters}
// @ts-expect-error
strategyDefinition={definition} strategyDefinition={definition}
context={context} context={context}
editable={editable} editable={editable}

View File

@ -50,10 +50,13 @@ const FlexibleStrategy = ({
const resolveStickiness = () => const resolveStickiness = () =>
builtInStickinessOptions.concat( builtInStickinessOptions.concat(
context context
// @ts-expect-error
.filter(c => c.stickiness) .filter(c => c.stickiness)
.filter( .filter(
// @ts-expect-error
c => !builtInStickinessOptions.find(s => s.key === c.name) c => !builtInStickinessOptions.find(s => s.key === c.name)
) )
// @ts-expect-error
.map(c => ({ key: c.name, label: c.name })) .map(c => ({ key: c.name, label: c.name }))
); );

View File

@ -28,20 +28,26 @@ const GeneralStrategy = ({
editable, editable,
}: IGeneralStrategyProps) => { }: IGeneralStrategyProps) => {
const styles = useStyles(); const styles = useStyles();
// @ts-expect-error
const onChangeTextField = (field, evt) => { const onChangeTextField = (field, evt) => {
const { value } = evt.currentTarget; const { value } = evt.currentTarget;
evt.preventDefault(); evt.preventDefault();
// @ts-expect-error
updateParameter(field, value); updateParameter(field, value);
}; };
// @ts-expect-error
const onChangePercentage = (field, evt, newValue) => { const onChangePercentage = (field, evt, newValue) => {
evt.preventDefault(); evt.preventDefault();
// @ts-expect-error
updateParameter(field, newValue); updateParameter(field, newValue);
}; };
// @ts-expect-error
const handleSwitchChange = (key, currentValue) => { const handleSwitchChange = (key, currentValue) => {
const value = currentValue === 'true' ? 'false' : 'true'; const value = currentValue === 'true' ? 'false' : 'true';
// @ts-expect-error
updateParameter(key, value); updateParameter(key, value);
}; };
@ -50,6 +56,7 @@ const GeneralStrategy = ({
strategyDefinition?.parameters.length > 0 strategyDefinition?.parameters.length > 0
) { ) {
return strategyDefinition.parameters.map( return strategyDefinition.parameters.map(
// @ts-expect-error
({ name, type, description, required }) => { ({ name, type, description, required }) => {
let value = parameters[name]; let value = parameters[name];

View File

@ -36,6 +36,7 @@ const StrategyConstraints: React.FC<IStrategyConstraintProps> = ({
const contextFields = context; const contextFields = context;
const enabled = uiConfig.flags[C]; const enabled = uiConfig.flags[C];
// @ts-expect-error
const contextNames = contextFields.map(context => context.name); const contextNames = contextFields.map(context => context.name);
const onClick = (evt: React.SyntheticEvent) => { const onClick = (evt: React.SyntheticEvent) => {
@ -65,9 +66,11 @@ const StrategyConstraints: React.FC<IStrategyConstraintProps> = ({
updateConstraints(updatedConstraints); updateConstraints(updatedConstraints);
}; };
// @ts-expect-error
const updateConstraint = (index: number) => (value, field) => { const updateConstraint = (index: number) => (value, field) => {
const updatedConstraints = [...constraints]; const updatedConstraints = [...constraints];
const constraint = updatedConstraints[index]; const constraint = updatedConstraints[index];
// @ts-expect-error
constraint[field] = value; constraint[field] = value;
updateConstraints(updatedConstraints); updateConstraints(updatedConstraints);
}; };

View File

@ -28,6 +28,7 @@ const StrategyInputList = ({
}; };
const onKeyDown = (e: ChangeEvent) => { const onKeyDown = (e: ChangeEvent) => {
// @ts-expect-error
if (e?.key === ENTERKEY) { if (e?.key === ENTERKEY) {
setValue(e); setValue(e);
e.preventDefault(); e.preventDefault();
@ -37,11 +38,13 @@ const StrategyInputList = ({
const setValue = (evt: ChangeEvent) => { const setValue = (evt: ChangeEvent) => {
evt.preventDefault(); evt.preventDefault();
// @ts-expect-error
const value = evt.target.value; const value = evt.target.value;
if (value) { if (value) {
const newValues = value const newValues = value
.split(/,\s*/) .split(/,\s*/)
// @ts-expect-error
.filter(a => !list.includes(a)); .filter(a => !list.includes(a));
if (newValues.length > 0) { if (newValues.length > 0) {
const newList = list.concat(newValues).filter(a => a); const newList = list.concat(newValues).filter(a => a);
@ -52,6 +55,7 @@ const StrategyInputList = ({
}; };
const onClose = (index: number) => { const onClose = (index: number) => {
// @ts-expect-error
list[index] = null; list[index] = null;
setConfig( setConfig(
name, name,
@ -59,6 +63,7 @@ const StrategyInputList = ({
); );
}; };
// @ts-expect-error
const onChange = e => { const onChange = e => {
setInput(e.currentTarget.value); setInput(e.currentTarget.value);
}; };
@ -96,9 +101,11 @@ const StrategyInputList = ({
placeholder="" placeholder=""
onBlur={onBlur} onBlur={onBlur}
onChange={onChange} onChange={onChange}
// @ts-expect-error
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
data-test={STRATEGY_INPUT_LIST} data-test={STRATEGY_INPUT_LIST}
/> />
{/* @ts-expect-error */}
<Button <Button
onClick={setValue} onClick={setValue}
data-test={ADD_TO_STRATEGY_INPUT_LIST} data-test={ADD_TO_STRATEGY_INPUT_LIST}

View File

@ -155,14 +155,17 @@ const AddVariant = ({
clear(); clear();
closeDialog(); closeDialog();
} catch (error) { } catch (error) {
// @ts-expect-error
if (error?.body?.details[0]?.message?.includes('duplicate value')) { if (error?.body?.details[0]?.message?.includes('duplicate value')) {
setError({ name: 'A variant with that name already exists.' }); setError({ name: 'A variant with that name already exists.' });
} else if ( } else if (
// @ts-expect-error
error?.body?.details[0]?.message?.includes('must be a number') error?.body?.details[0]?.message?.includes('must be a number')
) { ) {
setError({ weight: 'Weight must be a number' }); setError({ weight: 'Weight must be a number' });
} else { } else {
const msg = const msg =
// @ts-expect-error
error?.body?.details[0]?.message || 'Could not add variant'; error?.body?.details[0]?.message || 'Could not add variant';
setError({ general: msg }); setError({ general: msg });
} }
@ -173,6 +176,7 @@ const AddVariant = ({
e.preventDefault(); e.preventDefault();
setPayload({ setPayload({
...payload, ...payload,
// @ts-expect-error
[e.target.name]: e.target.value, [e.target.name]: e.target.value,
}); });
}; };
@ -189,6 +193,7 @@ const AddVariant = ({
setOverrides( setOverrides(
overrides.map((o, i) => { overrides.map((o, i) => {
if (i === index) { if (i === index) {
// @ts-expect-error
o[e.target.name] = e.target.value; o[e.target.name] = e.target.value;
} }

View File

@ -56,14 +56,17 @@ const FeatureOverviewVariants = () => {
useEffect(() => { useEffect(() => {
const options = [ const options = [
'default', 'default',
// @ts-expect-error
...context.filter(c => c.stickiness).map(c => c.name), ...context.filter(c => c.stickiness).map(c => c.name),
]; ];
// @ts-expect-error
setStickinessOptions(options); setStickinessOptions(options);
}, [context]); }, [context]);
const editable = hasAccess(UPDATE_FEATURE_VARIANTS, projectId); const editable = hasAccess(UPDATE_FEATURE_VARIANTS, projectId);
// @ts-expect-error
const setClonedVariants = clonedVariants => const setClonedVariants = clonedVariants =>
setVariants(cloneDeep(clonedVariants)); setVariants(cloneDeep(clonedVariants));
@ -101,16 +104,20 @@ const FeatureOverviewVariants = () => {
const options = stickinessOptions.map(c => ({ key: c, label: c })); const options = stickinessOptions.map(c => ({ key: c, label: c }));
// guard on stickiness being disabled for context field. // guard on stickiness being disabled for context field.
// @ts-expect-error
if (!stickinessOptions.includes(value)) { if (!stickinessOptions.includes(value)) {
// @ts-expect-error
options.push({ key: value, label: value }); options.push({ key: value, label: value });
} }
// @ts-expect-error
const onChange = event => { const onChange = event => {
updateStickiness(event.target.value); updateStickiness(event.target.value);
}; };
return ( return (
<section style={{ paddingTop: '16px' }}> <section style={{ paddingTop: '16px' }}>
{/* @ts-expect-error */}
<GeneralSelect <GeneralSelect
label="Stickiness" label="Stickiness"
options={options} options={options}
@ -315,6 +322,7 @@ const FeatureOverviewVariants = () => {
editing={editing} editing={editing}
validateName={validateName} validateName={validateName}
validateWeight={validateWeight} validateWeight={validateWeight}
// @ts-expect-error
editVariant={editVariant} editVariant={editVariant}
title={editing ? 'Edit variant' : 'Add variant'} title={editing ? 'Edit variant' : 'Add variant'}
/> />

View File

@ -158,6 +158,7 @@ export const FeatureView = () => {
projectId={projectId} projectId={projectId}
tooltip="Copy" tooltip="Copy"
data-loading data-loading
// @ts-expect-error
component={Link} component={Link}
to={`/projects/${projectId}/features/${featureId}/strategies/copy`} to={`/projects/${projectId}/features/${featureId}/strategies/copy`}
> >

View File

@ -69,6 +69,7 @@ const Project = () => {
}); });
} }
// @ts-expect-error
tabData.filter(tab => !tab.disabled); tabData.filter(tab => !tab.disabled);
/* eslint-disable-next-line */ /* eslint-disable-next-line */

View File

@ -51,6 +51,7 @@ const ProjectInfo = ({
<PermissionIconButton <PermissionIconButton
permission={UPDATE_PROJECT} permission={UPDATE_PROJECT}
projectId={id} projectId={id}
// @ts-expect-error
component={Link} component={Link}
className={permissionButtonClass} className={permissionButtonClass}
data-loading data-loading

View File

@ -79,6 +79,7 @@ export const ProjectAccessListItem = ({
onClick={() => { onClick={() => {
handleRemoveAccess(user); handleRemoveAccess(user);
}} }}
// @ts-expect-error
disabled={access.users.length === 1} disabled={access.users.length === 1}
tooltip={ tooltip={
access.users.length === 1 access.users.length === 1

View File

@ -39,6 +39,7 @@ export const ProjectCard = ({
const history = useHistory(); const history = useHistory();
const { setToastData, setToastApiError } = useToast(); const { setToastData, setToastApiError } = useToast();
// @ts-expect-error
const handleClick = e => { const handleClick = e => {
e.preventDefault(); e.preventDefault();
setAnchorEl(e.currentTarget); setAnchorEl(e.currentTarget);
@ -82,6 +83,7 @@ export const ProjectCard = ({
anchorEl={anchorEl} anchorEl={anchorEl}
style={{ top: '40px', left: '-60px' }} style={{ top: '40px', left: '-60px' }}
onClose={e => { onClose={e => {
// @ts-expect-error
e.preventDefault(); e.preventDefault();
setAnchorEl(null); setAnchorEl(null);
}} }}
@ -132,6 +134,7 @@ export const ProjectCard = ({
</div> </div>
<Dialogue <Dialogue
open={showDelDialog} open={showDelDialog}
// @ts-expect-error
onClick={onRemoveProject} onClick={onRemoveProject}
onClose={() => { onClose={() => {
setAnchorEl(null); setAnchorEl(null);

View File

@ -19,6 +19,7 @@ const SWRProvider: React.FC<ISWRProviderProps> = ({
const history = useHistory(); const history = useHistory();
const { setToastApiError } = useToast(); const { setToastApiError } = useToast();
// @ts-expect-error
const handleFetchError = error => { const handleFetchError = error => {
if (error.status === 401) { if (error.status === 401) {
const path = location.pathname; const path = location.pathname;
@ -36,6 +37,7 @@ const SWRProvider: React.FC<ISWRProviderProps> = ({
return; return;
} }
// @ts-expect-error
cache.clear(); cache.clear();
history.push('/login'); history.push('/login');

View File

@ -13,6 +13,7 @@ export const useStyles = makeStyles(theme => ({
}, },
deprecated: { deprecated: {
'& a': { '& a': {
// @ts-expect-error
color: theme.palette.links.deprecated, color: theme.palette.links.deprecated,
}, },
}, },

View File

@ -33,6 +33,7 @@ export const StrategyForm = ({ editMode, strategy }: IStrategyFormProps) => {
const [name, setName] = useState(strategy?.name || ''); const [name, setName] = useState(strategy?.name || '');
const [description, setDescription] = useState(strategy?.description || ''); const [description, setDescription] = useState(strategy?.description || '');
const [params, setParams] = useState<ICustomStrategyParams[]>( const [params, setParams] = useState<ICustomStrategyParams[]>(
// @ts-expect-error
strategy?.parameters || [] strategy?.parameters || []
); );
const [errors, setErrors] = useState<ICustomStrategyErrors>({}); const [errors, setErrors] = useState<ICustomStrategyErrors>({});

View File

@ -30,6 +30,7 @@ export const StrategyView = () => {
label: 'Details', label: 'Details',
component: ( component: (
<StrategyDetails <StrategyDetails
// @ts-expect-error
strategy={strategy} strategy={strategy}
toggles={toggles} toggles={toggles}
applications={applications} applications={applications}
@ -38,6 +39,7 @@ export const StrategyView = () => {
}, },
{ {
label: 'Edit', label: 'Edit',
// @ts-expect-error
component: <StrategyForm strategy={strategy} editMode />, component: <StrategyForm strategy={strategy} editMode />,
}, },
]; ];

View File

@ -79,8 +79,7 @@ const ForgottenPassword = () => {
onSubmit={onClick} onSubmit={onClick}
className={classnames( className={classnames(
commonStyles.contentSpacingY, commonStyles.contentSpacingY,
commonStyles.flexColumn, commonStyles.flexColumn
styles.container
)} )}
> >
<Typography <Typography

View File

@ -18,7 +18,9 @@ const StandaloneBanner: FC<IStandaloneBannerProps> = ({ title, children }) => {
return ( return (
<Gradient <Gradient
from={theme.palette.primary.main} from={theme.palette.primary.main}
// @ts-expect-error
to={theme.palette.login.gradient.bottom} to={theme.palette.login.gradient.bottom}
// @ts-expect-error
className={styles.gradient} className={styles.gradient}
> >
<div className={styles.container}> <div className={styles.container}>

View File

@ -10,6 +10,7 @@ export const useStyles = makeStyles(theme => ({
}, },
headerContainer: { display: 'flex', padding: '0.5rem' }, headerContainer: { display: 'flex', padding: '0.5rem' },
divider: { divider: {
// @ts-expect-error
backgroundColor: theme.palette.borders?.main, backgroundColor: theme.palette.borders?.main,
height: '1px', height: '1px',
width: '100%', width: '100%',

View File

@ -1,4 +1,3 @@
import { IContext } from '../../../../interfaces/context';
import useAPI from '../useApi/useApi'; import useAPI from '../useApi/useApi';
const useContextsApi = () => { const useContextsApi = () => {
@ -23,6 +22,7 @@ const useContextsApi = () => {
} }
}; };
// @ts-expect-error
const createContext = async (payload: IContext) => { const createContext = async (payload: IContext) => {
const path = URI; const path = URI;
const req = createRequest(path, { const req = createRequest(path, {
@ -39,6 +39,7 @@ const useContextsApi = () => {
} }
}; };
// @ts-expect-error
const updateContext = async (context: IContext) => { const updateContext = async (context: IContext) => {
const path = `${URI}/${context.name}`; const path = `${URI}/${context.name}`;
const req = createRequest(path, { const req = createRequest(path, {

View File

@ -22,6 +22,7 @@ const useProject = (id: string, options: SWRConfiguration = {}) => {
const sortedData = (data: IProject | undefined): IProject => { const sortedData = (data: IProject | undefined): IProject => {
if (data) { if (data) {
// @ts-expect-error
return { ...data, features: sort(data.features || []) }; return { ...data, features: sort(data.features || []) };
} }
return fallbackProject; return fallbackProject;

View File

@ -20,7 +20,7 @@ export const createPersistentGlobalStateHook = <T extends object>(
const setGlobalState = (value: React.SetStateAction<T>) => { const setGlobalState = (value: React.SetStateAction<T>) => {
const prev = container.getGlobalState(key); const prev = container.getGlobalState(key);
const next = typeof value === 'function' ? value(prev) : value; const next = value instanceof Function ? value(prev) : value;
container.setGlobalState(key, next); container.setGlobalState(key, next);
setLocalStorageItem(key, next); setLocalStorageItem(key, next);
}; };