Skip to content

Commit 368db16

Browse files
authored
Fix link to your projects page (#1149)
1 parent 96a2fcd commit 368db16

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## Unreleased
88

9+
## [0.28.11] - 2024-12-03
10+
11+
### Fixed
12+
13+
- Link to "Your projects" page (#1149)
14+
915
## [0.28.10] - 2024-11-29
1016

1117
### Fixed
@@ -995,7 +1001,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
9951001

9961002
- Events in Web Component indicating whether Mission Zero criteria have been met (#113)
9971003

998-
[unreleased]: https://github.com/RaspberryPiFoundation/editor-ui/compare/v0.28.10...HEAD
1004+
[unreleased]: https://github.com/RaspberryPiFoundation/editor-ui/compare/v0.28.11...HEAD
1005+
[0.28.11]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.28.11
9991006
[0.28.10]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.28.10
10001007
[0.28.9]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.28.9
10011008
[0.28.8]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.28.8

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@raspberrypifoundation/editor-ui",
3-
"version": "0.28.10",
3+
"version": "0.28.11",
44
"private": true,
55
"dependencies": {
66
"@apollo/client": "^3.7.8",

src/components/Menus/Sidebar/ProjectsPanel/ProjectsPanel.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ import { MOBILE_MEDIA_QUERY } from "../../../../utils/mediaQueryBreakpoints";
1313
import { useMediaQuery } from "react-responsive";
1414
import SaveStatus from "../../../SaveStatus/SaveStatus";
1515
import DesignSystemButton from "../../../DesignSystemButton/DesignSystemButton";
16+
import { navigateToProjectsPageEvent } from "../../../../events/WebComponentCustomEvents";
1617

1718
const ProjectsPanel = () => {
18-
const {
19-
t,
20-
i18n: { language: locale },
21-
} = useTranslation();
19+
const { t } = useTranslation();
2220

2321
const isLoggedIn = useSelector((state) => state?.auth?.user);
2422
const isMobile = useMediaQuery({ query: MOBILE_MEDIA_QUERY });
@@ -35,14 +33,18 @@ const ProjectsPanel = () => {
3533
</>
3634
);
3735

36+
const navigateToProjectsPage = () => {
37+
document.dispatchEvent(navigateToProjectsPageEvent);
38+
};
39+
3840
return (
3941
<SidebarPanel
4042
heading={t("projectsPanel.projects")}
4143
Button={() =>
4244
isLoggedIn && (
4345
<DesignSystemButton
4446
className="btn--primary projects-panel__your-projects-button"
45-
href={`/${locale}/projects`}
47+
onClick={navigateToProjectsPage}
4648
text={t("projectsPanel.yourProjectsButton")}
4749
/>
4850
)

src/components/Menus/Sidebar/ProjectsPanel/ProjectsPanel.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { MemoryRouter } from "react-router-dom";
66

77
import ProjectsPanel from "./ProjectsPanel";
88

9+
document.dispatchEvent = jest.fn();
10+
911
const initialState = {
1012
editor: {
1113
project: {
@@ -66,6 +68,20 @@ describe("Projects Panel", () => {
6668
screen.queryByText("projectsPanel.yourProjectsButton"),
6769
).toBeInTheDocument();
6870
});
71+
72+
test("Clicking projects button dispatches navigateToProjectsPageEvent", () => {
73+
const projectsPageButton = screen.getByText(
74+
"projectsPanel.yourProjectsButton",
75+
);
76+
projectsPageButton.click();
77+
expect(document.dispatchEvent).toHaveBeenCalledWith(
78+
new CustomEvent("editor-navigateToProjectsPageEvent", {
79+
bubbles: true,
80+
cancelable: false,
81+
composed: true,
82+
}),
83+
);
84+
});
6985
});
7086

7187
describe("When not read only", () => {

src/events/WebComponentCustomEvents.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const webComponentCustomEvent = (type, detail) =>
88

99
export const codeChangedEvent = webComponentCustomEvent("editor-codeChanged");
1010

11+
export const navigateToProjectsPageEvent = webComponentCustomEvent(
12+
"editor-navigateToProjectsPage",
13+
);
14+
1115
export const projectIdentifierChangedEvent = (detail) =>
1216
webComponentCustomEvent("editor-projectIdentifierChanged", detail);
1317

0 commit comments

Comments
 (0)