Skip to content

Commit

Permalink
chore: Update copy from Editor to Member
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 30, 2024
1 parent e65e434 commit 9c5c17b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export const TeamMembers = () => {

return (
<Container maxWidth="contentWrap">
<SettingsSection data-testid="team-editors">
<SettingsSection data-testid="team-members">
<Typography variant="h2" component="h3" gutterBottom>
Team editors
Team members
</Typography>
<Typography variant="body1">
Editors have access to edit your services.
Editors have access to edit your services, whilst viewers can only browse your services.
</Typography>
<MembersTable
members={activeMembers}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Chip from "@mui/material/Chip";
import Dialog from "@mui/material/Dialog";
import { styled } from "@mui/material/styles";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import { Role, UserRole } from "@opensystemslab/planx-core/types";
import { Role } from "@opensystemslab/planx-core/types";
import { AddButton } from "pages/Team";
import React, { useState } from "react";
import Permission from "ui/editor/Permission";

import { StyledAvatar, StyledTableRow } from "./../styles";
import { ActionType, MembersTableProps, TeamMember } from "./../types";
import { EditorUpsertModal } from "./EditorUpsertModal";
import { RemoveUserModal } from "./RemoveUserModal";
import { UserUpsertModal } from "./UserUpsertModal";

const TableRowButton = styled(Button)(({ theme }) => ({
textDecoration: "underline",
Expand All @@ -28,12 +27,14 @@ const TableRowButton = styled(Button)(({ theme }) => ({
backgroundColor: theme.palette.action.hover,
},
}));

const EditUserButton = styled(TableRowButton)(({ theme }) => ({
color: theme.palette.primary.light,
"&:hover": {
color: theme.palette.primary.dark,
},
}));

const RemoveUserButton = styled(TableRowButton)(({ theme }) => ({
color: theme.palette.text.secondary,
"&:hover": {
Expand Down Expand Up @@ -64,11 +65,13 @@ export const MembersTable = ({
setShowModal(true);
setInitialValues(member);
};

const removeUser = (member: TeamMember) => {
setActionType("remove");
setShowModal(true);
setInitialValues(member);
};

const addUser = () => {
setActionType("add");
setShowModal(true);
Expand Down Expand Up @@ -98,14 +101,14 @@ export const MembersTable = ({
addUser();
}}
>
Add a new editor
Add a new member
</AddButton>
</TableCell>
</TableRow>
)}
</Table>
{showModal && (
<EditorUpsertModal
<UserUpsertModal
showModal={showModal}
setShowModal={setShowModal}
initialValues={initialValues}
Expand Down Expand Up @@ -139,9 +142,9 @@ export const MembersTable = ({
</StyledTableRow>
</TableHead>
<TableBody
data-testid={`members-table${showAddMemberButton && "-add-editor"}`}
data-testid={`members-table${showAddMemberButton && "-add-member"}`}
>
{members.map((member, i) => (
{members.map((member) => (
<StyledTableRow key={member.id}>
<TableCell
sx={{
Expand Down Expand Up @@ -205,7 +208,7 @@ export const MembersTable = ({
addUser();
}}
>
Add a new editor
Add a new member
</AddButton>
</TableCell>
</TableRow>
Expand All @@ -223,7 +226,7 @@ export const MembersTable = ({
actionType={actionType}
/>
) : (
<EditorUpsertModal
<UserUpsertModal
setShowModal={setShowModal}
showModal={showModal}
initialValues={initialValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import ErrorWrapper from "ui/shared/ErrorWrapper";
import Input from "ui/shared/Input/Input";

import {
AddNewEditorErrors,
AddNewMemberErrors,
isUserAlreadyExistsError,
} from "../errors/addNewEditorErrors";
import { upsertEditorSchema } from "../formSchema";
import { upsertMemberSchema } from "../formSchema";
import { createAndAddUserToTeam } from "../queries/createAndAddUserToTeam";
import { updateTeamMember } from "../queries/updateUser";
import { SettingsDialog } from "../styles";
Expand All @@ -28,7 +28,7 @@ import {

export const DEMO_TEAM_ID = 32;

export const EditorUpsertModal = ({
export const UserUpsertModal = ({
setShowModal,
showModal,
initialValues,
Expand Down Expand Up @@ -117,7 +117,7 @@ export const EditorUpsertModal = ({
// Users within the Demo team are granted a role with a restricted permission set
role: isDemoTeam ? "demoUser" : "teamEditor",
},
validationSchema: upsertEditorSchema,
validationSchema: upsertMemberSchema,
onSubmit: handleSubmit,
});

Expand All @@ -136,7 +136,7 @@ export const EditorUpsertModal = ({
>
<Box sx={{ mt: 1, mb: 4 }}>
<Typography variant="h3" component="h2" id="dialog-heading">
Add a new editor
Add a new { isDemoTeam ? "demo user" : "editor" }
</Typography>
</Box>
<InputGroup flowSpacing>
Expand Down Expand Up @@ -191,7 +191,7 @@ export const EditorUpsertModal = ({
<ErrorWrapper
error={
showUserAlreadyExistsError
? AddNewEditorErrors.USER_ALREADY_EXISTS.errorMessage
? AddNewMemberErrors.USER_ALREADY_EXISTS.errorMessage
: undefined
}
>
Expand Down

0 comments on commit 9c5c17b

Please sign in to comment.