mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
refactor: change resourceCreateButton and SaveChangesButton name
This commit is contained in:
parent
af6542a291
commit
5371e15333
@ -1,7 +1,7 @@
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import ApiTokenForm from '../ApiTokenForm/ApiTokenForm';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import useApiTokensApi from 'hooks/api/actions/useApiTokensApi/useApiTokensApi';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import useToast from 'hooks/useToast';
|
||||
@ -95,10 +95,7 @@ export const CreateApiToken = () => {
|
||||
mode="Create"
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
permission={ADMIN}
|
||||
ressourceName={'token'}
|
||||
/>
|
||||
<CreateButton name="token" permission={ADMIN} />
|
||||
</ApiTokenForm>
|
||||
<ConfirmToken
|
||||
open={showConfirm}
|
||||
|
@ -5,7 +5,7 @@ import ProjectRoleForm from '../ProjectRoleForm/ProjectRoleForm';
|
||||
import useProjectRoleForm from '../hooks/useProjectRoleForm';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import useToast from 'hooks/useToast';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import { ADMIN } from 'component/providers/AccessProvider/permissions';
|
||||
|
||||
const CreateProjectRole = () => {
|
||||
@ -95,10 +95,7 @@ const CreateProjectRole = () => {
|
||||
validateNameUniqueness={validateNameUniqueness}
|
||||
getRoleKey={getRoleKey}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
ressourceName={'role'}
|
||||
permission={ADMIN}
|
||||
/>
|
||||
<CreateButton name="role" permission={ADMIN} />
|
||||
</ProjectRoleForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useEffect } from 'react';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import { ADMIN } from 'component/providers/AccessProvider/permissions';
|
||||
import useProjectRolesApi from 'hooks/api/actions/useProjectRolesApi/useProjectRolesApi';
|
||||
import useProjectRole from 'hooks/api/getters/useProjectRole/useProjectRole';
|
||||
@ -121,7 +121,7 @@ to resources within a project"
|
||||
clearErrors={clearErrors}
|
||||
getRoleKey={getRoleKey}
|
||||
>
|
||||
<SaveChangesButton permission={ADMIN} />
|
||||
<UpdateButton permission={ADMIN} />
|
||||
</ProjectRoleForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -8,7 +8,7 @@ import useAddUserForm from '../hooks/useAddUserForm';
|
||||
import ConfirmUserAdded from '../ConfirmUserAdded/ConfirmUserAdded';
|
||||
import { useState } from 'react';
|
||||
import { scrollToTop } from '../../../common/util';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import { ADMIN } from 'component/providers/AccessProvider/permissions';
|
||||
|
||||
const CreateUser = () => {
|
||||
@ -97,10 +97,7 @@ const CreateUser = () => {
|
||||
setRootRole={setRootRole}
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
permission={ADMIN}
|
||||
ressourceName={'user'}
|
||||
/>
|
||||
<CreateButton name="user" permission={ADMIN} />
|
||||
</UserForm>
|
||||
<ConfirmUserAdded
|
||||
open={showConfirm}
|
||||
|
@ -3,7 +3,7 @@ import UserForm from '../UserForm/UserForm';
|
||||
import useAddUserForm from '../hooks/useAddUserForm';
|
||||
import { scrollToTop } from '../../../common/util';
|
||||
import { useEffect } from 'react';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { ADMIN } from 'component/providers/AccessProvider/permissions';
|
||||
import { EDIT } from 'constants/misc';
|
||||
@ -94,7 +94,7 @@ const EditUser = () => {
|
||||
clearErrors={clearErrors}
|
||||
mode={EDIT}
|
||||
>
|
||||
<SaveChangesButton permission={ADMIN} />
|
||||
<UpdateButton permission={ADMIN} />
|
||||
</UserForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
19
frontend/src/component/common/CreateButton/CreateButton.tsx
Normal file
19
frontend/src/component/common/CreateButton/CreateButton.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
import PermissionButton, {
|
||||
IPermissionButtonProps,
|
||||
} from '../PermissionButton/PermissionButton';
|
||||
|
||||
interface ICreateButtonProps extends IPermissionButtonProps {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const CreateButton = ({
|
||||
name,
|
||||
permission,
|
||||
...rest
|
||||
}: ICreateButtonProps) => {
|
||||
return (
|
||||
<PermissionButton permission={permission} type="submit" {...rest}>
|
||||
Create {name}
|
||||
</PermissionButton>
|
||||
);
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
import { Button, Tooltip } from '@material-ui/core';
|
||||
import { Lock } from '@material-ui/icons';
|
||||
import AccessContext from 'contexts/AccessContext';
|
||||
import { useContext } from 'react';
|
||||
import AccessContext from '../../../contexts/AccessContext';
|
||||
import ConditionallyRender from '../ConditionallyRender';
|
||||
|
||||
export interface IPermissionIconButtonProps
|
||||
export interface IPermissionButtonProps
|
||||
extends React.HTMLProps<HTMLButtonElement> {
|
||||
permission: string | string[];
|
||||
tooltip?: string;
|
||||
@ -14,7 +14,7 @@ export interface IPermissionIconButtonProps
|
||||
environmentId?: string;
|
||||
}
|
||||
|
||||
const PermissionButton: React.FC<IPermissionIconButtonProps> = ({
|
||||
const PermissionButton: React.FC<IPermissionButtonProps> = ({
|
||||
permission,
|
||||
tooltip = 'Click to perform action',
|
||||
onClick,
|
||||
|
@ -1,18 +0,0 @@
|
||||
import PermissionButton from '../PermissionButton/PermissionButton';
|
||||
|
||||
interface IResourceCreationButtonProps {
|
||||
ressourceName: string;
|
||||
permission: string;
|
||||
}
|
||||
|
||||
export const ResourceCreationButton = ({
|
||||
ressourceName,
|
||||
permission,
|
||||
...rest
|
||||
}: IResourceCreationButtonProps) => {
|
||||
return (
|
||||
<PermissionButton permission={permission} type="submit" {...rest}>
|
||||
Create {ressourceName}
|
||||
</PermissionButton>
|
||||
);
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
import PermissionButton from '../PermissionButton/PermissionButton';
|
||||
|
||||
interface ISaveChangesButtonProps {
|
||||
permission: string;
|
||||
}
|
||||
|
||||
export const SaveChangesButton = ({
|
||||
permission,
|
||||
...rest
|
||||
}: ISaveChangesButtonProps) => {
|
||||
return (
|
||||
<PermissionButton permission={permission} type="submit" {...rest}>
|
||||
Save
|
||||
</PermissionButton>
|
||||
);
|
||||
};
|
13
frontend/src/component/common/UpdateButton/UpdateButton.tsx
Normal file
13
frontend/src/component/common/UpdateButton/UpdateButton.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import PermissionButton, {
|
||||
IPermissionButtonProps,
|
||||
} from '../PermissionButton/PermissionButton';
|
||||
|
||||
interface IUpdateButtonProps extends IPermissionButtonProps {}
|
||||
|
||||
export const UpdateButton = ({ permission, ...rest }: IUpdateButtonProps) => {
|
||||
return (
|
||||
<PermissionButton permission={permission} type="submit" {...rest}>
|
||||
Save
|
||||
</PermissionButton>
|
||||
);
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import useContextForm from '../hooks/useContextForm';
|
||||
import ContextForm from '../ContextForm/ContextForm';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import useToast from 'hooks/useToast';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { CREATE_CONTEXT_FIELD } from 'component/providers/AccessProvider/permissions';
|
||||
@ -91,9 +91,9 @@ const CreateContext = () => {
|
||||
setErrors={setErrors}
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
<CreateButton
|
||||
name="context"
|
||||
permission={CREATE_CONTEXT_FIELD}
|
||||
ressourceName={'context'}
|
||||
/>
|
||||
</ContextForm>
|
||||
</FormTemplate>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import { UPDATE_CONTEXT_FIELD } from 'component/providers/AccessProvider/permissions';
|
||||
import useContextsApi from 'hooks/api/actions/useContextsApi/useContextsApi';
|
||||
import useContext from 'hooks/api/getters/useContext/useContext';
|
||||
@ -103,7 +103,7 @@ const EditContext = () => {
|
||||
setErrors={setErrors}
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<SaveChangesButton permission={UPDATE_CONTEXT_FIELD} />
|
||||
<UpdateButton permission={UPDATE_CONTEXT_FIELD} />
|
||||
</ContextForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -4,7 +4,7 @@ import EnvironmentForm from '../EnvironmentForm/EnvironmentForm';
|
||||
import FormTemplate from '../../common/FormTemplate/FormTemplate';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
import { Button } from '@material-ui/core';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import useEnvironmentApi from 'hooks/api/actions/useEnvironmentApi/useEnvironmentApi';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import useToast from 'hooks/useToast';
|
||||
@ -100,10 +100,7 @@ const CreateEnvironment = () => {
|
||||
mode="Create"
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
ressourceName="environment"
|
||||
permission={ADMIN}
|
||||
/>
|
||||
<CreateButton name="environment" permission={ADMIN} />
|
||||
</EnvironmentForm>
|
||||
</FormTemplate>
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import useEnvironmentApi from 'hooks/api/actions/useEnvironmentApi/useEnvironmentApi';
|
||||
import useEnvironment from 'hooks/api/getters/useEnvironment/useEnvironment';
|
||||
import useProjectRolePermissions from 'hooks/api/getters/useProjectRolePermissions/useProjectRolePermissions';
|
||||
@ -85,7 +85,7 @@ const EditEnvironment = () => {
|
||||
errors={errors}
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<SaveChangesButton permission={ADMIN} />
|
||||
<UpdateButton permission={ADMIN} />
|
||||
</EnvironmentForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -7,7 +7,7 @@ import useToast from 'hooks/useToast';
|
||||
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
|
||||
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
||||
import { useContext } from 'react';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import UIContext from 'contexts/UIContext';
|
||||
import { CF_CREATE_BTN_ID } from 'testIds';
|
||||
|
||||
@ -99,8 +99,8 @@ const CreateFeature = () => {
|
||||
mode="Create"
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
ressourceName={'Feature'}
|
||||
<CreateButton
|
||||
name="Feature"
|
||||
permission={CREATE_FEATURE}
|
||||
projectId={project}
|
||||
data-test={CF_CREATE_BTN_ID}
|
||||
|
@ -3,7 +3,7 @@ import { useHistory, useParams } from 'react-router-dom';
|
||||
import FeatureForm from '../FeatureForm/FeatureForm';
|
||||
import useFeatureForm from '../hooks/useFeatureForm';
|
||||
import * as jsonpatch from 'fast-json-patch';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
||||
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
|
||||
import useFeature from 'hooks/api/getters/useFeature/useFeature';
|
||||
@ -101,10 +101,7 @@ const EditFeature = () => {
|
||||
mode="Edit"
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<SaveChangesButton
|
||||
permission={UPDATE_FEATURE}
|
||||
projectId={project}
|
||||
/>
|
||||
<UpdateButton permission={UPDATE_FEATURE} projectId={project} />
|
||||
</FeatureForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import ProjectForm from '../ProjectForm/ProjectForm';
|
||||
import useProjectForm from '../hooks/useProjectForm';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { CREATE_PROJECT } from 'component/providers/AccessProvider/permissions';
|
||||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||
@ -89,10 +89,7 @@ const CreateProject = () => {
|
||||
clearErrors={clearErrors}
|
||||
validateIdUniqueness={validateIdUniqueness}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
ressourceName="project"
|
||||
permission={CREATE_PROJECT}
|
||||
/>
|
||||
<CreateButton name="project" permission={CREATE_PROJECT} />
|
||||
</ProjectForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useHistory, useParams } from 'react-router-dom';
|
||||
import ProjectForm from '../ProjectForm/ProjectForm';
|
||||
import useProjectForm from '../hooks/useProjectForm';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { UPDATE_PROJECT } from 'component/providers/AccessProvider/permissions';
|
||||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
|
||||
@ -90,7 +90,7 @@ const EditProject = () => {
|
||||
clearErrors={clearErrors}
|
||||
validateIdUniqueness={validateIdUniqueness}
|
||||
>
|
||||
<SaveChangesButton permission={UPDATE_PROJECT} />
|
||||
<UpdateButton permission={UPDATE_PROJECT} />
|
||||
</ProjectForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import useTagTypeForm from '../TagTypeForm/useTagTypeForm';
|
||||
import TagTypeForm from '../TagTypeForm/TagTypeForm';
|
||||
import { ResourceCreationButton } from 'component/common/ResourceCreationButton/ResourceCreationButton';
|
||||
import { CreateButton } from 'component/common/CreateButton/CreateButton';
|
||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||
import { UPDATE_TAG_TYPE } from 'component/providers/AccessProvider/permissions';
|
||||
import useTagTypesApi from 'hooks/api/actions/useTagTypesApi/useTagTypesApi';
|
||||
@ -77,10 +77,7 @@ const CreateTagType = () => {
|
||||
clearErrors={clearErrors}
|
||||
validateNameUniqueness={validateNameUniqueness}
|
||||
>
|
||||
<ResourceCreationButton
|
||||
ressourceName="type"
|
||||
permission={UPDATE_TAG_TYPE}
|
||||
/>
|
||||
<CreateButton name="type" permission={UPDATE_TAG_TYPE} />
|
||||
</TagTypeForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
@ -2,7 +2,7 @@ import { useHistory, useParams } from 'react-router-dom';
|
||||
import { UPDATE_TAG_TYPE } from '../../providers/AccessProvider/permissions';
|
||||
import useTagTypeForm from '../TagTypeForm/useTagTypeForm';
|
||||
import TagForm from '../TagTypeForm/TagTypeForm';
|
||||
import { SaveChangesButton } from 'component/common/SaveChangesButton/SaveChangesButton';
|
||||
import { UpdateButton } from 'component/common/UpdateButton/UpdateButton';
|
||||
import useTagTypesApi from 'hooks/api/actions/useTagTypesApi/useTagTypesApi';
|
||||
import useTagType from 'hooks/api/getters/useTagType/useTagType';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
@ -74,7 +74,7 @@ const EditTagType = () => {
|
||||
mode="Edit"
|
||||
clearErrors={clearErrors}
|
||||
>
|
||||
<SaveChangesButton permission={UPDATE_TAG_TYPE} />
|
||||
<UpdateButton permission={UPDATE_TAG_TYPE} />
|
||||
</TagForm>
|
||||
</FormTemplate>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user