Skip to content

Commit

Permalink
[ProjectSettings] Refactor with category tabs (#2569)
Browse files Browse the repository at this point in the history
Also:
* Move ProjectUsers out of ProjectSettings folder
* Don't show tab for read-only Schedule if no dates have been added
  • Loading branch information
imnasnainaec authored Sep 19, 2023
1 parent 84b1645 commit e75fe85
Show file tree
Hide file tree
Showing 24 changed files with 563 additions and 261 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/crypto-js": "^4.1.2",
"@types/css-mediaquery": "^0.1.2",
"@types/jest": "^29.5.5",
"@types/loadable__component": "^5.13.4",
"@types/node": "^20.5.1",
Expand All @@ -105,6 +106,7 @@
"@types/validator": "^13.11.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.3.0",
"css-mediaquery": "^0.1.2",
"eslint": "^8.44.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
Expand Down
10 changes: 9 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
},
"projectSettings": {
"project": "Project:",
"tab": {
"basic": "Basic Settings",
"export": "Export",
"importExport": "Import/Export",
"languages": "Languages",
"schedule": "Schedule",
"users": "Users"
},
"language": {
"header": "Language",
"vernacular": "Vernacular",
Expand All @@ -144,7 +152,7 @@
"analysisLanguage": "Analysis Language",
"semanticDomains": "Semantic Domains",
"semanticDomainsDefault": "(Default to browser language)",
"languages": "Languages",
"languages": "Project Languages",
"bcp47": "BCP 47 Code",
"name": "Name",
"font": "Font",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ interface BaseSettingsProps {
body: ReactNode;
}

export default function BaseSettingsComponent(
props: BaseSettingsProps
): ReactElement {
export default function BaseSettings(props: BaseSettingsProps): ReactElement {
const [isVisible, setIsVisible] = useState(true);

const toggleVisibility = (): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Button } from "@mui/material";
import { ButtonProps } from "@mui/material/Button";
import React, { useState } from "react";
import { useState } from "react";
import { useTranslation } from "react-i18next";

import { archiveProject, restoreProject } from "backend";
import { ButtonConfirmation } from "components/Dialogs";
import { themeColors } from "types/theme";

interface ProjectButtonWithConfirmationProps {
interface ProjectArchiveProps extends ButtonProps {
archive?: boolean;
projectId: string;
updateParent: () => void | Promise<void>;
Expand All @@ -17,9 +17,7 @@ interface ProjectButtonWithConfirmationProps {
/**
* Button for archiving/restoring project (changing isActive)
*/
export default function ProjectButtonWithConfirmation(
props: ButtonProps & ProjectButtonWithConfirmationProps
) {
export default function ProjectArchive(props: ProjectArchiveProps) {
const [open, setOpen] = useState(false);
const { t } = useTranslation();

Expand All @@ -41,7 +39,7 @@ export default function ProjectButtonWithConfirmation(
}

return (
<React.Fragment>
<>
<Button
variant="contained"
color={props.warn ? "secondary" : "primary"}
Expand All @@ -68,6 +66,6 @@ export default function ProjectButtonWithConfirmation(
props.archive ? "archive" : "restore"
}-confirm`}
/>
</React.Fragment>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IconButton } from "@mui/material";
import { Button, IconButton } from "@mui/material";
import renderer from "react-test-renderer";

import "tests/reactI18nextMock";

import { Project } from "api/models";
import ProjectSchedule from "components/ProjectSettings/ProjectSchedule/ProjectSchedule";
import ProjectSchedule from "components/ProjectSettings/ProjectSchedule";
import { newProject } from "types/project";

const mockUpdateProject = jest.fn();
Expand Down Expand Up @@ -39,6 +39,7 @@ describe("ProjectSchedule", () => {

it("renders readOnly with no buttons", async () => {
await renderProjSched(undefined, true);
expect(projectMaster.root.findAllByType(Button)).toHaveLength(0);
expect(projectMaster.root.findAllByType(IconButton)).toHaveLength(0);
});
});
Loading

0 comments on commit e75fe85

Please sign in to comment.