diff --git a/components/frontend/src/header_footer/buttons/AppBarbutton.jsx b/components/frontend/src/header_footer/buttons/AppBarbutton.jsx new file mode 100644 index 0000000000..3a7a84f8c5 --- /dev/null +++ b/components/frontend/src/header_footer/buttons/AppBarbutton.jsx @@ -0,0 +1,35 @@ +import { Button, Tooltip } from "@mui/material" +import { grey } from "@mui/material/colors" +import { bool, element, func, object, string } from "prop-types" + +import { childrenPropType } from "../../sharedPropTypes" + +export function AppBarButton({ children, disabled, loading, onClick, startIcon, sx, tooltip }) { + return ( + + + + + + ) +} +AppBarButton.propTypes = { + children: childrenPropType, + disabled: bool, + loading: bool, + onClick: func, + startIcon: element, + sx: object, + tooltip: string, +} diff --git a/components/frontend/src/header_footer/buttons/CollapseButton.jsx b/components/frontend/src/header_footer/buttons/CollapseButton.jsx index e3b21eedbf..631f4e99fa 100644 --- a/components/frontend/src/header_footer/buttons/CollapseButton.jsx +++ b/components/frontend/src/header_footer/buttons/CollapseButton.jsx @@ -1,23 +1,19 @@ import UnfoldLessIcon from "@mui/icons-material/UnfoldLess" -import { Button, Tooltip } from "@mui/material" import { stringsURLSearchQueryPropType } from "../../sharedPropTypes" +import { AppBarButton } from "./AppBarbutton" + export function CollapseButton({ expandedItems }) { return ( - - - - - + expandedItems.reset()} + startIcon={} + tooltip={"Collapse all headers and metrics"} + > + Collapse all + ) } CollapseButton.propTypes = { diff --git a/components/frontend/src/header_footer/buttons/CollapseButton.test.jsx b/components/frontend/src/header_footer/buttons/CollapseButton.test.jsx index 2bd044e4b2..d57372a895 100644 --- a/components/frontend/src/header_footer/buttons/CollapseButton.test.jsx +++ b/components/frontend/src/header_footer/buttons/CollapseButton.test.jsx @@ -19,7 +19,7 @@ it("resets the expanded items", () => { const expandedItems = renderHook(() => useExpandedItemsSearchQuery()) expect(expandedItems.result.current.value).toStrictEqual(["tab"]) renderCollapseButton({ expandedItems: expandedItems.result.current }) - fireEvent.click(screen.getByRole("button", { name: "Collapse all" })) + fireEvent.click(screen.getByRole("button", { name: /Collapse all/ })) expandedItems.rerender() expect(expandedItems.result.current.value).toStrictEqual([]) }) @@ -28,7 +28,7 @@ it("doesn't change the expanded items if there are none", () => { const expandedItems = renderHook(() => useExpandedItemsSearchQuery()) expect(expandedItems.result.current.value).toStrictEqual([]) renderCollapseButton({ expandedItems: expandedItems.result.current }) - fireEvent.click(screen.getByRole("button", { name: "Collapse all" })) + fireEvent.click(screen.getByRole("button", { name: /Collapse all/ })) expandedItems.rerender() expect(expandedItems.result.current.value).toStrictEqual([]) }) diff --git a/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.jsx b/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.jsx index d2e1ee345c..8285405988 100644 --- a/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.jsx +++ b/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.jsx @@ -1,5 +1,4 @@ import PictureAsPdf from "@mui/icons-material/PictureAsPdf" -import { Button, Tooltip } from "@mui/material" import { string } from "prop-types" import { useState } from "react" @@ -7,6 +6,8 @@ import { get_report_pdf } from "../../api/report" import { registeredURLSearchParams } from "../../hooks/url_search_query" import { showMessage } from "../../widgets/toast" +import { AppBarButton } from "./AppBarbutton" + function downloadPDF(report_uuid, queryString, callback) { const reportId = report_uuid ? `report-${report_uuid}` : "reports-overview" return get_report_pdf(report_uuid, queryString) @@ -39,25 +40,20 @@ export function DownloadAsPDFButton({ report_uuid }) { const queryString = query.toString() ? "?" + query.toString() : "" query.set("report_url", window.location.origin + window.location.pathname + queryString + window.location.hash) const itemType = report_uuid ? "report" : "reports overview" - const label = `Download ${itemType} as PDF` return ( - - - + { + setLoading(true) + downloadPDF(report_uuid, `?${query.toString()}`, () => { + setLoading(false) + }) + }} + startIcon={} + tooltip={`Generate a PDF version of the ${itemType} as currently displayed. This may take some time.`} + > + Download as PDF + ) } DownloadAsPDFButton.propTypes = { diff --git a/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.test.jsx b/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.test.jsx index bfa434ee02..76d1a1986c 100644 --- a/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.test.jsx +++ b/components/frontend/src/header_footer/buttons/DownloadAsPDFButton.test.jsx @@ -16,12 +16,14 @@ beforeEach(() => { test("DownloadAsPDFButton has the correct label for reports overview", () => { render() - expect(screen.getAllByLabelText(/reports overview as PDF/).length).toBe(1) + // toBe(2) due to 10840-menubar-color-contrast-for-disabled-items + expect(screen.getAllByLabelText(/Generate a PDF version/).length).toBe(2) }) test("DownloadAsPDFButton has the correct label for a report", () => { render() - expect(screen.getAllByLabelText(/report as PDF/).length).toBe(1) + // toBe(2) due to 10840-menubar-color-contrast-for-disabled-items + expect(screen.getAllByLabelText(/Generate a PDF version/).length).toBe(2) }) async function clickDownload(nrClicks = 1) { diff --git a/components/frontend/src/header_footer/buttons/HomeButton.jsx b/components/frontend/src/header_footer/buttons/HomeButton.jsx index f6fc711a33..6de8e5c70d 100644 --- a/components/frontend/src/header_footer/buttons/HomeButton.jsx +++ b/components/frontend/src/header_footer/buttons/HomeButton.jsx @@ -1,25 +1,23 @@ -import { Button, Tooltip, Typography } from "@mui/material" +import { Typography } from "@mui/material" import { bool, func } from "prop-types" +import { AppBarButton } from "./AppBarbutton" + export function HomeButton({ atReportsOverview, openReportsOverview, setSettingsPanelVisible }) { const label = "Go to reports overview" return ( - - - - - + { + setSettingsPanelVisible(false) + openReportsOverview() + }} + startIcon={{label}} + sx={{ textTransform: "none" }} + tooltip={label} + > + Quality-time + ) } HomeButton.propTypes = { diff --git a/components/frontend/src/header_footer/buttons/ResetSettingsButton.jsx b/components/frontend/src/header_footer/buttons/ResetSettingsButton.jsx index fad6c8fea9..94327580e5 100644 --- a/components/frontend/src/header_footer/buttons/ResetSettingsButton.jsx +++ b/components/frontend/src/header_footer/buttons/ResetSettingsButton.jsx @@ -1,28 +1,23 @@ import SettingsBackupRestoreIcon from "@mui/icons-material/SettingsBackupRestore" -import { Button, Tooltip } from "@mui/material" import { bool, func } from "prop-types" import { optionalDatePropType, settingsPropType } from "../../sharedPropTypes" +import { AppBarButton } from "./AppBarbutton" + export function ResetSettingsButton({ atReportsOverview, handleDateChange, reportDate, settings }) { - const label = `Reset ${atReportsOverview ? "reports overview" : "this report's"} settings` return ( - - - - - + { + handleDateChange(null) + settings.reset() + }} + startIcon={} + tooltip={`Reset ${atReportsOverview ? "reports overview" : "this report's"} settings`} + > + Reset settings + ) } ResetSettingsButton.propTypes = { diff --git a/components/frontend/src/header_footer/buttons/SettingsButton.jsx b/components/frontend/src/header_footer/buttons/SettingsButton.jsx index 0ad445148a..ff3314b93b 100644 --- a/components/frontend/src/header_footer/buttons/SettingsButton.jsx +++ b/components/frontend/src/header_footer/buttons/SettingsButton.jsx @@ -1,17 +1,17 @@ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown" import ArrowRightIcon from "@mui/icons-material/ArrowRight" -import { Button } from "@mui/material" import { bool, func } from "prop-types" +import { AppBarButton } from "./AppBarbutton" + export function SettingsButton({ settingsPanelVisible, setSettingsPanelVisible }) { return ( - + ) } SettingsButton.propTypes = { diff --git a/docs/src/changelog.md b/docs/src/changelog.md index abd88cdf40..a1221f1f78 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -16,6 +16,7 @@ If your currently installed *Quality-time* version is not the latest version, pl ### Fixed +- Increase contrast for disabled items in the menu bar. Fixes [#10840](https://github.com/ICTU/quality-time/issues/10840). - Links to documentation on Read the Docs for subjects, metrics, or sources with hyphens in their name wouldn't scroll to the right location. Fixes [#10843](https://github.com/ICTU/quality-time/issues/10843). - The software documentation was outdated (among other things the API-server health check endpoint). Fixes [#10858](https://github.com/ICTU/quality-time/issues/10858).