From 1297c9f391a4b553a124f32d453881b2efeaad5f Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 10 Sep 2020 20:04:03 +0200 Subject: [PATCH] Restructure (#78) * moved files into new structure * translation files / namespace per "page" fixes: #77 * renamed pages to sections * moved save, delete and others to common bundle --- package.json | 1 - src/App.tsx | 59 +++++++++---------- src/PageNav.tsx | 2 +- ...tFoundPage.tsx => PageNotFoundSection.tsx} | 2 +- .../AuthenticationSection.tsx} | 2 +- .../ClientScopesSection.tsx} | 2 +- .../client => clients}/ClientDescription.tsx | 10 ++-- src/clients/ClientList.tsx | 17 +++--- .../ClientsSection.tsx} | 8 +-- .../{ => __tests__}/ClientList.test.tsx | 4 +- src/clients/{ => __tests__}/mock-clients.json | 0 .../client => clients/add}/NewClientForm.tsx | 14 +++-- src/{forms/client => clients/add}/Step1.tsx | 6 +- src/{forms/client => clients/add}/Step2.tsx | 2 +- .../add/__tests__}/mock-serverinfo.json | 0 .../client => clients/import}/ImportForm.tsx | 12 ++-- src/clients/messages.json | 15 +++++ src/{model => clients/models}/client-model.ts | 0 src/{model => clients/models}/server-info.ts | 0 src/common-messages.json | 19 ++++++ .../alert/{ => __tests__}/Alerts.test.tsx | 4 +- .../__snapshots__/Alerts.test.tsx.snap | 0 .../{ => __tests__}/DataLoader.test.tsx | 2 +- .../{ => __tests__}/ExternalLink.test.tsx | 2 +- .../__snapshots__/ExternalLink.test.tsx.snap | 0 src/components/help-enabler/HelpHeader.tsx | 2 - .../{ => __tests__}/HelpHeader.test.tsx | 2 +- .../{ => __tests__}/HelpItem.test.tsx | 2 +- .../__snapshots__/HelpHeader.test.tsx.snap | 0 .../__snapshots__/HelpItem.test.tsx.snap | 0 .../{ => __tests__}/JsonFileUpload.test.tsx | 2 +- .../JsonFileUpload.test.tsx.snap | 0 .../realm-selector/RealmSelector.tsx | 2 +- .../{ => __tests__}/RealmSelector.test.tsx | 5 +- .../__snapshots__/RealmSelector.test.tsx.snap | 0 .../EventsSection.tsx} | 2 +- .../GroupsSection.tsx} | 2 +- src/help.json | 6 +- src/i18n.ts | 15 +++-- .../IdentityProvidersSection.tsx} | 2 +- src/index.tsx | 16 +++-- src/messages.json | 24 -------- .../RealmRolesSection.tsx} | 2 +- .../RealmSettingsSection.tsx} | 2 +- .../realm => realm/add}/NewRealmForm.tsx | 16 ++--- src/realm/messages.json | 11 ++++ src/{ => realm}/models/Realm.ts | 0 .../SessionsSection.tsx} | 2 +- src/stories/ClientList.stories.tsx | 2 +- src/stories/HelpSystem.stories.tsx | 2 +- src/stories/RealmForm.stories.tsx | 2 +- .../UserFederationSection.tsx} | 2 +- .../UsersPage.tsx => user/UsersSection.tsx} | 2 +- src/util.ts | 2 +- yarn.lock | 17 ++---- 55 files changed, 170 insertions(+), 157 deletions(-) rename src/{page/PageNotFoundPage.tsx => PageNotFoundSection.tsx} (58%) rename src/{page/AuthenticationPage.tsx => authentication/AuthenticationSection.tsx} (60%) rename src/{page/ClientScopesPage.tsx => client-scopes/ClientScopesSection.tsx} (61%) rename src/{forms/client => clients}/ClientDescription.tsx (73%) rename src/{page/ClientsPage.tsx => clients/ClientsSection.tsx} (90%) rename src/clients/{ => __tests__}/ClientList.test.tsx (86%) rename src/clients/{ => __tests__}/mock-clients.json (100%) rename src/{forms/client => clients/add}/NewClientForm.tsx (84%) rename src/{forms/client => clients/add}/Step1.tsx (91%) rename src/{forms/client => clients/add}/Step2.tsx (97%) rename src/{forms/client => clients/add/__tests__}/mock-serverinfo.json (100%) rename src/{forms/client => clients/import}/ImportForm.tsx (88%) create mode 100644 src/clients/messages.json rename src/{model => clients/models}/client-model.ts (100%) rename src/{model => clients/models}/server-info.ts (100%) create mode 100644 src/common-messages.json rename src/components/alert/{ => __tests__}/Alerts.test.tsx (91%) rename src/components/alert/{ => __tests__}/__snapshots__/Alerts.test.tsx.snap (100%) rename src/components/data-loader/{ => __tests__}/DataLoader.test.tsx (94%) rename src/components/external-link/{ => __tests__}/ExternalLink.test.tsx (90%) rename src/components/external-link/{ => __tests__}/__snapshots__/ExternalLink.test.tsx.snap (100%) rename src/components/help-enabler/{ => __tests__}/HelpHeader.test.tsx (95%) rename src/components/help-enabler/{ => __tests__}/HelpItem.test.tsx (86%) rename src/components/help-enabler/{ => __tests__}/__snapshots__/HelpHeader.test.tsx.snap (100%) rename src/components/help-enabler/{ => __tests__}/__snapshots__/HelpItem.test.tsx.snap (100%) rename src/components/json-file-upload/{ => __tests__}/JsonFileUpload.test.tsx (94%) rename src/components/json-file-upload/{ => __tests__}/__snapshots__/JsonFileUpload.test.tsx.snap (100%) rename src/components/realm-selector/{ => __tests__}/RealmSelector.test.tsx (75%) rename src/components/realm-selector/{ => __tests__}/__snapshots__/RealmSelector.test.tsx.snap (100%) rename src/{page/EventsPage.tsx => events/EventsSection.tsx} (62%) rename src/{page/GroupsPage.tsx => groups/GroupsSection.tsx} (62%) rename src/{page/IdentityProvidersPage.tsx => identity-providers/IdentityProvidersSection.tsx} (60%) delete mode 100644 src/messages.json rename src/{page/RealmRolesPage.tsx => realm-roles/RealmRolesSection.tsx} (62%) rename src/{page/RealmSettingsPage.tsx => realm-settings/RealmSettingsSection.tsx} (61%) rename src/{forms/realm => realm/add}/NewRealmForm.tsx (75%) create mode 100644 src/realm/messages.json rename src/{ => realm}/models/Realm.ts (100%) rename src/{page/SessionsPage.tsx => sessions/SessionsSection.tsx} (62%) rename src/{page/UserFederationPage.tsx => user-federation/UserFederationSection.tsx} (61%) rename src/{page/UsersPage.tsx => user/UsersSection.tsx} (62%) diff --git a/package.json b/package.json index a1ba96bbe1..5f31881a00 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "@patternfly/react-table": "^4.15.5", "file-saver": "^2.0.2", "i18next": "^19.6.2", - "i18next-http-backend": "^1.0.18", "keycloak-js": "^11.0.0", "react": "^16.8.5", "react-dom": "^16.8.5", diff --git a/src/App.tsx b/src/App.tsx index f50a700aee..f1cfea07a6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,27 +1,26 @@ import React from "react"; -import { Page, PageSection, Button } from "@patternfly/react-core"; +import { Page, PageSection } from "@patternfly/react-core"; import { Header } from "./PageHeader"; import { PageNav } from "./PageNav"; import { Help } from "./components/help-enabler/HelpHeader"; import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; -import { NewRealmForm } from "./forms/realm/NewRealmForm"; -import { NewClientForm } from "./forms/client/NewClientForm"; -import { ImportForm } from "./forms/client/ImportForm"; +import { NewRealmForm } from "./realm/add/NewRealmForm"; +import { NewClientForm } from "./clients/add/NewClientForm"; +import { ImportForm } from "./clients/import/ImportForm"; +import { ClientsSection } from "./clients/ClientsSection"; +import { ClientScopesSection } from "./client-scopes/ClientScopesSection"; +import { RealmRolesSection } from "./realm-roles/RealmRolesSection"; +import { UsersSection } from "./user/UsersSection"; +import { GroupsSection } from "./groups/GroupsSection"; +import { SessionsSection } from "./sessions/SessionsSection"; +import { EventsSection } from "./events/EventsSection"; +import { RealmSettingsSection } from "./realm-settings/RealmSettingsSection"; +import { AuthenticationSection } from "./authentication/AuthenticationSection"; +import { IdentityProvidersSection } from "./identity-providers/IdentityProvidersSection"; +import { UserFederationSection } from "./user-federation/UserFederationSection"; -import { ClientsPage } from "./page/ClientsPage"; -import { ClientScopesPage } from "./page/ClientScopesPage"; -import { RealmRolesPage } from "./page/RealmRolesPage"; -import { UsersPage } from "./page/UsersPage"; -import { GroupsPage } from "./page/GroupsPage"; -import { SessionsPage } from "./page/SessionsPage"; -import { EventsPage } from "./page/EventsPage"; -import { RealmSettingsPage } from "./page/RealmSettingsPage"; -import { AuthenticationPage } from "./page/AuthenticationPage"; -import { IdentityProvidersPage } from "./page/IdentityProvidersPage"; -import { UserFederationPage } from "./page/UserFederationPage"; - -import { PageNotFoundPage } from "./page/PageNotFoundPage"; +import { PageNotFoundSection } from "./PageNotFoundSection"; export const App = () => { return ( @@ -32,48 +31,48 @@ export const App = () => { - + - - - - + + + + - - + + diff --git a/src/PageNav.tsx b/src/PageNav.tsx index c15123d886..fbf69505a2 100644 --- a/src/PageNav.tsx +++ b/src/PageNav.tsx @@ -4,7 +4,7 @@ import { Nav, NavItem, NavGroup, PageSidebar } from "@patternfly/react-core"; import { RealmSelector } from "./components/realm-selector/RealmSelector"; import { DataLoader } from "./components/data-loader/DataLoader"; import { HttpClientContext } from "./http-service/HttpClientContext"; -import { Realm } from "./models/Realm"; +import { Realm } from "./realm/models/Realm"; export const PageNav: React.FunctionComponent = () => { const httpClient = useContext(HttpClientContext)!; diff --git a/src/page/PageNotFoundPage.tsx b/src/PageNotFoundSection.tsx similarity index 58% rename from src/page/PageNotFoundPage.tsx rename to src/PageNotFoundSection.tsx index 82dc761d63..bf839bb863 100644 --- a/src/page/PageNotFoundPage.tsx +++ b/src/PageNotFoundSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const PageNotFoundPage = () => { +export const PageNotFoundSection = () => { return <>Page Not Found; }; diff --git a/src/page/AuthenticationPage.tsx b/src/authentication/AuthenticationSection.tsx similarity index 60% rename from src/page/AuthenticationPage.tsx rename to src/authentication/AuthenticationSection.tsx index ab95487923..043ac8c86c 100644 --- a/src/page/AuthenticationPage.tsx +++ b/src/authentication/AuthenticationSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const AuthenticationPage = () => { +export const AuthenticationSection = () => { return <>The Authentication Page; }; diff --git a/src/page/ClientScopesPage.tsx b/src/client-scopes/ClientScopesSection.tsx similarity index 61% rename from src/page/ClientScopesPage.tsx rename to src/client-scopes/ClientScopesSection.tsx index a8e9aae73b..ef8cc2d287 100644 --- a/src/page/ClientScopesPage.tsx +++ b/src/client-scopes/ClientScopesSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const ClientScopesPage = () => { +export const ClientScopesSection = () => { return <>The Client Scopes Page; }; diff --git a/src/forms/client/ClientDescription.tsx b/src/clients/ClientDescription.tsx similarity index 73% rename from src/forms/client/ClientDescription.tsx rename to src/clients/ClientDescription.tsx index fcadd06399..7edbbbf073 100644 --- a/src/forms/client/ClientDescription.tsx +++ b/src/clients/ClientDescription.tsx @@ -1,7 +1,8 @@ import React, { FormEvent } from "react"; import { FormGroup, TextInput } from "@patternfly/react-core"; -import { ClientRepresentation } from "../../model/client-model"; +import { ClientRepresentation } from "./models/client-model"; +import { useTranslation } from "react-i18next"; type ClientDescriptionProps = { onChange: (value: string, event: FormEvent) => void; @@ -12,9 +13,10 @@ export const ClientDescription = ({ client, onChange, }: ClientDescriptionProps) => { + const { t } = useTranslation("clients"); return ( <> - + - + - + { + const { t } = useTranslation("clients"); const httpClient = useContext(HttpClientContext)!; - const { t } = useTranslation(); const [add, alerts, hide] = useAlerts(); const convertClientId = (clientId: string) => @@ -58,6 +58,7 @@ export const ClientList = ({ baseUrl, clients }: ClientListProps) => { ) : undefined) as object; }; + /* eslint-disable no-template-curly-in-string */ const replaceBaseUrl = (r: ClientRepresentation) => r.rootUrl && r.rootUrl @@ -91,7 +92,7 @@ export const ClientList = ({ baseUrl, clients }: ClientListProps) => { rows={data} actions={[ { - title: t("Export"), + title: t("common:Export"), onClick: (_, rowId) => { const clientCopy = JSON.parse(JSON.stringify(data[rowId].client)); clientCopy.clientId = convertClientId(clientCopy.clientId); @@ -103,7 +104,7 @@ export const ClientList = ({ baseUrl, clients }: ClientListProps) => { } } - saveAs( + FileSaver.saveAs( new Blob([JSON.stringify(clientCopy, null, 2)], { type: "application/json", }), @@ -112,7 +113,7 @@ export const ClientList = ({ baseUrl, clients }: ClientListProps) => { }, }, { - title: t("Delete"), + title: t("common:Delete"), onClick: (_, rowId) => { try { httpClient.doDelete( @@ -128,7 +129,7 @@ export const ClientList = ({ baseUrl, clients }: ClientListProps) => { }, }, ]} - aria-label="Client list" + aria-label={t("Client list")} > diff --git a/src/page/ClientsPage.tsx b/src/clients/ClientsSection.tsx similarity index 90% rename from src/page/ClientsPage.tsx rename to src/clients/ClientsSection.tsx index 6c66defc9f..02c77f4be6 100644 --- a/src/page/ClientsPage.tsx +++ b/src/clients/ClientsSection.tsx @@ -5,13 +5,13 @@ import { Button } from "@patternfly/react-core"; import { DataLoader } from "../components/data-loader/DataLoader"; import { TableToolbar } from "../components/table-toolbar/TableToolbar"; -import { ClientList } from "../clients/ClientList"; +import { ClientList } from "./ClientList"; import { HttpClientContext } from "../http-service/HttpClientContext"; import { KeycloakContext } from "../auth/KeycloakContext"; -import { ClientRepresentation } from "../model/client-model"; +import { ClientRepresentation } from "./models/client-model"; -export const ClientsPage = () => { - const { t } = useTranslation(); +export const ClientsSection = () => { + const { t } = useTranslation("clients"); const history = useHistory(); const [max, setMax] = useState(10); const [first, setFirst] = useState(0); diff --git a/src/clients/ClientList.test.tsx b/src/clients/__tests__/ClientList.test.tsx similarity index 86% rename from src/clients/ClientList.test.tsx rename to src/clients/__tests__/ClientList.test.tsx index 96ed3ddd49..acdc9852da 100644 --- a/src/clients/ClientList.test.tsx +++ b/src/clients/__tests__/ClientList.test.tsx @@ -2,9 +2,9 @@ import React from "react"; import { render } from "@testing-library/react"; import clientMock from "./mock-clients.json"; -import { ClientList } from "./ClientList"; import { I18nextProvider } from "react-i18next"; -import { i18n } from "../i18n"; +import i18n from "../../i18n"; +import { ClientList } from "../ClientList"; test("renders ClientList", () => { const { getByText } = render( diff --git a/src/clients/mock-clients.json b/src/clients/__tests__/mock-clients.json similarity index 100% rename from src/clients/mock-clients.json rename to src/clients/__tests__/mock-clients.json diff --git a/src/forms/client/NewClientForm.tsx b/src/clients/add/NewClientForm.tsx similarity index 84% rename from src/forms/client/NewClientForm.tsx rename to src/clients/add/NewClientForm.tsx index b303e2bb49..c45c0b2aa9 100644 --- a/src/forms/client/NewClientForm.tsx +++ b/src/clients/add/NewClientForm.tsx @@ -10,11 +10,13 @@ import { import { HttpClientContext } from "../../http-service/HttpClientContext"; import { Step1 } from "./Step1"; import { Step2 } from "./Step2"; -import { ClientRepresentation } from "../../model/client-model"; +import { ClientRepresentation } from "../models/client-model"; import { AlertPanel } from "../../components/alert/AlertPanel"; import { useAlerts } from "../../components/alert/Alerts"; +import { useTranslation } from "react-i18next"; export const NewClientForm = () => { + const { t } = useTranslation("clients"); const httpClient = useContext(HttpClientContext)!; const [client, setClient] = useState({ protocol: "", @@ -48,7 +50,7 @@ export const NewClientForm = () => { }); }; - const title = "Create client"; + const title = t("Create client"); return ( <> @@ -64,16 +66,16 @@ export const NewClientForm = () => { mainAriaLabel={`${title} content`} steps={[ { - name: "General Settings", + name: t("General Settings"), component: , }, { - name: "Capability config", + name: t("Capability config"), component: , - nextButtonText: "Save", + nextButtonText: t("common:Save"), }, ]} - onSave={save} + onSave={() => save()} /> diff --git a/src/forms/client/Step1.tsx b/src/clients/add/Step1.tsx similarity index 91% rename from src/forms/client/Step1.tsx rename to src/clients/add/Step1.tsx index 749f202d62..1c19920315 100644 --- a/src/forms/client/Step1.tsx +++ b/src/clients/add/Step1.tsx @@ -9,9 +9,9 @@ import { import { HttpClientContext } from "../../http-service/HttpClientContext"; import { sortProvider } from "../../util"; -import { ServerInfoRepresentation } from "../../model/server-info"; -import { ClientRepresentation } from "../../model/client-model"; -import { ClientDescription } from "./ClientDescription"; +import { ServerInfoRepresentation } from "../models/server-info"; +import { ClientRepresentation } from "../models/client-model"; +import { ClientDescription } from "../ClientDescription"; type Step1Props = { onChange: (value: string, event: FormEvent) => void; diff --git a/src/forms/client/Step2.tsx b/src/clients/add/Step2.tsx similarity index 97% rename from src/forms/client/Step2.tsx rename to src/clients/add/Step2.tsx index ed3405f911..4be30a3233 100644 --- a/src/forms/client/Step2.tsx +++ b/src/clients/add/Step2.tsx @@ -7,7 +7,7 @@ import { GridItem, } from "@patternfly/react-core"; import React, { FormEvent } from "react"; -import { ClientRepresentation } from "../../model/client-model"; +import { ClientRepresentation } from "../models/client-model"; type Step2Props = { onChange: ( diff --git a/src/forms/client/mock-serverinfo.json b/src/clients/add/__tests__/mock-serverinfo.json similarity index 100% rename from src/forms/client/mock-serverinfo.json rename to src/clients/add/__tests__/mock-serverinfo.json diff --git a/src/forms/client/ImportForm.tsx b/src/clients/import/ImportForm.tsx similarity index 88% rename from src/forms/client/ImportForm.tsx rename to src/clients/import/ImportForm.tsx index c312e0a4c5..6be1689a77 100644 --- a/src/forms/client/ImportForm.tsx +++ b/src/clients/import/ImportForm.tsx @@ -13,15 +13,15 @@ import { } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; -import { ClientRepresentation } from "../../model/client-model"; -import { ClientDescription } from "./ClientDescription"; +import { ClientRepresentation } from "../models/client-model"; +import { ClientDescription } from "../ClientDescription"; import { HttpClientContext } from "../../http-service/HttpClientContext"; import { JsonFileUpload } from "../../components/json-file-upload/JsonFileUpload"; import { useAlerts } from "../../components/alert/Alerts"; import { AlertPanel } from "../../components/alert/AlertPanel"; export const ImportForm = () => { - const { t } = useTranslation(); + const { t } = useTranslation("clients"); const httpClient = useContext(HttpClientContext)!; const [add, alerts, hide] = useAlerts(); @@ -84,10 +84,10 @@ export const ImportForm = () => { /> - - + diff --git a/src/clients/messages.json b/src/clients/messages.json new file mode 100644 index 0000000000..1bd6b5ab90 --- /dev/null +++ b/src/clients/messages.json @@ -0,0 +1,15 @@ +{ + "clients": { + "Create client": "Create client", + "Import client": "Import client", + "Client ID": "Client ID", + "Type": "Type", + "Home URL": "Home URL", + "Description": "Description", + "Client list": "Client list", + "General Settings": "General Settings", + "Capability config": "Capability config", + "Clients are applications and services that can request authentication of a user": "Clients are applications and services that can request authentication of a user", + "Name": "Name" + } +} diff --git a/src/model/client-model.ts b/src/clients/models/client-model.ts similarity index 100% rename from src/model/client-model.ts rename to src/clients/models/client-model.ts diff --git a/src/model/server-info.ts b/src/clients/models/server-info.ts similarity index 100% rename from src/model/server-info.ts rename to src/clients/models/server-info.ts diff --git a/src/common-messages.json b/src/common-messages.json new file mode 100644 index 0000000000..8ec3dea8a0 --- /dev/null +++ b/src/common-messages.json @@ -0,0 +1,19 @@ +{ + "common": { + "fullName": "{{givenName}} {{familyName}}", + "unknownUser": "Anonymous", + + "Save": "Save", + "Cancel": "Cancel", + "Delete": "Delete", + "Export": "Export", + "Resource file": "Resource file", + + "Sign out": "Sign out", + "Manage account": "Manage account", + "Server info": "Server info", + "Help": "Help", + "Documentation": "Documentation", + "Enable help mode": "Enable help mode" + } +} diff --git a/src/components/alert/Alerts.test.tsx b/src/components/alert/__tests__/Alerts.test.tsx similarity index 91% rename from src/components/alert/Alerts.test.tsx rename to src/components/alert/__tests__/Alerts.test.tsx index 8d33be21c2..dcdbd2293f 100644 --- a/src/components/alert/Alerts.test.tsx +++ b/src/components/alert/__tests__/Alerts.test.tsx @@ -3,8 +3,8 @@ import { Button, AlertVariant } from "@patternfly/react-core"; import { mount } from "enzyme"; import { act } from "react-dom/test-utils"; -import { AlertPanel } from "./AlertPanel"; -import { useAlerts } from "./Alerts"; +import { AlertPanel } from "../AlertPanel"; +import { useAlerts } from "../Alerts"; jest.useFakeTimers(); diff --git a/src/components/alert/__snapshots__/Alerts.test.tsx.snap b/src/components/alert/__tests__/__snapshots__/Alerts.test.tsx.snap similarity index 100% rename from src/components/alert/__snapshots__/Alerts.test.tsx.snap rename to src/components/alert/__tests__/__snapshots__/Alerts.test.tsx.snap diff --git a/src/components/data-loader/DataLoader.test.tsx b/src/components/data-loader/__tests__/DataLoader.test.tsx similarity index 94% rename from src/components/data-loader/DataLoader.test.tsx rename to src/components/data-loader/__tests__/DataLoader.test.tsx index b4d8492ae3..ed471494d9 100644 --- a/src/components/data-loader/DataLoader.test.tsx +++ b/src/components/data-loader/__tests__/DataLoader.test.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { DataLoader } from "./DataLoader"; +import { DataLoader } from "../DataLoader"; import { act } from "@testing-library/react"; import { render, unmountComponentAtNode } from "react-dom"; diff --git a/src/components/external-link/ExternalLink.test.tsx b/src/components/external-link/__tests__/ExternalLink.test.tsx similarity index 90% rename from src/components/external-link/ExternalLink.test.tsx rename to src/components/external-link/__tests__/ExternalLink.test.tsx index f7e5ea46f6..8922e633be 100644 --- a/src/components/external-link/ExternalLink.test.tsx +++ b/src/components/external-link/__tests__/ExternalLink.test.tsx @@ -1,6 +1,6 @@ import React from "react"; import { render } from "@testing-library/react"; -import { ExternalLink } from "./ExternalLink"; +import { ExternalLink } from "../ExternalLink"; describe("", () => { it("render with link", () => { diff --git a/src/components/external-link/__snapshots__/ExternalLink.test.tsx.snap b/src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap similarity index 100% rename from src/components/external-link/__snapshots__/ExternalLink.test.tsx.snap rename to src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap diff --git a/src/components/help-enabler/HelpHeader.tsx b/src/components/help-enabler/HelpHeader.tsx index 249e9708a2..fe6b962b41 100644 --- a/src/components/help-enabler/HelpHeader.tsx +++ b/src/components/help-enabler/HelpHeader.tsx @@ -6,8 +6,6 @@ import { Split, SplitItem, Switch, - Text, - TextVariants, } from "@patternfly/react-core"; import { Trans, useTranslation } from "react-i18next"; import { HelpIcon, ExternalLinkAltIcon } from "@patternfly/react-icons"; diff --git a/src/components/help-enabler/HelpHeader.test.tsx b/src/components/help-enabler/__tests__/HelpHeader.test.tsx similarity index 95% rename from src/components/help-enabler/HelpHeader.test.tsx rename to src/components/help-enabler/__tests__/HelpHeader.test.tsx index 86c09f18de..28e6d98075 100644 --- a/src/components/help-enabler/HelpHeader.test.tsx +++ b/src/components/help-enabler/__tests__/HelpHeader.test.tsx @@ -1,6 +1,6 @@ import React, { useContext } from "react"; import { render, act, fireEvent } from "@testing-library/react"; -import { HelpHeader, HelpContext } from "./HelpHeader"; +import { HelpHeader, HelpContext } from "../HelpHeader"; describe("", () => { it("render", () => { diff --git a/src/components/help-enabler/HelpItem.test.tsx b/src/components/help-enabler/__tests__/HelpItem.test.tsx similarity index 86% rename from src/components/help-enabler/HelpItem.test.tsx rename to src/components/help-enabler/__tests__/HelpItem.test.tsx index 62297a6999..4cc440c604 100644 --- a/src/components/help-enabler/HelpItem.test.tsx +++ b/src/components/help-enabler/__tests__/HelpItem.test.tsx @@ -1,7 +1,7 @@ import React from "react"; import { render } from "@testing-library/react"; -import { HelpItem } from "./HelpItem"; +import { HelpItem } from "../HelpItem"; describe("", () => { it("render", () => { diff --git a/src/components/help-enabler/__snapshots__/HelpHeader.test.tsx.snap b/src/components/help-enabler/__tests__/__snapshots__/HelpHeader.test.tsx.snap similarity index 100% rename from src/components/help-enabler/__snapshots__/HelpHeader.test.tsx.snap rename to src/components/help-enabler/__tests__/__snapshots__/HelpHeader.test.tsx.snap diff --git a/src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap b/src/components/help-enabler/__tests__/__snapshots__/HelpItem.test.tsx.snap similarity index 100% rename from src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap rename to src/components/help-enabler/__tests__/__snapshots__/HelpItem.test.tsx.snap diff --git a/src/components/json-file-upload/JsonFileUpload.test.tsx b/src/components/json-file-upload/__tests__/JsonFileUpload.test.tsx similarity index 94% rename from src/components/json-file-upload/JsonFileUpload.test.tsx rename to src/components/json-file-upload/__tests__/JsonFileUpload.test.tsx index f087ad52d5..aecdc7758f 100644 --- a/src/components/json-file-upload/JsonFileUpload.test.tsx +++ b/src/components/json-file-upload/__tests__/JsonFileUpload.test.tsx @@ -1,7 +1,7 @@ import React from "react"; import { mount } from "enzyme"; -import { JsonFileUpload } from "./JsonFileUpload"; +import { JsonFileUpload } from "../JsonFileUpload"; describe("", () => { it("render", () => { diff --git a/src/components/json-file-upload/__snapshots__/JsonFileUpload.test.tsx.snap b/src/components/json-file-upload/__tests__/__snapshots__/JsonFileUpload.test.tsx.snap similarity index 100% rename from src/components/json-file-upload/__snapshots__/JsonFileUpload.test.tsx.snap rename to src/components/json-file-upload/__tests__/__snapshots__/JsonFileUpload.test.tsx.snap diff --git a/src/components/realm-selector/RealmSelector.tsx b/src/components/realm-selector/RealmSelector.tsx index 7c6dabf4ba..65e8b5e8c2 100644 --- a/src/components/realm-selector/RealmSelector.tsx +++ b/src/components/realm-selector/RealmSelector.tsx @@ -1,6 +1,6 @@ import React, { useState, useContext, useEffect } from "react"; import { useHistory } from "react-router-dom"; -import { Realm } from "../../models/Realm"; +import { Realm } from "../../realm/models/Realm"; import { Dropdown, diff --git a/src/components/realm-selector/RealmSelector.test.tsx b/src/components/realm-selector/__tests__/RealmSelector.test.tsx similarity index 75% rename from src/components/realm-selector/RealmSelector.test.tsx rename to src/components/realm-selector/__tests__/RealmSelector.test.tsx index 7397d73f76..c7e00e22da 100644 --- a/src/components/realm-selector/RealmSelector.test.tsx +++ b/src/components/realm-selector/__tests__/RealmSelector.test.tsx @@ -2,10 +2,7 @@ import React from "react"; import { mount } from "enzyme"; import { act } from "@testing-library/react"; -import { AlertPanel } from "../alert/AlertPanel"; -import { useAlerts } from "../alert/Alerts"; - -import { RealmSelector } from "./RealmSelector"; +import { RealmSelector } from "../RealmSelector"; it("renders realm selector", async () => { const wrapper = mount( diff --git a/src/components/realm-selector/__snapshots__/RealmSelector.test.tsx.snap b/src/components/realm-selector/__tests__/__snapshots__/RealmSelector.test.tsx.snap similarity index 100% rename from src/components/realm-selector/__snapshots__/RealmSelector.test.tsx.snap rename to src/components/realm-selector/__tests__/__snapshots__/RealmSelector.test.tsx.snap diff --git a/src/page/EventsPage.tsx b/src/events/EventsSection.tsx similarity index 62% rename from src/page/EventsPage.tsx rename to src/events/EventsSection.tsx index 73d09b50d5..fad54953ba 100644 --- a/src/page/EventsPage.tsx +++ b/src/events/EventsSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const EventsPage = () => { +export const EventsSection = () => { return <>The Events Page; }; diff --git a/src/page/GroupsPage.tsx b/src/groups/GroupsSection.tsx similarity index 62% rename from src/page/GroupsPage.tsx rename to src/groups/GroupsSection.tsx index 18104bcbb6..93c4a78237 100644 --- a/src/page/GroupsPage.tsx +++ b/src/groups/GroupsSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const GroupsPage = () => { +export const GroupsSection = () => { return <>The Groups Page; }; diff --git a/src/help.json b/src/help.json index 0d706d03e4..0f72e894f3 100644 --- a/src/help.json +++ b/src/help.json @@ -1,7 +1,5 @@ { - "en": { - "help": { - "storybook": "Sometimes you need some help and it's nice when the app does that" - } + "help": { + "storybook": "Sometimes you need some help and it's nice when the app does that" } } diff --git a/src/i18n.ts b/src/i18n.ts index a83e535a42..d58c7ed28a 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -2,16 +2,19 @@ import i18n from "i18next"; import { initReactI18next } from "react-i18next"; // import backend from "i18next-http-backend"; -import messages from "./messages.json"; +import common from "./common-messages.json"; +import clients from "./clients/messages.json"; +import realm from "./realm/messages.json"; import help from "./help.json"; const initOptions = { - ns: ["messages", "help"], - defaultNS: "messages", - resources: { ...messages, ...help }, + ns: ["common", "help", "clients", "realm"], + defaultNS: "common", + resources: { + en: { ...common, ...help, ...clients, ...realm }, + }, lng: "en", fallbackLng: "en", - saveMissing: true, interpolation: { escapeValue: false, @@ -23,4 +26,4 @@ i18n // .use(backend) .init(initOptions); -export { i18n, initOptions }; +export default i18n; diff --git a/src/page/IdentityProvidersPage.tsx b/src/identity-providers/IdentityProvidersSection.tsx similarity index 60% rename from src/page/IdentityProvidersPage.tsx rename to src/identity-providers/IdentityProvidersSection.tsx index 13374cdc80..417a6f4226 100644 --- a/src/page/IdentityProvidersPage.tsx +++ b/src/identity-providers/IdentityProvidersSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const IdentityProvidersPage = () => { +export const IdentityProvidersSection = () => { return <>The Identity Providers Page; }; diff --git a/src/index.tsx b/src/index.tsx index 700274f5ee..a268f47a5d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,6 @@ import React from "react"; import ReactDom from "react-dom"; -import { I18nextProvider } from "react-i18next"; -import { i18n } from "./i18n"; +import i18n from "./i18n"; import { App } from "./App"; import init from "./auth/keycloak"; @@ -10,16 +9,15 @@ import { KeycloakService } from "./auth/keycloak.service"; import { HttpClientContext } from "./http-service/HttpClientContext"; import { HttpClient } from "./http-service/http-client"; +console.info("supported languages", ...i18n.languages); init().then((keycloak) => { const keycloakService = new KeycloakService(keycloak); ReactDom.render( - - - - - - - , + + + + + , document.getElementById("app") ); }); diff --git a/src/messages.json b/src/messages.json deleted file mode 100644 index f7de1d2a5f..0000000000 --- a/src/messages.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "en": { - "messages": { - "personalInfoHtmlTitle": "Personal Info", - "personalInfoIntroMessage": "Manage your basic information", - "Account Security": "Account Security", - "accountSecurityIntroMessage": "Control your password and account access", - "signingIn": "Signing In", - "device-activity": "Device Activity", - "applications": "Applications", - "applicationsIntroMessage": "Track and manage your app permission to access your account", - "fullName": "{{givenName}} {{familyName}}", - "unknownUser": "Anonymous", - "Keycloak Administration Console": "RH-SSO Administration Console", - "confirmImportClear": "If you clear this file, you need to click Browse button to re-import a valid file", - - "********* MASTHEAD *********": "", - "Sign out": "Sign out", - "Manage account": "Manage account", - "Server info": "Server info", - "Help": "Help" - } - } -} \ No newline at end of file diff --git a/src/page/RealmRolesPage.tsx b/src/realm-roles/RealmRolesSection.tsx similarity index 62% rename from src/page/RealmRolesPage.tsx rename to src/realm-roles/RealmRolesSection.tsx index 429e649f12..62b150db95 100644 --- a/src/page/RealmRolesPage.tsx +++ b/src/realm-roles/RealmRolesSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const RealmRolesPage = () => { +export const RealmRolesSection = () => { return <>The Realm Roles Page; }; diff --git a/src/page/RealmSettingsPage.tsx b/src/realm-settings/RealmSettingsSection.tsx similarity index 61% rename from src/page/RealmSettingsPage.tsx rename to src/realm-settings/RealmSettingsSection.tsx index 372d6e4ca1..ef615697fc 100644 --- a/src/page/RealmSettingsPage.tsx +++ b/src/realm-settings/RealmSettingsSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const RealmSettingsPage = () => { +export const RealmSettingsSection = () => { return <>The Realm Settings Page; }; diff --git a/src/forms/realm/NewRealmForm.tsx b/src/realm/add/NewRealmForm.tsx similarity index 75% rename from src/forms/realm/NewRealmForm.tsx rename to src/realm/add/NewRealmForm.tsx index 732dd25e65..7370d5f550 100644 --- a/src/forms/realm/NewRealmForm.tsx +++ b/src/realm/add/NewRealmForm.tsx @@ -12,12 +12,14 @@ import { Button, Divider, } from "@patternfly/react-core"; +import { useTranslation } from "react-i18next"; //type NewRealmFormProps = { // realm: string; //}; export const NewRealmForm = () => { + const { t } = useTranslation("realm"); //({ realm }: NewRealmFormProps) => { return ( <> @@ -29,7 +31,7 @@ export const NewRealmForm = () => {
- + { // isLoading={isLoading} /> - + { // onChange={this.handleTextInputChange2} /> - + - - + +
diff --git a/src/realm/messages.json b/src/realm/messages.json new file mode 100644 index 0000000000..5f8f74829e --- /dev/null +++ b/src/realm/messages.json @@ -0,0 +1,11 @@ +{ + "realm": { + "Upload JSON file":"Upload JSON file", + "Realm name":"Realm name", + "Enabled":"Enabled", + "On": "On", + "Off":"Off", + "Create":"Create", + "Cancel":"Cancel" + } +} diff --git a/src/models/Realm.ts b/src/realm/models/Realm.ts similarity index 100% rename from src/models/Realm.ts rename to src/realm/models/Realm.ts diff --git a/src/page/SessionsPage.tsx b/src/sessions/SessionsSection.tsx similarity index 62% rename from src/page/SessionsPage.tsx rename to src/sessions/SessionsSection.tsx index a902c099dd..c4cb3de3dd 100644 --- a/src/page/SessionsPage.tsx +++ b/src/sessions/SessionsSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const SessionsPage = () => { +export const SessionsSection = () => { return <>The Sessions Page; }; diff --git a/src/stories/ClientList.stories.tsx b/src/stories/ClientList.stories.tsx index 314d01384d..e243bf5150 100644 --- a/src/stories/ClientList.stories.tsx +++ b/src/stories/ClientList.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Meta } from "@storybook/react"; import { ClientList } from "../clients/ClientList"; -import clientMock from "../clients/mock-clients.json"; +import clientMock from "../clients/__tests__/mock-clients.json"; export default { title: "Client List", diff --git a/src/stories/HelpSystem.stories.tsx b/src/stories/HelpSystem.stories.tsx index 958cae6586..8df4c9217a 100644 --- a/src/stories/HelpSystem.stories.tsx +++ b/src/stories/HelpSystem.stories.tsx @@ -14,7 +14,7 @@ import { HelpHeader, } from "../components/help-enabler/HelpHeader"; import { I18nextProvider } from "react-i18next"; -import { i18n } from "../i18n"; +import i18n from "../i18n"; export default { title: "Help System Example", diff --git a/src/stories/RealmForm.stories.tsx b/src/stories/RealmForm.stories.tsx index a7f632b2cc..34960d6e2b 100644 --- a/src/stories/RealmForm.stories.tsx +++ b/src/stories/RealmForm.stories.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Meta } from "@storybook/react"; import { Page } from "@patternfly/react-core"; -import { NewRealmForm } from "../forms/realm/NewRealmForm"; +import { NewRealmForm } from "../realm/add/NewRealmForm"; export default { title: "New reaml form", diff --git a/src/page/UserFederationPage.tsx b/src/user-federation/UserFederationSection.tsx similarity index 61% rename from src/page/UserFederationPage.tsx rename to src/user-federation/UserFederationSection.tsx index f2fd4ae3e6..36eb56256b 100644 --- a/src/page/UserFederationPage.tsx +++ b/src/user-federation/UserFederationSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const UserFederationPage = () => { +export const UserFederationSection = () => { return <>The User Federation Page; }; diff --git a/src/page/UsersPage.tsx b/src/user/UsersSection.tsx similarity index 62% rename from src/page/UsersPage.tsx rename to src/user/UsersSection.tsx index 99aff9b597..e0f7176e30 100644 --- a/src/page/UsersPage.tsx +++ b/src/user/UsersSection.tsx @@ -1,5 +1,5 @@ import React from "react"; -export const UsersPage = () => { +export const UsersSection = () => { return <>The Users Page; }; diff --git a/src/util.ts b/src/util.ts index fcfdf6e7bd..499e1315ee 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,4 @@ -import { ProviderRepresentation } from "./model/server-info"; +import { ProviderRepresentation } from "./clients/models/server-info"; export const sortProvider = ( a: [string, ProviderRepresentation], diff --git a/yarn.lock b/yarn.lock index e0caedf71b..1b2c6dd5ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10457,13 +10457,6 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -i18next-http-backend@^1.0.18: - version "1.0.18" - resolved "https://registry.yarnpkg.com/i18next-http-backend/-/i18next-http-backend-1.0.18.tgz#ec3627c6079366665bd265054edf1fe80614089b" - integrity sha512-YPkSyqJZk8UoJTdmbisx7cPtE+04eOJlShw//O8/sj78xwlgLtqJonOyS0o+Y0ruZgfyQFMSXCZ1M4s6gQYHBw== - dependencies: - node-fetch "2.6.0" - i18next@^19.6.2: version "19.6.2" resolved "https://registry.yarnpkg.com/i18next/-/i18next-19.6.2.tgz#859aeba46db0c7cdfa8ae3de7c3a5cad3b0cec83" @@ -13415,11 +13408,6 @@ node-dir@^0.1.10: dependencies: minimatch "^3.0.2" -node-fetch@2.6.0, node-fetch@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" - integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== - node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -13428,6 +13416,11 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" +node-fetch@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + node-forge@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579"