From 9f86f972afe69891d1baa92ce029d04a823bcc26 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Fri, 4 Jul 2025 16:47:02 +0100 Subject: [PATCH 1/7] delete strings we're not using --- public/translations/en.json | 38 ++-------------------------------- public/translations/xx-XX.json | 38 ++-------------------------------- 2 files changed, 4 insertions(+), 72 deletions(-) diff --git a/public/translations/en.json b/public/translations/en.json index 0cfeb181d..5ea3c5f06 100644 --- a/public/translations/en.json +++ b/public/translations/en.json @@ -58,13 +58,6 @@ "downloadHint": "Download your project files so you can use them offline and in a different code editor.", "downloadButton": "Download project" }, - "footer": { - "accessibility": "Accessibility", - "charityNameAndNumber": "Raspberry Pi Foundation UK registered charity 1129409", - "cookies": "Cookies", - "privacy": "Privacy", - "safeguarding": "Safeguarding" - }, "projectName": { "label": "Project name", "newProject": "New Project" @@ -73,12 +66,10 @@ "download": "Download", "downloadFileNameDefault": "my {{project_type}} project", "editorLogoAltText": "Editor logo", - "projects": "Your projects", "renameProject": "Edit project name", "renameSave": "Save project name", "save": "Save", - "loginToSave": "Log in to save", - "settings": "Settings" + "loginToSave": "Log in to save" }, "imagePanel": { "gallery": "Image Gallery" @@ -137,7 +128,6 @@ "notifications": { "close": "close", "loginPrompt": "To save this project and access it later, don't forget to log in or sign up!", - "projectRemixed": "Your remixed project has been saved", "projectRenamed": "You have renamed your project.", "projectSaved": "Your project has been saved", "savePrompt": "Save this project to access it later under \"Your projects\"." @@ -199,37 +189,13 @@ }, "untitled": "Untitled project" }, - "projectHeader": { - "subTitle": "Code Editor", - "title": "Your projects", - "text": "Select a project to continue coding, view, or edit it." - }, "projectList": { - "delete": "Delete", - "deleteLabel": "Delete project", - "empty": "No projects created yet", - "label": "Open project menu", - "loading": "Loading", - "loadingFailed": "Failed to load projects", - "newProject": "Create a new project", - "pagination": { - "first": "First page", - "last": "Last page", - "next": "Next page", - "previous": "Previous page", - "more": "Load more projects" - }, - "rename": "Rename", - "renameLabel": "Rename project", "renameProjectModal": { "cancel": "Do not save", "heading": "Rename project", "inputLabel": "Change the name of your project", "save": "Save" - }, - "updated": "Edited", - "python_type": "Python", - "html_type": "HTML" + } }, "projectTypes": { "html": "HTML/CSS", diff --git a/public/translations/xx-XX.json b/public/translations/xx-XX.json index 3613cacf0..caa180c20 100644 --- a/public/translations/xx-XX.json +++ b/public/translations/xx-XX.json @@ -58,13 +58,6 @@ "downloadHint": "Laden Sie Ihre Projektdateien herunter, damit Sie sie offline und in einem anderen Code-Editor verwenden können.", "downloadButton": "Projekt herunterladen" }, - "footer": { - "accessibility": "Barrierefreiheit", - "charityNameAndNumber": "Raspberry Pi Foundation UK eingetragene Wohltätigkeitsorganisation 1129409", - "cookies": "Cookies", - "privacy": "Datenschutz", - "safeguarding": "Kinderschutz" - }, "projectName": { "label": "Projektname", "newProject": "Neues Projekt" @@ -73,12 +66,10 @@ "download": "Herunterladen", "downloadFileNameDefault": "mein {{project_type}} Projekt", "editorLogoAltText": "Editor-Logo", - "projects": "Ihre Projekte", "renameProject": "Projektnamen bearbeiten", "renameSave": "Projektnamen speichern", "save": "Speichern", - "loginToSave": "Zum Speichern anmelden", - "settings": "Einstellungen" + "loginToSave": "Zum Speichern anmelden" }, "imagePanel": { "gallery": "Bildergalerie" @@ -137,7 +128,6 @@ "notifications": { "close": "schließen", "loginPrompt": "Um dieses Projekt zu speichern und später darauf zuzugreifen, vergessen Sie nicht, sich anzumelden oder zu registrieren!", - "projectRemixed": "Ihr neu gemischtes Projekt wurde gespeichert", "projectRenamed": "Sie haben Ihr Projekt umbenannt.", "projectSaved": "Ihr Projekt wurde gespeichert", "savePrompt": "Speichern Sie dieses Projekt, um später unter „Ihre Projekte“ darauf zuzugreifen." @@ -199,37 +189,13 @@ }, "untitled": "Unbenanntes Projekt" }, - "projectHeader": { - "subTitle": "Code-Editor", - "title": "Ihre Projekte", - "text": "Wählen Sie ein Projekt aus, um mit dem Programmieren fortzufahren, es anzuzeigen oder zu bearbeiten." - }, "projectList": { - "delete": "Löschen", - "deleteLabel": "Projekt löschen", - "empty": "Noch keine Projekte erstellt", - "label": "Projektmenü öffnen", - "loading": "Wird geladen", - "loadingFailed": "Fehler beim Laden der Projekte", - "newProject": "Neues Projekt erstellen", - "pagination": { - "first": "Erste Seite", - "last": "Letzte Seite", - "next": "Nächste Seite", - "previous": "Vorherige Seite", - "more": "Weitere Projekte laden" - }, - "rename": "Umbenennen", - "renameLabel": "Projekt umbenennen", "renameProjectModal": { "cancel": "Nicht speichern", "heading": "Projekt umbenennen", "inputLabel": "Ändern Sie den Namen Ihres Projekts", "save": "Speichern" - }, - "updated": "Bearbeitet", - "python_type": "Python", - "html_type": "HTML" + } }, "projectTypes": { "html": "HTML/CSS", From 54f2b173212ab5ec0540bbba01f59d6fdcbe81c8 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Fri, 4 Jul 2025 17:08:17 +0100 Subject: [PATCH 2/7] delete AccessDeniedWithAuthModal --- public/translations/en.json | 9 --- public/translations/xx-XX.json | 9 --- .../Modals/AccessDeniedWithAuthModal.jsx | 77 ------------------- .../Modals/AccessDeniedWithAuthModal.test.js | 69 ----------------- src/redux/EditorSlice.js | 5 -- src/redux/reducers/loadProjectReducers.js | 2 - .../reducers/loadProjectReducers.test.js | 1 - src/utils/Notifications.js | 7 -- 8 files changed, 179 deletions(-) delete mode 100644 src/components/Modals/AccessDeniedWithAuthModal.jsx delete mode 100644 src/components/Modals/AccessDeniedWithAuthModal.test.js diff --git a/public/translations/en.json b/public/translations/en.json index 5ea3c5f06..a1bcf189f 100644 --- a/public/translations/en.json +++ b/public/translations/en.json @@ -168,15 +168,6 @@ "buttonSplitTitle": "Split view" }, "project": { - "accessDeniedWithAuthModal": { - "embedded": { - "text": "Visit the Projects site for cool project ideas" - }, - "heading": "You can't access this project", - "newProject": "Create a new code project", - "projectsSiteLinkText": "Explore Projects site", - "text": "Visit the Projects site for cool project ideas or start coding in a new project." - }, "loading": "Loading", "notFoundModal": { "embedded": { diff --git a/public/translations/xx-XX.json b/public/translations/xx-XX.json index caa180c20..90858927c 100644 --- a/public/translations/xx-XX.json +++ b/public/translations/xx-XX.json @@ -168,15 +168,6 @@ "buttonSplitTitle": "Geteilte Ansicht" }, "project": { - "accessDeniedWithAuthModal": { - "embedded": { - "text": "Besuchen Sie die Projektseite für tolle Projektideen" - }, - "heading": "Sie können auf dieses Projekt nicht zugreifen", - "newProject": "Ein neues Code-Projekt erstellen", - "projectsSiteLinkText": "Projektseite erkunden", - "text": "Besuchen Sie die Projektseite für tolle Projektideen oder beginnen Sie mit dem Programmieren in einem neuen Projekt." - }, "loading": "Wird geladen", "notFoundModal": { "embedded": { diff --git a/src/components/Modals/AccessDeniedWithAuthModal.jsx b/src/components/Modals/AccessDeniedWithAuthModal.jsx deleted file mode 100644 index 11ad413eb..000000000 --- a/src/components/Modals/AccessDeniedWithAuthModal.jsx +++ /dev/null @@ -1,77 +0,0 @@ -import React from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { useTranslation } from "react-i18next"; - -import Button from "../Button/Button"; -import "../../assets/stylesheets/Modal.scss"; -import { - closeAccessDeniedWithAuthModal, - syncProject, -} from "../../redux/EditorSlice"; -import { defaultPythonProject } from "../../utils/defaultProjects"; -import GeneralModal from "./GeneralModal"; - -const AccessDeniedWithAuthModal = (props) => { - const { - buttons = null, - text = null, - withCloseButton = true, - withClickToClose = true, - } = props; - const dispatch = useDispatch(); - const { t } = useTranslation(); - const user = useSelector((state) => state.auth.user); - - const isModalOpen = useSelector( - (state) => state.editor.accessDeniedWithAuthModalShowing, - ); - - const closeModal = () => dispatch(closeAccessDeniedWithAuthModal()); - - const createNewProject = async () => { - dispatch( - syncProject("save")({ - project: defaultPythonProject, - accessToken: user.access_token, - autosave: false, - }), - ); - }; - - return ( - , - - {t("project.accessDeniedWithAuthModal.projectsSiteLinkText")} - , - ] - } - defaultCallback={createNewProject} - /> - ); -}; - -export default AccessDeniedWithAuthModal; diff --git a/src/components/Modals/AccessDeniedWithAuthModal.test.js b/src/components/Modals/AccessDeniedWithAuthModal.test.js deleted file mode 100644 index b4deeedfe..000000000 --- a/src/components/Modals/AccessDeniedWithAuthModal.test.js +++ /dev/null @@ -1,69 +0,0 @@ -import React from "react"; -import { fireEvent, render, screen, waitFor } from "@testing-library/react"; -import { Provider } from "react-redux"; -import configureStore from "redux-mock-store"; -import AccessDeniedWithAuthModal from "./AccessDeniedWithAuthModal"; -import { syncProject } from "../../redux/EditorSlice"; -import { defaultPythonProject } from "../../utils/defaultProjects"; - -jest.mock("../../redux/EditorSlice", () => ({ - ...jest.requireActual("../../redux/EditorSlice"), - syncProject: jest.fn((_) => jest.fn()), -})); - -const user = { - access_token: "39a09671-be55-4847-baf5-8919a0c24a25", - profile: { - user: "b48e70e2-d9ed-4a59-aee5-fc7cf09dbfaf", - }, -}; - -const middlewares = []; -const mockStore = configureStore(middlewares); - -describe("When accessDeniedWithAuthModalShowing is true", () => { - let store; - - beforeEach(() => { - const initialState = { - editor: { - accessDeniedWithAuthModalShowing: true, - }, - auth: { - user: user, - }, - }; - store = mockStore(initialState); - render( - -
- -
-
, - ); - }); - - test("Modal rendered", () => { - expect( - screen.queryByText("project.accessDeniedWithAuthModal.heading"), - ).toBeInTheDocument(); - }); - - test("Clicking new project creates a new project", async () => { - const newProjectLink = screen.queryByText( - "project.accessDeniedWithAuthModal.newProject", - ); - const saveAction = { type: "SAVE_PROJECT" }; - const saveProject = jest.fn(() => saveAction); - syncProject.mockImplementationOnce(jest.fn((_) => saveProject)); - fireEvent.click(newProjectLink); - await waitFor(() => - expect(saveProject).toHaveBeenCalledWith({ - project: defaultPythonProject, - accessToken: user.access_token, - autosave: false, - }), - ); - expect(store.getActions()[0]).toEqual(saveAction); - }); -}); diff --git a/src/redux/EditorSlice.js b/src/redux/EditorSlice.js index 60f47acd1..168dd16a6 100644 --- a/src/redux/EditorSlice.js +++ b/src/redux/EditorSlice.js @@ -130,7 +130,6 @@ export const editorInitialState = { senseHatAlwaysEnabled: false, senseHatEnabled: false, loadRemixDisabled: false, - accessDeniedWithAuthModalShowing: false, betaModalShowing: false, errorModalShowing: false, notFoundModalShowing: false, @@ -345,9 +344,6 @@ export const EditorSlice = createSlice({ state.codeRunStopped = false; state.runnerBeingLoaded = null; }, - closeAccessDeniedWithAuthModal: (state) => { - state.accessDeniedWithAuthModalShowing = false; - }, showBetaModal: (state) => { state.betaModalShowing = true; }, @@ -496,7 +492,6 @@ export const { updateImages, updateProjectComponent, updateProjectName, - closeAccessDeniedWithAuthModal, showBetaModal, closeBetaModal, showErrorModal, diff --git a/src/redux/reducers/loadProjectReducers.js b/src/redux/reducers/loadProjectReducers.js index 5bf49d54e..bf353605d 100644 --- a/src/redux/reducers/loadProjectReducers.js +++ b/src/redux/reducers/loadProjectReducers.js @@ -41,8 +41,6 @@ const loadProjectRejected = (state, action) => { if (errorCode === "404") { state.notFoundModalShowing = true; - } else if (accessDeniedCodes.includes(errorCode) && accessToken) { - state.accessDeniedWithAuthModalShowing = true; } else if (accessDeniedCodes.includes(errorCode) && !accessToken) { state.modals.accessDenied = { identifier: action.meta.arg.identifier, diff --git a/src/redux/reducers/loadProjectReducers.test.js b/src/redux/reducers/loadProjectReducers.test.js index 9b1a08b39..e65427a26 100644 --- a/src/redux/reducers/loadProjectReducers.test.js +++ b/src/redux/reducers/loadProjectReducers.test.js @@ -190,7 +190,6 @@ describe("EditorSliceReducers::loadProjectRejectedReducer", () => { let expectedState = { loading: "failed", saving: "idle", - accessDeniedWithAuthModalShowing: true, currentLoadingRequestId: undefined, }; diff --git a/src/utils/Notifications.js b/src/utils/Notifications.js index 61c014453..589b30750 100644 --- a/src/utils/Notifications.js +++ b/src/utils/Notifications.js @@ -64,10 +64,3 @@ export const showRenamedMessage = () => { icon: TickIcon, }); }; - -export const showRemixedMessage = () => { - toast(i18n.t("notifications.projectRemixed"), { - ...bottomCenterSettings, - icon: TickIcon, - }); -}; From 708733e3cc3e462a0706d245fee1bd2e4dc82176 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Fri, 4 Jul 2025 17:11:55 +0100 Subject: [PATCH 3/7] delete rename project modal --- public/translations/en.json | 8 -- public/translations/xx-XX.json | 8 -- src/components/Modals/RenameProjectModal.jsx | 81 ----------- .../Modals/RenameProjectModal.test.js | 135 ------------------ src/redux/EditorSlice.js | 19 +-- src/redux/EditorSlice.test.js | 2 - 6 files changed, 1 insertion(+), 252 deletions(-) delete mode 100644 src/components/Modals/RenameProjectModal.jsx delete mode 100644 src/components/Modals/RenameProjectModal.test.js diff --git a/public/translations/en.json b/public/translations/en.json index a1bcf189f..25c978537 100644 --- a/public/translations/en.json +++ b/public/translations/en.json @@ -180,14 +180,6 @@ }, "untitled": "Untitled project" }, - "projectList": { - "renameProjectModal": { - "cancel": "Do not save", - "heading": "Rename project", - "inputLabel": "Change the name of your project", - "save": "Save" - } - }, "projectTypes": { "html": "HTML/CSS", "python": "Python" diff --git a/public/translations/xx-XX.json b/public/translations/xx-XX.json index 90858927c..e5720a751 100644 --- a/public/translations/xx-XX.json +++ b/public/translations/xx-XX.json @@ -180,14 +180,6 @@ }, "untitled": "Unbenanntes Projekt" }, - "projectList": { - "renameProjectModal": { - "cancel": "Nicht speichern", - "heading": "Projekt umbenennen", - "inputLabel": "Ändern Sie den Namen Ihres Projekts", - "save": "Speichern" - } - }, "projectTypes": { "html": "HTML/CSS", "python": "Python" diff --git a/src/components/Modals/RenameProjectModal.jsx b/src/components/Modals/RenameProjectModal.jsx deleted file mode 100644 index ca462a7b6..000000000 --- a/src/components/Modals/RenameProjectModal.jsx +++ /dev/null @@ -1,81 +0,0 @@ -import React, { useState } from "react"; -import { gql, useMutation } from "@apollo/client"; -import { useTranslation } from "react-i18next"; -import { useDispatch, useSelector } from "react-redux"; -import { closeRenameProjectModal } from "../../redux/EditorSlice"; -import { showRenamedMessage } from "../../utils/Notifications"; -import Button from "../Button/Button"; -import InputModal from "./InputModal"; - -export const RENAME_PROJECT_MUTATION = gql` - mutation RenameProject($id: String!, $name: String!) { - updateProject(input: { id: $id, name: $name }) { - project { - id - name - updatedAt - } - } - } -`; - -export const RenameProjectModal = () => { - const dispatch = useDispatch(); - const { t } = useTranslation(); - const isModalOpen = useSelector( - (state) => state.editor.renameProjectModalShowing, - ); - const project = useSelector((state) => state.editor.modals.renameProject); - const closeModal = () => dispatch(closeRenameProjectModal()); - - const [projectName, setProjectName] = useState(project.name); - - const onCompleted = () => { - closeModal(); - showRenamedMessage(); - }; - - // This can capture data, error, loading as per normal queries, but we're not - // using them yet. - const [renameProjectMutation] = useMutation(RENAME_PROJECT_MUTATION); - - const renameProject = () => { - renameProjectMutation({ - variables: { id: project.id, name: projectName }, - onCompleted: onCompleted, - }); - }; - - return ( - , -