diff --git a/frontend/src/component/admin/api-token/CreateApiToken/CreateApiToken.tsx b/frontend/src/component/admin/api-token/CreateApiToken/CreateApiToken.tsx index ce66a5388e..6d693005fe 100644 --- a/frontend/src/component/admin/api-token/CreateApiToken/CreateApiToken.tsx +++ b/frontend/src/component/admin/api-token/CreateApiToken/CreateApiToken.tsx @@ -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} > - + { @@ -95,10 +95,7 @@ const CreateProjectRole = () => { validateNameUniqueness={validateNameUniqueness} getRoleKey={getRoleKey} > - + ); diff --git a/frontend/src/component/admin/project-roles/EditProjectRole/EditProjectRole.tsx b/frontend/src/component/admin/project-roles/EditProjectRole/EditProjectRole.tsx index d5071139d0..3bcdef9960 100644 --- a/frontend/src/component/admin/project-roles/EditProjectRole/EditProjectRole.tsx +++ b/frontend/src/component/admin/project-roles/EditProjectRole/EditProjectRole.tsx @@ -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} > - + ); diff --git a/frontend/src/component/admin/users/CreateUser/CreateUser.tsx b/frontend/src/component/admin/users/CreateUser/CreateUser.tsx index 9270eea424..e64a08b7d7 100644 --- a/frontend/src/component/admin/users/CreateUser/CreateUser.tsx +++ b/frontend/src/component/admin/users/CreateUser/CreateUser.tsx @@ -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} > - + { clearErrors={clearErrors} mode={EDIT} > - + ); diff --git a/frontend/src/component/common/CreateButton/CreateButton.tsx b/frontend/src/component/common/CreateButton/CreateButton.tsx new file mode 100644 index 0000000000..87f9f45464 --- /dev/null +++ b/frontend/src/component/common/CreateButton/CreateButton.tsx @@ -0,0 +1,19 @@ +import PermissionButton, { + IPermissionButtonProps, +} from '../PermissionButton/PermissionButton'; + +interface ICreateButtonProps extends IPermissionButtonProps { + name: string; +} + +export const CreateButton = ({ + name, + permission, + ...rest +}: ICreateButtonProps) => { + return ( + + Create {name} + + ); +}; diff --git a/frontend/src/component/common/PermissionButton/PermissionButton.tsx b/frontend/src/component/common/PermissionButton/PermissionButton.tsx index 161a2ee05c..0df5a0c319 100644 --- a/frontend/src/component/common/PermissionButton/PermissionButton.tsx +++ b/frontend/src/component/common/PermissionButton/PermissionButton.tsx @@ -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 { permission: string | string[]; tooltip?: string; @@ -14,7 +14,7 @@ export interface IPermissionIconButtonProps environmentId?: string; } -const PermissionButton: React.FC = ({ +const PermissionButton: React.FC = ({ permission, tooltip = 'Click to perform action', onClick, diff --git a/frontend/src/component/common/ResourceCreationButton/ResourceCreationButton.tsx b/frontend/src/component/common/ResourceCreationButton/ResourceCreationButton.tsx deleted file mode 100644 index 4f49b10eb1..0000000000 --- a/frontend/src/component/common/ResourceCreationButton/ResourceCreationButton.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import PermissionButton from '../PermissionButton/PermissionButton'; - -interface IResourceCreationButtonProps { - ressourceName: string; - permission: string; -} - -export const ResourceCreationButton = ({ - ressourceName, - permission, - ...rest -}: IResourceCreationButtonProps) => { - return ( - - Create {ressourceName} - - ); -}; diff --git a/frontend/src/component/common/SaveChangesButton/SaveChangesButton.tsx b/frontend/src/component/common/SaveChangesButton/SaveChangesButton.tsx deleted file mode 100644 index f314d5a57d..0000000000 --- a/frontend/src/component/common/SaveChangesButton/SaveChangesButton.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import PermissionButton from '../PermissionButton/PermissionButton'; - -interface ISaveChangesButtonProps { - permission: string; -} - -export const SaveChangesButton = ({ - permission, - ...rest -}: ISaveChangesButtonProps) => { - return ( - - Save - - ); -}; diff --git a/frontend/src/component/common/UpdateButton/UpdateButton.tsx b/frontend/src/component/common/UpdateButton/UpdateButton.tsx new file mode 100644 index 0000000000..27c1808241 --- /dev/null +++ b/frontend/src/component/common/UpdateButton/UpdateButton.tsx @@ -0,0 +1,13 @@ +import PermissionButton, { + IPermissionButtonProps, +} from '../PermissionButton/PermissionButton'; + +interface IUpdateButtonProps extends IPermissionButtonProps {} + +export const UpdateButton = ({ permission, ...rest }: IUpdateButtonProps) => { + return ( + + Save + + ); +}; diff --git a/frontend/src/component/context/CreateContext/CreateContext.tsx b/frontend/src/component/context/CreateContext/CreateContext.tsx index 28de67b0d6..3b10300a58 100644 --- a/frontend/src/component/context/CreateContext/CreateContext.tsx +++ b/frontend/src/component/context/CreateContext/CreateContext.tsx @@ -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} > - diff --git a/frontend/src/component/context/EditContext/EditContext.tsx b/frontend/src/component/context/EditContext/EditContext.tsx index 7150dbd5ca..03c3883e49 100644 --- a/frontend/src/component/context/EditContext/EditContext.tsx +++ b/frontend/src/component/context/EditContext/EditContext.tsx @@ -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} > - + ); diff --git a/frontend/src/component/environments/CreateEnvironment/CreateEnvironment.tsx b/frontend/src/component/environments/CreateEnvironment/CreateEnvironment.tsx index ffabb7b9cf..e2f8d7eb4a 100644 --- a/frontend/src/component/environments/CreateEnvironment/CreateEnvironment.tsx +++ b/frontend/src/component/environments/CreateEnvironment/CreateEnvironment.tsx @@ -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} > - + } diff --git a/frontend/src/component/environments/EditEnvironment/EditEnvironment.tsx b/frontend/src/component/environments/EditEnvironment/EditEnvironment.tsx index 431763ec1e..84ce834b3b 100644 --- a/frontend/src/component/environments/EditEnvironment/EditEnvironment.tsx +++ b/frontend/src/component/environments/EditEnvironment/EditEnvironment.tsx @@ -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} > - + ); diff --git a/frontend/src/component/feature/CreateFeature/CreateFeature.tsx b/frontend/src/component/feature/CreateFeature/CreateFeature.tsx index 5cc637c635..85ecf3ca7a 100644 --- a/frontend/src/component/feature/CreateFeature/CreateFeature.tsx +++ b/frontend/src/component/feature/CreateFeature/CreateFeature.tsx @@ -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} > - { mode="Edit" clearErrors={clearErrors} > - + ); diff --git a/frontend/src/component/project/Project/CreateProject/CreateProject.tsx b/frontend/src/component/project/Project/CreateProject/CreateProject.tsx index d0ab5977be..7dfff9afc8 100644 --- a/frontend/src/component/project/Project/CreateProject/CreateProject.tsx +++ b/frontend/src/component/project/Project/CreateProject/CreateProject.tsx @@ -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} > - + ); diff --git a/frontend/src/component/project/Project/EditProject/EditProject.tsx b/frontend/src/component/project/Project/EditProject/EditProject.tsx index fa372ba814..5f1aae32a4 100644 --- a/frontend/src/component/project/Project/EditProject/EditProject.tsx +++ b/frontend/src/component/project/Project/EditProject/EditProject.tsx @@ -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} > - + ); diff --git a/frontend/src/component/tags/CreateTagType/CreateTagType.tsx b/frontend/src/component/tags/CreateTagType/CreateTagType.tsx index ff1893eb7f..b29f9b576f 100644 --- a/frontend/src/component/tags/CreateTagType/CreateTagType.tsx +++ b/frontend/src/component/tags/CreateTagType/CreateTagType.tsx @@ -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} > - + ); diff --git a/frontend/src/component/tags/EditTagType/EditTagType.tsx b/frontend/src/component/tags/EditTagType/EditTagType.tsx index f084df76f7..5cac7d6730 100644 --- a/frontend/src/component/tags/EditTagType/EditTagType.tsx +++ b/frontend/src/component/tags/EditTagType/EditTagType.tsx @@ -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} > - + );