1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

Merge branch 'main' into fix/context-form-validation

This commit is contained in:
Youssef Khedher 2022-02-25 14:02:42 +01:00 committed by GitHub
commit 19abd37b60
34 changed files with 49 additions and 64 deletions

View File

@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { TextField, FormControlLabel, Switch } from '@material-ui/core'; import { TextField, FormControlLabel, Switch, Button } from '@material-ui/core';
import { FormButtons, styles as commonStyles } from '../../common'; import { styles as commonStyles } from '../../common';
import { trim } from '../../common/util'; import { trim } from '../../common/util';
import { AddonParameters } from './AddonParameters/AddonParameters'; import { AddonParameters } from './AddonParameters/AddonParameters';
import { AddonEvents } from './AddonEvents/AddonEvents'; import { AddonEvents } from './AddonEvents/AddonEvents';
@ -79,7 +79,7 @@ export const AddonForm = ({ editMode, provider, addon, fetch }) => {
setErrors({ ...errors, events: undefined }); setErrors({ ...errors, events: undefined });
}; };
const handleCancel = () => { const onCancel = () => {
history.goBack(); history.goBack();
}; };
@ -203,10 +203,12 @@ export const AddonForm = ({ editMode, provider, addon, fetch }) => {
/> />
</section> </section>
<section className={styles.formSection}> <section className={styles.formSection}>
<FormButtons <Button type="submit" color="primary" variant="contained">
submitText={submitText} {submitText}
onCancel={handleCancel} </Button>
/> <Button type="button" onClick={onCancel}>
Cancel
</Button>
</section> </section>
</form> </form>
</PageContent> </PageContent>

View File

@ -44,7 +44,6 @@ export const AvailableAddons = ({
onClick={() => onClick={() =>
history.push(`/addons/create/${provider.name}`) history.push(`/addons/create/${provider.name}`)
} }
tooltip={`Configure ${provider.name} Addon`}
> >
Configure Configure
</PermissionButton> </PermissionButton>

View File

@ -123,7 +123,6 @@ export const ConfiguredAddons = ({ getAddonIcon }: IConfigureAddonsProps) => {
</PermissionIconButton> </PermissionIconButton>
<PermissionIconButton <PermissionIconButton
permission={UPDATE_ADDON} permission={UPDATE_ADDON}
tooltip={'Edit Addon'}
onClick={() => { onClick={() => {
history.push(`/addons/edit/${addon.id}`); history.push(`/addons/edit/${addon.id}`);
}} }}
@ -132,7 +131,6 @@ export const ConfiguredAddons = ({ getAddonIcon }: IConfigureAddonsProps) => {
</PermissionIconButton> </PermissionIconButton>
<PermissionIconButton <PermissionIconButton
permission={DELETE_ADDON} permission={DELETE_ADDON}
tooltip={'Remove Addon'}
onClick={() => { onClick={() => {
setDeletedAddon(addon); setDeletedAddon(addon);
setShowDelete(true); setShowDelete(true);

View File

@ -249,7 +249,7 @@ export const ApiTokenList = () => {
} }
data-test={CREATE_API_TOKEN_BUTTON} data-test={CREATE_API_TOKEN_BUTTON}
> >
Create API token New API token
</Button> </Button>
} }
/> />

View File

@ -126,7 +126,7 @@ to resources within a project"
getRoleKey={getRoleKey} getRoleKey={getRoleKey}
> >
<PermissionButton permission={ADMIN} type="submit"> <PermissionButton permission={ADMIN} type="submit">
Edit role Save
</PermissionButton> </PermissionButton>
</ProjectRoleForm> </ProjectRoleForm>
</FormTemplate> </FormTemplate>

View File

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

View File

@ -96,7 +96,7 @@ const EditUser = () => {
mode={EDIT} mode={EDIT}
> >
<PermissionButton permission={ADMIN} type="submit"> <PermissionButton permission={ADMIN} type="submit">
Edit user Save
</PermissionButton> </PermissionButton>
</UserForm> </UserForm>
</FormTemplate> </FormTemplate>

View File

@ -35,7 +35,7 @@ const UsersAdmin = () => {
history.push('/admin/create-user') history.push('/admin/create-user')
} }
> >
Add new user New user
</Button> </Button>
} }
elseShow={ elseShow={

View File

@ -52,7 +52,6 @@ const Constraint = ({
<div className={styles.btnContainer}> <div className={styles.btnContainer}>
<PermissionIconButton <PermissionIconButton
onClick={editCallback} onClick={editCallback}
tooltip="Edit strategy"
permission={UPDATE_FEATURE} permission={UPDATE_FEATURE}
projectId={projectId} projectId={projectId}
> >
@ -61,7 +60,6 @@ const Constraint = ({
<PermissionIconButton <PermissionIconButton
onClick={deleteCallback} onClick={deleteCallback}
tooltip="Delete strategy"
permission={UPDATE_FEATURE} permission={UPDATE_FEATURE}
projectId={projectId} projectId={projectId}
> >

View File

@ -16,7 +16,7 @@ export interface IPermissionIconButtonProps
const PermissionButton: React.FC<IPermissionIconButtonProps> = ({ const PermissionButton: React.FC<IPermissionIconButtonProps> = ({
permission, permission,
tooltip = 'Click to perform action', tooltip,
onClick, onClick,
children, children,
disabled, disabled,
@ -54,9 +54,9 @@ const PermissionButton: React.FC<IPermissionIconButtonProps> = ({
access = handleAccess(); access = handleAccess();
const tooltipText = access const tooltipText = !access
? tooltip ? "You don't have access to perform this operation"
: "You don't have access to perform this operation"; : '';
return ( return (
<Tooltip title={tooltipText} arrow> <Tooltip title={tooltipText} arrow>

View File

@ -39,9 +39,9 @@ const PermissionIconButton: React.FC<IPermissionIconButtonProps> = ({
access = hasAccess(permission); access = hasAccess(permission);
} }
const tooltipText = access const tooltipText = !access
? tooltip || '' ? "You don't have access to perform this operation"
: "You don't have access to perform this operation"; : '';
return ( return (
<Tooltip title={tooltipText} arrow> <Tooltip title={tooltipText} arrow>

View File

@ -19,7 +19,7 @@ const PermissionSwitch = React.forwardRef<
>((props, ref) => { >((props, ref) => {
const { const {
permission, permission,
tooltip = '', tooltip,
disabled, disabled,
projectId, projectId,
environmentId, environmentId,
@ -39,9 +39,9 @@ const PermissionSwitch = React.forwardRef<
access = hasAccess(permission); access = hasAccess(permission);
} }
const tooltipText = access const tooltipText = !access
? tooltip ? "You don't have access to perform this operation"
: "You don't have access to perform this operation"; : '';
return ( return (
<Tooltip title={tooltipText} arrow> <Tooltip title={tooltipText} arrow>

View File

@ -128,7 +128,7 @@ const ContextList = () => {
color="primary" color="primary"
variant="contained" variant="contained"
> >
Add new context field New context field
</Button> </Button>
} }
/> />

View File

@ -102,7 +102,7 @@ export const EditContext = () => {
permission={UPDATE_CONTEXT_FIELD} permission={UPDATE_CONTEXT_FIELD}
type="submit" type="submit"
> >
Edit context Save
</PermissionButton> </PermissionButton>
</ContextForm> </ContextForm>
</FormTemplate> </FormTemplate>

View File

@ -87,7 +87,7 @@ const EditEnvironment = () => {
clearErrors={clearErrors} clearErrors={clearErrors}
> >
<PermissionButton permission={ADMIN} type="submit"> <PermissionButton permission={ADMIN} type="submit">
Edit environment Save
</PermissionButton> </PermissionButton>
</EnvironmentForm> </EnvironmentForm>
</FormTemplate> </FormTemplate>

View File

@ -175,12 +175,11 @@ const EnvironmentList = () => {
<ResponsiveButton <ResponsiveButton
onClick={navigateToCreateEnvironment} onClick={navigateToCreateEnvironment}
maxWidth="700px" maxWidth="700px"
tooltip="Add environment"
Icon={Add} Icon={Add}
permission={ADMIN} permission={ADMIN}
disabled={!Boolean(uiConfig.flags.EEA)} disabled={!Boolean(uiConfig.flags.EEA)}
> >
Add Environment New Environment
</ResponsiveButton> </ResponsiveButton>
</> </>
} }

View File

@ -107,7 +107,7 @@ const EditFeature = () => {
projectId={project} projectId={project}
type="submit" type="submit"
> >
Edit toggle Save
</PermissionButton> </PermissionButton>
</FeatureForm> </FeatureForm>
</FormTemplate> </FormTemplate>

View File

@ -183,7 +183,7 @@ const FeatureToggleList = ({
skeleton: loading, skeleton: loading,
})} })}
> >
Create feature toggle New feature toggle
</Button> </Button>
} }
/> />

View File

@ -165,7 +165,7 @@ exports[`renders correctly with one feature 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Create feature toggle New feature toggle
</span> </span>
</a> </a>
</div> </div>
@ -362,7 +362,7 @@ exports[`renders correctly with one feature without permissions 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Create feature toggle New feature toggle
</span> </span>
</a> </a>
</div> </div>

View File

@ -95,7 +95,6 @@ const FeatureOverviewEnvSwitch = ({
checked={env.enabled} checked={env.enabled}
onChange={toggleEnvironment} onChange={toggleEnvironment}
environmentId={env.name} environmentId={env.name}
tooltip={''}
/> />
{content} {content}
</div> </div>

View File

@ -102,7 +102,6 @@ const FeatureSettingsProject = () => {
show={ show={
<PermissionButton <PermissionButton
permission={MOVE_FEATURE_TOGGLE} permission={MOVE_FEATURE_TOGGLE}
tooltip="Update feature"
onClick={() => setShowConfirmDialog(true)} onClick={() => setShowConfirmDialog(true)}
projectId={projectId} projectId={projectId}
> >

View File

@ -282,7 +282,7 @@ const FeatureStrategiesEnvironments = () => {
environmentId={activeEnvironment.name} environmentId={activeEnvironment.name}
permission={CREATE_FEATURE_STRATEGY} permission={CREATE_FEATURE_STRATEGY}
> >
Add new strategy New strategy
</ResponsiveButton> </ResponsiveButton>
} }
/> />

View File

@ -294,7 +294,7 @@ const FeatureOverviewVariants = () => {
permission={UPDATE_FEATURE_VARIANTS} permission={UPDATE_FEATURE_VARIANTS}
projectId={projectId} projectId={projectId}
> >
Add variant New variant
</PermissionButton> </PermissionButton>
<ConditionallyRender <ConditionallyRender
condition={editable} condition={editable}

View File

@ -92,7 +92,7 @@ const EditProject = () => {
validateIdUniqueness={validateIdUniqueness} validateIdUniqueness={validateIdUniqueness}
> >
<PermissionButton permission={UPDATE_PROJECT} type="submit"> <PermissionButton permission={UPDATE_PROJECT} type="submit">
Edit project Save
</PermissionButton> </PermissionButton>
</ProjectForm> </ProjectForm>
</FormTemplate> </FormTemplate>

View File

@ -125,7 +125,6 @@ const Project = () => {
<div className={styles.titleText}>{project?.name}</div> <div className={styles.titleText}>{project?.name}</div>
<PermissionIconButton <PermissionIconButton
permission={UPDATE_PROJECT} permission={UPDATE_PROJECT}
tooltip="Edit"
projectId={project?.id} projectId={project?.id}
onClick={() => history.push(`/projects/${id}/edit`)} onClick={() => history.push(`/projects/${id}/edit`)}
data-loading data-loading

View File

@ -66,7 +66,6 @@ const ProjectFeatureToggles = ({
) )
} }
maxWidth="700px" maxWidth="700px"
tooltip="New feature toggle"
Icon={Add} Icon={Add}
projectId={id} projectId={id}
permission={CREATE_FEATURE} permission={CREATE_FEATURE}

View File

@ -50,7 +50,6 @@ const ProjectInfo = ({
const permissionButton = ( const permissionButton = (
<PermissionIconButton <PermissionIconButton
permission={UPDATE_PROJECT} permission={UPDATE_PROJECT}
tooltip={'Edit description'}
projectId={id} projectId={id}
component={Link} component={Link}
className={permissionButtonClass} className={permissionButtonClass}

View File

@ -139,7 +139,7 @@ const ProjectListNew = () => {
tooltip={createButtonData.title} tooltip={createButtonData.title}
disabled={createButtonData.disabled} disabled={createButtonData.disabled}
> >
Add new project New project
</ResponsiveButton> </ResponsiveButton>
} }
/> />

View File

@ -72,7 +72,6 @@ export const StrategiesList = () => {
data-test={ADD_NEW_STRATEGY_ID} data-test={ADD_NEW_STRATEGY_ID}
onClick={() => history.push('/strategies/create')} onClick={() => history.push('/strategies/create')}
permission={CREATE_STRATEGY} permission={CREATE_STRATEGY}
tooltip={'Add new strategy'}
> >
<Add /> <Add />
</PermissionIconButton> </PermissionIconButton>
@ -83,9 +82,8 @@ export const StrategiesList = () => {
color="primary" color="primary"
permission={CREATE_STRATEGY} permission={CREATE_STRATEGY}
data-test={ADD_NEW_STRATEGY_ID} data-test={ADD_NEW_STRATEGY_ID}
tooltip={'Add new strategy'}
> >
Add new strategy New strategy
</PermissionButton> </PermissionButton>
} }
/> />
@ -168,7 +166,6 @@ export const StrategiesList = () => {
<PermissionIconButton <PermissionIconButton
onClick={() => onReactivateStrategy(strategy)} onClick={() => onReactivateStrategy(strategy)}
permission={UPDATE_STRATEGY} permission={UPDATE_STRATEGY}
tooltip={'Reactivate activation strategy'}
> >
<VisibilityOff /> <VisibilityOff />
</PermissionIconButton> </PermissionIconButton>
@ -208,7 +205,6 @@ export const StrategiesList = () => {
<PermissionIconButton <PermissionIconButton
onClick={() => onDeleteStrategy(strategy)} onClick={() => onDeleteStrategy(strategy)}
permission={DELETE_STRATEGY} permission={DELETE_STRATEGY}
tooltip={'Delete strategy'}
> >
<Delete /> <Delete />
</PermissionIconButton> </PermissionIconButton>

View File

@ -178,7 +178,7 @@ export const StrategyForm = ({ editMode, strategy }: IStrategyFormProps) => {
color="primary" color="primary"
style={{ display: 'block' }} style={{ display: 'block' }}
> >
Update Save
</Button> </Button>
} }
elseShow={ elseShow={

View File

@ -38,7 +38,7 @@ exports[`renders correctly with one strategy 1`] = `
onMouseOver={[Function]} onMouseOver={[Function]}
onTouchEnd={[Function]} onTouchEnd={[Function]}
onTouchStart={[Function]} onTouchStart={[Function]}
title="Add new strategy" title=""
> >
<button <button
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary" className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary"
@ -62,7 +62,7 @@ exports[`renders correctly with one strategy 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Add new strategy New strategy
<span <span
className="MuiButton-endIcon MuiButton-iconSizeMedium" className="MuiButton-endIcon MuiButton-iconSizeMedium"
/> />
@ -135,7 +135,7 @@ exports[`renders correctly with one strategy 1`] = `
onMouseOver={[Function]} onMouseOver={[Function]}
onTouchEnd={[Function]} onTouchEnd={[Function]}
onTouchStart={[Function]} onTouchStart={[Function]}
title="Deprecate activation strategy" title=""
> >
<button <button
className="MuiButtonBase-root MuiIconButton-root" className="MuiButtonBase-root MuiIconButton-root"
@ -263,7 +263,7 @@ exports[`renders correctly with one strategy without permissions 1`] = `
onMouseOver={[Function]} onMouseOver={[Function]}
onTouchEnd={[Function]} onTouchEnd={[Function]}
onTouchStart={[Function]} onTouchStart={[Function]}
title="Add new strategy" title=""
> >
<button <button
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary" className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary"
@ -287,7 +287,7 @@ exports[`renders correctly with one strategy without permissions 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Add new strategy New strategy
<span <span
className="MuiButton-endIcon MuiButton-iconSizeMedium" className="MuiButton-endIcon MuiButton-iconSizeMedium"
/> />
@ -360,7 +360,7 @@ exports[`renders correctly with one strategy without permissions 1`] = `
onMouseOver={[Function]} onMouseOver={[Function]}
onTouchEnd={[Function]} onTouchEnd={[Function]}
onTouchStart={[Function]} onTouchStart={[Function]}
title="Deprecate activation strategy" title=""
> >
<button <button
className="MuiButtonBase-root MuiIconButton-root" className="MuiButtonBase-root MuiIconButton-root"

View File

@ -76,7 +76,7 @@ const EditTagType = () => {
clearErrors={clearErrors} clearErrors={clearErrors}
> >
<PermissionButton permission={UPDATE_TAG_TYPE} type="submit"> <PermissionButton permission={UPDATE_TAG_TYPE} type="submit">
Edit type Save
</PermissionButton> </PermissionButton>
</TagForm> </TagForm>
</FormTemplate> </FormTemplate>

View File

@ -81,7 +81,7 @@ export const TagTypeList = () => {
history.push('/tag-types/create') history.push('/tag-types/create')
} }
> >
Add new tag type New tag type
</Button> </Button>
} }
/> />

View File

@ -50,7 +50,7 @@ exports[`renders a list with elements correctly 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Add new tag type New tag type
</span> </span>
<span <span
className="MuiTouchRipple-root" className="MuiTouchRipple-root"
@ -126,7 +126,7 @@ exports[`renders an empty list correctly 1`] = `
<span <span
className="MuiButton-label" className="MuiButton-label"
> >
Add new tag type New tag type
</span> </span>
</button> </button>
</div> </div>