Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add translations to menu

dominik-zeglen8d070189b97f
diff --git a/saleor/static/dashboard-next/components/AppLayout/menuStructure.ts b/saleor/static/dashboard-next/components/AppLayout/menuStructure.ts
index 7fafc5bf70..c222ae8b6e 100644
--- a/saleor/static/dashboard-next/components/AppLayout/menuStructure.ts
+++ b/saleor/static/dashboard-next/components/AppLayout/menuStructure.ts
@@ -5,6 +5,7 @@ import { saleListUrl, voucherListUrl } from "../../discounts/urls";
import i18n from "../../i18n";
import { orderDraftListUrl, orderListUrl } from "../../orders/urls";
import { productListUrl } from "../../products/urls";
+import { languageListUrl } from "../../translations/urls";
import { PermissionEnum } from "../../types/globalTypes";
export interface IMenuItem {
@@ -68,6 +69,7 @@ const menuStructure: IMenuItem[] = [
permission: PermissionEnum.MANAGE_USERS,
url: customerListUrl
},
+
{
ariaLabel: "discounts",
children: [
@@ -84,6 +86,12 @@ const menuStructure: IMenuItem[] = [
],
label: i18n.t("Discounts", { context: "Menu label" }),
permission: PermissionEnum.MANAGE_DISCOUNTS
+ },
+ {
+ ariaLabel: "translations",
+ label: i18n.t("Translations", { context: "Menu label" }),
+ permission: PermissionEnum.MANAGE_TRANSLATIONS,
+ url: languageListUrl
}
];
export default menuStructure;
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index 23241cc82b..740f53838b 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -42,6 +42,7 @@ import ShippingSection from "./shipping";
import SiteSettingsSection from "./siteSettings";
import StaffSection from "./staff";
import TaxesSection from "./taxes";
+import TranslationsSection from "./translations";
import { PermissionEnum } from "./types/globalTypes";
const cookies = new Cookies();
@@ -195,6 +196,13 @@ const App: React.FC = () => {
path="/shipping"
component={ShippingSection}
/>
+ <SectionRoute
+ permissions={[
+ PermissionEnum.MANAGE_TRANSLATIONS
+ ]}
+ path="/translations"
+ component={TranslationsSection}
+ />
{configurationMenu.filter(menuItem =>
hasPermission(menuItem.permission, user)
).length > 0 && (
diff --git a/saleor/static/dashboard-next/translations/components/TranslationsLanguageList/TranslationsLanguageList.tsx b/saleor/static/dashboard-next/translations/components/TranslationsLanguageList/TranslationsLanguageList.tsx
index 36ba5488d4..b3e0641ca5 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationsLanguageList/TranslationsLanguageList.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationsLanguageList/TranslationsLanguageList.tsx
@@ -51,11 +51,9 @@ const TranslationsLanguageList = withStyles(styles, {
className={!!language ? classes.link : undefined}
hover={!!language}
key={language ? language.code : "skeleton"}
+ onClick={() => onRowClick(language.code)}
>
- <TableCell
- className={classes.capitalize}
- onClick={() => onRowClick(language.code)}
- >
+ <TableCell className={classes.capitalize}>
{maybe<React.ReactNode>(
() => language.language,
<Skeleton />
diff --git a/saleor/static/dashboard-next/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx
index e8d6a8b163..a70ed671b5 100644
--- a/saleor/static/dashboard-next/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx
+++ b/saleor/static/dashboard-next/translations/components/TranslationsLanguageListPage/TranslationsLanguageListPage.tsx
@@ -1,5 +1,5 @@
-import Button from "@material-ui/core/Button";
-import AddIcon from "@material-ui/icons/Add";
+// import Button from "@material-ui/core/Button";
+// import AddIcon from "@material-ui/icons/Add";
import * as React from "react";
import Container from "../../../components/Container";
@@ -10,19 +10,19 @@ import TranslationsLanguageList from "../TranslationsLanguageList";
export interface TranslationsLanguageListPageProps {
languages: ShopInfo_shop_languages[];
- onAdd: () => void;
+ // onAdd: () => void;
onRowClick: (code: string) => void;
}
const TranslationsLanguageListPage: React.StatelessComponent<
TranslationsLanguageListPageProps
-> = ({ languages, onAdd, onRowClick }) => (
+> = ({ languages, onRowClick }) => (
<Container>
- <PageHeader>
- <Button color="primary" variant="contained" onClick={onAdd}>
+ <PageHeader title={i18n.t("Languages")}>
+ {/* <Button color="primary" variant="contained" onClick={onAdd}>
{i18n.t("Add Language")}
<AddIcon />
- </Button>
+ </Button> */}
</PageHeader>
<TranslationsLanguageList languages={languages} onRowClick={onRowClick} />
</Container>
diff --git a/saleor/static/dashboard-next/translations/index.tsx b/saleor/static/dashboard-next/translations/index.tsx
index e69de29bb2..256ef44c39 100644
--- a/saleor/static/dashboard-next/translations/index.tsx
+++ b/saleor/static/dashboard-next/translations/index.tsx
@@ -0,0 +1,22 @@
+import * as React from "react";
+import { Route, RouteComponentProps, Switch } from "react-router-dom";
+
+import { WindowTitle } from "../components/WindowTitle";
+import i18n from "../i18n";
+import { languageListPath } from "./urls";
+import TranslationsLanguageList from "./views/TranslationsLanguageList";
+
+const TranslationsRouter: React.FC = () => (
+ <>
+ <WindowTitle title={i18n.t("Translations")} />
+ <Switch>
+ <Route
+ exact
+ path={languageListPath}
+ component={TranslationsLanguageList}
+ />
+ </Switch>
+ </>
+);
+TranslationsRouter.displayName = "TranslationsRouter";
+export default TranslationsRouter;
diff --git a/saleor/static/dashboard-next/translations/urls.ts b/saleor/static/dashboard-next/translations/urls.ts
index e69de29bb2..01c7dddcb1 100644
--- a/saleor/static/dashboard-next/translations/urls.ts
+++ b/saleor/static/dashboard-next/translations/urls.ts
@@ -0,0 +1,12 @@
+import * as urlJoin from "url-join";
+
+const translationsSection = "/translations/";
+
+export const languageListPath = translationsSection;
+export const languageListUrl = translationsSection;
+
+export const languageEntitiesPath = (code: string) =>
+ urlJoin(translationsSection, code);
+export const languageEntitiesUrl = languageEntitiesPath;
+
+// export const language
diff --git a/saleor/static/dashboard-next/translations/views/TranslationsLanguageList.tsx b/saleor/static/dashboard-next/translations/views/TranslationsLanguageList.tsx
index 92ce43ee49..b454f211bc 100644
--- a/saleor/static/dashboard-next/translations/views/TranslationsLanguageList.tsx
+++ b/saleor/static/dashboard-next/translations/views/TranslationsLanguageList.tsx
@@ -13,7 +13,7 @@ const TranslationsLanguageList: React.FC = () => {
return (
<TranslationsLanguageListPage
languages={maybe(() => shop.languages)}
- onAdd={undefined}
+ // onAdd={undefined}
onRowClick={code => navigate(languageEntitiesUrl(code))}
/>
);