Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add translations to sales, vouchers and pages
dominik-zeglen35b85f72fe52
diff --git a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsxindex 31c5960ca3..a89f2ce4ac 100644--- a/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationFields/TranslationFields.tsx@@ -142,7 +142,7 @@ const TranslationFields = withStyles(styles, { name: "TranslationFields" })(})}</Typography>{fields.map(field => (- <>+ <React.Fragment key={field.name}><Hr className={classes.hr} /><Typography className={classes.fieldName} variant="body1">{field.displayName}@@ -214,7 +214,7 @@ const TranslationFields = withStyles(styles, { name: "TranslationFields" })(<Skeleton />)}</Typography>- </>+ </React.Fragment>))}</Grid></CardContent>diff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsxindex 98304ecbf4..bbf298880a 100644--- a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsx+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsx@@ -22,6 +22,9 @@ export interface TranslationsEntitiesFilters {onCategoriesTabClick: () => void;onCollectionsTabClick: () => void;onProductsTabClick: () => void;+ onSalesTabClick: () => void;+ onVouchersTabClick: () => void;+ onPagesTabClick: () => void;}export type TranslationsEntitiesListFilterTab = keyof typeof TranslatableEntities;@@ -42,7 +45,10 @@ const TranslationsEntitiesListPage: React.StatelessComponent<currentTab={(["categories","collections",- "products"+ "products",+ "sales",+ "vouchers",+ "pages"] as TranslationsEntitiesListFilterTab[]).indexOf(filters.current)}><FilterTab@@ -57,6 +63,12 @@ const TranslationsEntitiesListPage: React.StatelessComponent<label={i18n.t("Products")}onClick={filters.onProductsTabClick}/>+ <FilterTab label={i18n.t("Sales")} onClick={filters.onSalesTabClick} />+ <FilterTab+ label={i18n.t("Vouchers")}+ onClick={filters.onVouchersTabClick}+ />+ <FilterTab label={i18n.t("Pages")} onClick={filters.onPagesTabClick} /></FilterTabs>{children}</Card>diff --git a/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsxnew file mode 100644index 0000000000..c254e125b7--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx@@ -0,0 +1,110 @@+import * as React from "react";++import CardSpacer from "../../../components/CardSpacer";+import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";+import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import { PageTranslationFragment } from "../../types/PageTranslationFragment";+import TranslationFields from "../TranslationFields";++export interface TranslationsPagesPageProps {+ activeField: string;+ disabled: boolean;+ languageCode: string;+ page: PageTranslationFragment;+ saveButtonState: ConfirmButtonTransitionState;+ onEdit: (field: string) => void;+ onSubmit: (field: string, data: string) => void;+}++export const fieldNames = {+ contentJson: "content",+ seoDescription: "seoDescription",+ seoTitle: "seoTitle",+ title: "title"+};++const TranslationsPagesPage: React.StatelessComponent<+ TranslationsPagesPageProps+> = ({+ activeField,+ disabled,+ languageCode,+ page,+ saveButtonState,+ onEdit,+ onSubmit+}) => (+ <Container>+ <PageHeader+ title={i18n.t('Translation Page "{{ pageName }}" - {{ languageCode }}', {+ context: "page translation page title",+ languageCode,+ pageName: maybe(() => page.title, "...")+ })}+ />+ <TranslationFields+ activeField={activeField}+ disabled={disabled}+ initialState={true}+ title={i18n.t("General Information")}+ fields={[+ {+ displayName: i18n.t("Page Title"),+ name: fieldNames.title,+ translation: maybe(() =>+ page.translation ? page.translation.title : null+ ),+ type: "short" as "short",+ value: maybe(() => page.title)+ },+ {+ displayName: i18n.t("Content"),+ name: fieldNames.contentJson,+ translation: maybe(() =>+ page.translation ? page.translation.contentJson : null+ ),+ type: "rich" as "rich",+ value: maybe(() => page.contentJson)+ }+ ]}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={onSubmit}+ />+ <CardSpacer />+ <TranslationFields+ activeField={activeField}+ disabled={disabled}+ initialState={true}+ title={i18n.t("Search Engine Preview")}+ fields={[+ {+ displayName: i18n.t("Search Engine Title"),+ name: fieldNames.seoTitle,+ translation: maybe(() =>+ page.translation ? page.translation.seoTitle : null+ ),+ type: "short" as "short",+ value: maybe(() => page.seoTitle)+ },+ {+ displayName: i18n.t("Search Engine Description"),+ name: fieldNames.seoDescription,+ translation: maybe(() =>+ page.translation ? page.translation.seoDescription : null+ ),+ type: "long" as "long",+ value: maybe(() => page.seoDescription)+ }+ ]}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={onSubmit}+ />+ </Container>+);+TranslationsPagesPage.displayName = "TranslationsPagesPage";+export default TranslationsPagesPage;diff --git a/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/index.ts b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/index.tsnew file mode 100644index 0000000000..b4546e835d--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsPagesPage/index.ts@@ -0,0 +1,2 @@+export { default } from "./TranslationsPagesPage";+export * from "./TranslationsPagesPage";diff --git a/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsxnew file mode 100644index 0000000000..ae361cf5ff--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx@@ -0,0 +1,67 @@+import * as React from "react";++import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";+import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import { SaleTranslationFragment } from "../../types/SaleTranslationFragment";+import TranslationFields from "../TranslationFields";++export interface TranslationsSalesPageProps {+ activeField: string;+ disabled: boolean;+ languageCode: string;+ sale: SaleTranslationFragment;+ saveButtonState: ConfirmButtonTransitionState;+ onEdit: (field: string) => void;+ onSubmit: (field: string, data: string) => void;+}++export const fieldNames = {+ name: "name"+};++const TranslationsSalesPage: React.StatelessComponent<+ TranslationsSalesPageProps+> = ({+ activeField,+ disabled,+ languageCode,+ sale,+ saveButtonState,+ onEdit,+ onSubmit+}) => (+ <Container>+ <PageHeader+ title={i18n.t('Translation Sale "{{ saleName }}" - {{ languageCode }}', {+ context: "sale translation page title",+ languageCode,+ saleName: maybe(() => sale.name, "...")+ })}+ />+ <TranslationFields+ activeField={activeField}+ disabled={disabled}+ initialState={true}+ title={i18n.t("General Information")}+ fields={[+ {+ displayName: i18n.t("Sale Name"),+ name: fieldNames.name,+ translation: maybe(() =>+ sale.translation ? sale.translation.name : null+ ),+ type: "short" as "short",+ value: maybe(() => sale.name)+ }+ ]}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={onSubmit}+ />+ </Container>+);+TranslationsSalesPage.displayName = "TranslationsSalesPage";+export default TranslationsSalesPage;diff --git a/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/index.ts b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/index.tsnew file mode 100644index 0000000000..864fb89318--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsSalesPage/index.ts@@ -0,0 +1,2 @@+export { default } from "./TranslationsSalesPage";+export * from "./TranslationsSalesPage";diff --git a/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsxnew file mode 100644index 0000000000..d13b615404--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx@@ -0,0 +1,70 @@+import * as React from "react";++import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";+import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import { VoucherTranslationFragment } from "../../types/VoucherTranslationFragment";+import TranslationFields from "../TranslationFields";++export interface TranslationsVouchersPageProps {+ activeField: string;+ disabled: boolean;+ languageCode: string;+ voucher: VoucherTranslationFragment;+ saveButtonState: ConfirmButtonTransitionState;+ onEdit: (field: string) => void;+ onSubmit: (field: string, data: string) => void;+}++export const fieldNames = {+ name: "name"+};++const TranslationsVouchersPage: React.StatelessComponent<+ TranslationsVouchersPageProps+> = ({+ activeField,+ disabled,+ languageCode,+ voucher,+ saveButtonState,+ onEdit,+ onSubmit+}) => (+ <Container>+ <PageHeader+ title={i18n.t(+ 'Translation Voucher "{{ voucherName }}" - {{ languageCode }}',+ {+ context: "voucher translation page title",+ languageCode,+ voucherName: maybe(() => voucher.name, "...")+ }+ )}+ />+ <TranslationFields+ activeField={activeField}+ disabled={disabled}+ initialState={true}+ title={i18n.t("General Information")}+ fields={[+ {+ displayName: i18n.t("Voucher Name"),+ name: fieldNames.name,+ translation: maybe(() =>+ voucher.translation ? voucher.translation.name : null+ ),+ type: "short" as "short",+ value: maybe(() => voucher.name)+ }+ ]}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={onSubmit}+ />+ </Container>+);+TranslationsVouchersPage.displayName = "TranslationsVouchersPage";+export default TranslationsVouchersPage;diff --git a/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/index.ts b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/index.tsnew file mode 100644index 0000000000..926a5618fa--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsVouchersPage/index.ts@@ -0,0 +1,2 @@+export { default } from "./TranslationsVouchersPage";+export * from "./TranslationsVouchersPage";diff --git a/saleor/static/dashboard-next/translations/index.tsx b/saleor/static/dashboard-next/translations/index.tsxindex b0f9d6cc50..bfb52a89a6 100644--- a/saleor/static/dashboard-next/translations/index.tsx+++ b/saleor/static/dashboard-next/translations/index.tsx@@ -21,9 +21,18 @@ import TranslationsEntitiesComponent, {TranslationsEntitiesListQueryParams} from "./views/TranslationsEntities";import TranslationsLanguageList from "./views/TranslationsLanguageList";+import TranslationsPagesComponent, {+ TranslationsPagesQueryParams+} from "./views/TranslationsPages";import TranslationsProductsComponent, {TranslationsProductsQueryParams} from "./views/TranslationsProducts";+import TranslationsSaleComponent, {+ TranslationsSalesQueryParams+} from "./views/TranslationsSales";+import TranslationsVouchersComponent, {+ TranslationsVouchersQueryParams+} from "./views/TranslationsVouchers";type TranslationsEntitiesRouteProps = RouteComponentProps<{languageCode: string;@@ -97,6 +106,54 @@ const TranslationsProducts: React.FC<TranslationsEntityRouteProps> = ({/>);};+const TranslationsSales: React.FC<TranslationsEntityRouteProps> = ({+ location,+ match+}) => {+ const qs = parseQs(location.search.substr(1));+ const params: TranslationsSalesQueryParams = {+ activeField: qs.activeField+ };+ return (+ <TranslationsSaleComponent+ id={decodeURIComponent(match.params.id)}+ languageCode={LanguageCodeEnum[match.params.languageCode]}+ params={params}+ />+ );+};+const TranslationsVouchers: React.FC<TranslationsEntityRouteProps> = ({+ location,+ match+}) => {+ const qs = parseQs(location.search.substr(1));+ const params: TranslationsVouchersQueryParams = {+ activeField: qs.activeField+ };+ return (+ <TranslationsVouchersComponent+ id={decodeURIComponent(match.params.id)}+ languageCode={LanguageCodeEnum[match.params.languageCode]}+ params={params}+ />+ );+};+const TranslationsPages: React.FC<TranslationsEntityRouteProps> = ({+ location,+ match+}) => {+ const qs = parseQs(location.search.substr(1));+ const params: TranslationsPagesQueryParams = {+ activeField: qs.activeField+ };+ return (+ <TranslationsPagesComponent+ id={decodeURIComponent(match.params.id)}+ languageCode={LanguageCodeEnum[match.params.languageCode]}+ params={params}+ />+ );+};const TranslationsRouter: React.FC = () => (<>@@ -139,6 +196,33 @@ const TranslationsRouter: React.FC = () => ()}component={TranslationsCollections}/>+ <Route+ exact+ path={languageEntityPath(+ ":languageCode",+ TranslatableEntities.sales,+ ":id"+ )}+ component={TranslationsSales}+ />+ <Route+ exact+ path={languageEntityPath(+ ":languageCode",+ TranslatableEntities.vouchers,+ ":id"+ )}+ component={TranslationsVouchers}+ />+ <Route+ exact+ path={languageEntityPath(+ ":languageCode",+ TranslatableEntities.pages,+ ":id"+ )}+ component={TranslationsPages}+ /></Switch></>);diff --git a/saleor/static/dashboard-next/translations/mutations.ts b/saleor/static/dashboard-next/translations/mutations.tsindex f7e8857c13..2836660904 100644--- a/saleor/static/dashboard-next/translations/mutations.ts+++ b/saleor/static/dashboard-next/translations/mutations.ts@@ -4,7 +4,10 @@ import { TypedMutation } from "../mutations";import {categoryTranslationFragment,collectionTranslationFragment,- productTranslationFragment+ pageTranslationFragment,+ productTranslationFragment,+ saleTranslationFragment,+ voucherTranslationFragment} from "./queries";import {UpdateCategoryTranslations,@@ -14,10 +17,22 @@ import {UpdateCollectionTranslations,UpdateCollectionTranslationsVariables} from "./types/UpdateCollectionTranslations";+import {+ UpdatePageTranslations,+ UpdatePageTranslationsVariables+} from "./types/UpdatePageTranslations";import {UpdateProductTranslations,UpdateProductTranslationsVariables} from "./types/UpdateProductTranslations";+import {+ UpdateSaleTranslations,+ UpdateSaleTranslationsVariables+} from "./types/UpdateSaleTranslations";+import {+ UpdateVoucherTranslations,+ UpdateVoucherTranslationsVariables+} from "./types/UpdateVoucherTranslations";const updateProductTranslations = gql`${productTranslationFragment}@@ -87,3 +102,72 @@ export const TypedUpdateCollectionTranslations = TypedMutation<UpdateCollectionTranslations,UpdateCollectionTranslationsVariables>(updateCollectionTranslations);++const updatePageTranslations = gql`+ ${pageTranslationFragment}+ mutation UpdatePageTranslations(+ $id: ID!+ $input: PageTranslationInput!+ $language: LanguageCodeEnum!+ ) {+ pageTranslate(id: $id, input: $input, languageCode: $language) {+ errors {+ field+ message+ }+ page {+ ...PageTranslationFragment+ }+ }+ }+`;+export const TypedUpdatePageTranslations = TypedMutation<+ UpdatePageTranslations,+ UpdatePageTranslationsVariables+>(updatePageTranslations);++const updateVoucherTranslations = gql`+ ${voucherTranslationFragment}+ mutation UpdateVoucherTranslations(+ $id: ID!+ $input: NameTranslationInput!+ $language: LanguageCodeEnum!+ ) {+ voucherTranslate(id: $id, input: $input, languageCode: $language) {+ errors {+ field+ message+ }+ voucher {+ ...VoucherTranslationFragment+ }+ }+ }+`;+export const TypedUpdateVoucherTranslations = TypedMutation<+ UpdateVoucherTranslations,+ UpdateVoucherTranslationsVariables+>(updateVoucherTranslations);++const updateSaleTranslations = gql`+ ${saleTranslationFragment}+ mutation UpdateSaleTranslations(+ $id: ID!+ $input: NameTranslationInput!+ $language: LanguageCodeEnum!+ ) {+ saleTranslate(id: $id, input: $input, languageCode: $language) {+ errors {+ field+ message+ }+ sale {+ ...SaleTranslationFragment+ }+ }+ }+`;+export const TypedUpdateSaleTranslations = TypedMutation<+ UpdateSaleTranslations,+ UpdateSaleTranslationsVariables+>(updateSaleTranslations);diff --git a/saleor/static/dashboard-next/translations/queries.ts b/saleor/static/dashboard-next/translations/queries.tsindex cb8c774a23..5832a04149 100644--- a/saleor/static/dashboard-next/translations/queries.ts+++ b/saleor/static/dashboard-next/translations/queries.ts@@ -17,6 +17,14 @@ import {CollectionTranslations,CollectionTranslationsVariables} from "./types/CollectionTranslations";+import {+ PageTranslationDetails,+ PageTranslationDetailsVariables+} from "./types/PageTranslationDetails";+import {+ PageTranslations,+ PageTranslationsVariables+} from "./types/PageTranslations";import {ProductTranslationDetails,ProductTranslationDetailsVariables@@ -25,6 +33,22 @@ import {ProductTranslations,ProductTranslationsVariables} from "./types/ProductTranslations";+import {+ SaleTranslationDetails,+ SaleTranslationDetailsVariables+} from "./types/SaleTranslationDetails";+import {+ SaleTranslations,+ SaleTranslationsVariables+} from "./types/SaleTranslations";+import {+ VoucherTranslationDetails,+ VoucherTranslationDetailsVariables+} from "./types/VoucherTranslationDetails";+import {+ VoucherTranslations,+ VoucherTranslationsVariables+} from "./types/VoucherTranslations";export const categoryTranslationFragment = gql`fragment CategoryTranslationFragment on Category {@@ -84,6 +108,69 @@ export const productTranslationFragment = gql`}}`;+export const saleTranslationFragment = gql`+ fragment SaleTranslationFragment on Sale {+ id+ name+ translation(languageCode: $language) {+ id+ language {+ code+ language+ }+ name+ }+ }+`;+export const voucherTranslationFragment = gql`+ fragment VoucherTranslationFragment on Voucher {+ id+ name+ translation(languageCode: $language) {+ id+ language {+ code+ language+ }+ name+ }+ }+`;+export const shippingMethodTranslationFragment = gql`+ fragment ShippingMethodTranslationFragment on ShippingMethod {+ id+ name+ translation(languageCode: $language) {+ id+ language {+ code+ language+ }+ name+ }+ }+`;+export const pageTranslationFragment = gql`+ fragment PageTranslationFragment on Page {+ id+ contentJson+ seoDescription+ seoTitle+ title++ translation(languageCode: $language) {+ id+ contentJson+ seoDescription+ seoTitle+ title+ language {+ code+ language+ }+ }+ }+`;const categoryTranslations = gql`${pageInfoFragment}@@ -166,6 +253,87 @@ export const TypedProductTranslations = TypedQuery<ProductTranslationsVariables>(productTranslations);+const pageTranslations = gql`+ ${pageInfoFragment}+ ${pageTranslationFragment}+ query PageTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ pages(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...PageTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedPageTranslations = TypedQuery<+ PageTranslations,+ PageTranslationsVariables+>(pageTranslations);++const voucherTranslations = gql`+ ${pageInfoFragment}+ ${voucherTranslationFragment}+ query VoucherTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ vouchers(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...VoucherTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedVoucherTranslations = TypedQuery<+ VoucherTranslations,+ VoucherTranslationsVariables+>(voucherTranslations);++const saleTranslations = gql`+ ${pageInfoFragment}+ ${saleTranslationFragment}+ query SaleTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ sales(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...SaleTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedSaleTranslations = TypedQuery<+ SaleTranslations,+ SaleTranslationsVariables+>(saleTranslations);+const productTranslationDetails = gql`${productTranslationFragment}query ProductTranslationDetails($id: ID!, $language: LanguageCodeEnum!) {@@ -204,3 +372,42 @@ export const TypedCollectionTranslationDetails = TypedQuery<CollectionTranslationDetails,CollectionTranslationDetailsVariables>(collectionTranslationDetails);++const pageTranslationDetails = gql`+ ${pageTranslationFragment}+ query PageTranslationDetails($id: ID!, $language: LanguageCodeEnum!) {+ page(id: $id) {+ ...PageTranslationFragment+ }+ }+`;+export const TypedPageTranslationDetails = TypedQuery<+ PageTranslationDetails,+ PageTranslationDetailsVariables+>(pageTranslationDetails);++const saleTranslationDetails = gql`+ ${saleTranslationFragment}+ query SaleTranslationDetails($id: ID!, $language: LanguageCodeEnum!) {+ sale(id: $id) {+ ...SaleTranslationFragment+ }+ }+`;+export const TypedSaleTranslationDetails = TypedQuery<+ SaleTranslationDetails,+ SaleTranslationDetailsVariables+>(saleTranslationDetails);++const voucherTranslationDetails = gql`+ ${voucherTranslationFragment}+ query VoucherTranslationDetails($id: ID!, $language: LanguageCodeEnum!) {+ voucher(id: $id) {+ ...VoucherTranslationFragment+ }+ }+`;+export const TypedVoucherTranslationDetails = TypedQuery<+ VoucherTranslationDetails,+ VoucherTranslationDetailsVariables+>(voucherTranslationDetails);diff --git a/saleor/static/dashboard-next/translations/types/PageTranslationDetails.ts b/saleor/static/dashboard-next/translations/types/PageTranslationDetails.tsnew file mode 100644index 0000000000..8763d2c4c9--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/PageTranslationDetails.ts@@ -0,0 +1,44 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: PageTranslationDetails+// ====================================================++export interface PageTranslationDetails_page_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface PageTranslationDetails_page_translation {+ __typename: "PageTranslation";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ language: PageTranslationDetails_page_translation_language;+}++export interface PageTranslationDetails_page {+ __typename: "Page";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ translation: PageTranslationDetails_page_translation | null;+}++export interface PageTranslationDetails {+ page: PageTranslationDetails_page | null;+}++export interface PageTranslationDetailsVariables {+ id: string;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/PageTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/PageTranslationFragment.tsnew file mode 100644index 0000000000..cbbd01c62b--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/PageTranslationFragment.ts@@ -0,0 +1,35 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: PageTranslationFragment+// ====================================================++export interface PageTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface PageTranslationFragment_translation {+ __typename: "PageTranslation";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ language: PageTranslationFragment_translation_language;+}++export interface PageTranslationFragment {+ __typename: "Page";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ translation: PageTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/PageTranslations.ts b/saleor/static/dashboard-next/translations/types/PageTranslations.tsnew file mode 100644index 0000000000..d9ac202218--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/PageTranslations.ts@@ -0,0 +1,66 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: PageTranslations+// ====================================================++export interface PageTranslations_pages_edges_node_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface PageTranslations_pages_edges_node_translation {+ __typename: "PageTranslation";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ language: PageTranslations_pages_edges_node_translation_language;+}++export interface PageTranslations_pages_edges_node {+ __typename: "Page";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ translation: PageTranslations_pages_edges_node_translation | null;+}++export interface PageTranslations_pages_edges {+ __typename: "PageCountableEdge";+ node: PageTranslations_pages_edges_node;+}++export interface PageTranslations_pages_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface PageTranslations_pages {+ __typename: "PageCountableConnection";+ edges: PageTranslations_pages_edges[];+ pageInfo: PageTranslations_pages_pageInfo;+}++export interface PageTranslations {+ pages: PageTranslations_pages | null;+}++export interface PageTranslationsVariables {+ language: LanguageCodeEnum;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/types/SaleTranslationDetails.ts b/saleor/static/dashboard-next/translations/types/SaleTranslationDetails.tsnew file mode 100644index 0000000000..2fe0c1c9b9--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/SaleTranslationDetails.ts@@ -0,0 +1,38 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: SaleTranslationDetails+// ====================================================++export interface SaleTranslationDetails_sale_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface SaleTranslationDetails_sale_translation {+ __typename: "SaleTranslation";+ id: string;+ language: SaleTranslationDetails_sale_translation_language;+ name: string | null;+}++export interface SaleTranslationDetails_sale {+ __typename: "Sale";+ id: string;+ name: string;+ translation: SaleTranslationDetails_sale_translation | null;+}++export interface SaleTranslationDetails {+ sale: SaleTranslationDetails_sale | null;+}++export interface SaleTranslationDetailsVariables {+ id: string;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/SaleTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/SaleTranslationFragment.tsnew file mode 100644index 0000000000..3978bf69e8--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/SaleTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: SaleTranslationFragment+// ====================================================++export interface SaleTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface SaleTranslationFragment_translation {+ __typename: "SaleTranslation";+ id: string;+ language: SaleTranslationFragment_translation_language;+ name: string | null;+}++export interface SaleTranslationFragment {+ __typename: "Sale";+ id: string;+ name: string;+ translation: SaleTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/SaleTranslations.ts b/saleor/static/dashboard-next/translations/types/SaleTranslations.tsnew file mode 100644index 0000000000..d014353ca2--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/SaleTranslations.ts@@ -0,0 +1,60 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: SaleTranslations+// ====================================================++export interface SaleTranslations_sales_edges_node_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface SaleTranslations_sales_edges_node_translation {+ __typename: "SaleTranslation";+ id: string;+ language: SaleTranslations_sales_edges_node_translation_language;+ name: string | null;+}++export interface SaleTranslations_sales_edges_node {+ __typename: "Sale";+ id: string;+ name: string;+ translation: SaleTranslations_sales_edges_node_translation | null;+}++export interface SaleTranslations_sales_edges {+ __typename: "SaleCountableEdge";+ node: SaleTranslations_sales_edges_node;+}++export interface SaleTranslations_sales_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface SaleTranslations_sales {+ __typename: "SaleCountableConnection";+ edges: SaleTranslations_sales_edges[];+ pageInfo: SaleTranslations_sales_pageInfo;+}++export interface SaleTranslations {+ sales: SaleTranslations_sales | null;+}++export interface SaleTranslationsVariables {+ language: LanguageCodeEnum;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/types/ShippingMethodTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/ShippingMethodTranslationFragment.tsnew file mode 100644index 0000000000..565d2b42bd--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/ShippingMethodTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: ShippingMethodTranslationFragment+// ====================================================++export interface ShippingMethodTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface ShippingMethodTranslationFragment_translation {+ __typename: "ShippingMethodTranslation";+ id: string;+ language: ShippingMethodTranslationFragment_translation_language;+ name: string | null;+}++export interface ShippingMethodTranslationFragment {+ __typename: "ShippingMethod";+ id: string;+ name: string;+ translation: ShippingMethodTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/UpdatePageTranslations.ts b/saleor/static/dashboard-next/translations/types/UpdatePageTranslations.tsnew file mode 100644index 0000000000..020ef5c04c--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/UpdatePageTranslations.ts@@ -0,0 +1,57 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { PageTranslationInput, LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL mutation operation: UpdatePageTranslations+// ====================================================++export interface UpdatePageTranslations_pageTranslate_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface UpdatePageTranslations_pageTranslate_page_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface UpdatePageTranslations_pageTranslate_page_translation {+ __typename: "PageTranslation";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ language: UpdatePageTranslations_pageTranslate_page_translation_language;+}++export interface UpdatePageTranslations_pageTranslate_page {+ __typename: "Page";+ id: string;+ contentJson: any;+ seoDescription: string | null;+ seoTitle: string | null;+ title: string;+ translation: UpdatePageTranslations_pageTranslate_page_translation | null;+}++export interface UpdatePageTranslations_pageTranslate {+ __typename: "PageTranslate";+ errors: UpdatePageTranslations_pageTranslate_errors[] | null;+ page: UpdatePageTranslations_pageTranslate_page | null;+}++export interface UpdatePageTranslations {+ pageTranslate: UpdatePageTranslations_pageTranslate | null;+}++export interface UpdatePageTranslationsVariables {+ id: string;+ input: PageTranslationInput;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/UpdateSaleTranslations.ts b/saleor/static/dashboard-next/translations/types/UpdateSaleTranslations.tsnew file mode 100644index 0000000000..f503df7f59--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/UpdateSaleTranslations.ts@@ -0,0 +1,51 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { NameTranslationInput, LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL mutation operation: UpdateSaleTranslations+// ====================================================++export interface UpdateSaleTranslations_saleTranslate_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface UpdateSaleTranslations_saleTranslate_sale_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface UpdateSaleTranslations_saleTranslate_sale_translation {+ __typename: "SaleTranslation";+ id: string;+ language: UpdateSaleTranslations_saleTranslate_sale_translation_language;+ name: string | null;+}++export interface UpdateSaleTranslations_saleTranslate_sale {+ __typename: "Sale";+ id: string;+ name: string;+ translation: UpdateSaleTranslations_saleTranslate_sale_translation | null;+}++export interface UpdateSaleTranslations_saleTranslate {+ __typename: "SaleTranslate";+ errors: UpdateSaleTranslations_saleTranslate_errors[] | null;+ sale: UpdateSaleTranslations_saleTranslate_sale | null;+}++export interface UpdateSaleTranslations {+ saleTranslate: UpdateSaleTranslations_saleTranslate | null;+}++export interface UpdateSaleTranslationsVariables {+ id: string;+ input: NameTranslationInput;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/UpdateVoucherTranslations.ts b/saleor/static/dashboard-next/translations/types/UpdateVoucherTranslations.tsnew file mode 100644index 0000000000..e5fdf47719--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/UpdateVoucherTranslations.ts@@ -0,0 +1,51 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { NameTranslationInput, LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL mutation operation: UpdateVoucherTranslations+// ====================================================++export interface UpdateVoucherTranslations_voucherTranslate_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface UpdateVoucherTranslations_voucherTranslate_voucher_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface UpdateVoucherTranslations_voucherTranslate_voucher_translation {+ __typename: "VoucherTranslation";+ id: string;+ language: UpdateVoucherTranslations_voucherTranslate_voucher_translation_language;+ name: string | null;+}++export interface UpdateVoucherTranslations_voucherTranslate_voucher {+ __typename: "Voucher";+ id: string;+ name: string | null;+ translation: UpdateVoucherTranslations_voucherTranslate_voucher_translation | null;+}++export interface UpdateVoucherTranslations_voucherTranslate {+ __typename: "VoucherTranslate";+ errors: UpdateVoucherTranslations_voucherTranslate_errors[] | null;+ voucher: UpdateVoucherTranslations_voucherTranslate_voucher | null;+}++export interface UpdateVoucherTranslations {+ voucherTranslate: UpdateVoucherTranslations_voucherTranslate | null;+}++export interface UpdateVoucherTranslationsVariables {+ id: string;+ input: NameTranslationInput;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/VoucherTranslationDetails.ts b/saleor/static/dashboard-next/translations/types/VoucherTranslationDetails.tsnew file mode 100644index 0000000000..b14a21093d--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/VoucherTranslationDetails.ts@@ -0,0 +1,38 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: VoucherTranslationDetails+// ====================================================++export interface VoucherTranslationDetails_voucher_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface VoucherTranslationDetails_voucher_translation {+ __typename: "VoucherTranslation";+ id: string;+ language: VoucherTranslationDetails_voucher_translation_language;+ name: string | null;+}++export interface VoucherTranslationDetails_voucher {+ __typename: "Voucher";+ id: string;+ name: string | null;+ translation: VoucherTranslationDetails_voucher_translation | null;+}++export interface VoucherTranslationDetails {+ voucher: VoucherTranslationDetails_voucher | null;+}++export interface VoucherTranslationDetailsVariables {+ id: string;+ language: LanguageCodeEnum;+}diff --git a/saleor/static/dashboard-next/translations/types/VoucherTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/VoucherTranslationFragment.tsnew file mode 100644index 0000000000..080d3489c6--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/VoucherTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: VoucherTranslationFragment+// ====================================================++export interface VoucherTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface VoucherTranslationFragment_translation {+ __typename: "VoucherTranslation";+ id: string;+ language: VoucherTranslationFragment_translation_language;+ name: string | null;+}++export interface VoucherTranslationFragment {+ __typename: "Voucher";+ id: string;+ name: string | null;+ translation: VoucherTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/VoucherTranslations.ts b/saleor/static/dashboard-next/translations/types/VoucherTranslations.tsnew file mode 100644index 0000000000..5a16149088--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/VoucherTranslations.ts@@ -0,0 +1,60 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: VoucherTranslations+// ====================================================++export interface VoucherTranslations_vouchers_edges_node_translation_language {+ __typename: "LanguageDisplay";+ code: LanguageCodeEnum;+ language: string;+}++export interface VoucherTranslations_vouchers_edges_node_translation {+ __typename: "VoucherTranslation";+ id: string;+ language: VoucherTranslations_vouchers_edges_node_translation_language;+ name: string | null;+}++export interface VoucherTranslations_vouchers_edges_node {+ __typename: "Voucher";+ id: string;+ name: string | null;+ translation: VoucherTranslations_vouchers_edges_node_translation | null;+}++export interface VoucherTranslations_vouchers_edges {+ __typename: "VoucherCountableEdge";+ node: VoucherTranslations_vouchers_edges_node;+}++export interface VoucherTranslations_vouchers_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherTranslations_vouchers {+ __typename: "VoucherCountableConnection";+ edges: VoucherTranslations_vouchers_edges[];+ pageInfo: VoucherTranslations_vouchers_pageInfo;+}++export interface VoucherTranslations {+ vouchers: VoucherTranslations_vouchers | null;+}++export interface VoucherTranslationsVariables {+ language: LanguageCodeEnum;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/urls.ts b/saleor/static/dashboard-next/translations/urls.tsindex 549fdb8ed7..b50e3c3b1a 100644--- a/saleor/static/dashboard-next/translations/urls.ts+++ b/saleor/static/dashboard-next/translations/urls.ts@@ -12,7 +12,10 @@ export const languageEntitiesUrl = languageEntitiesPath;export enum TranslatableEntities {categories = "categories",products = "products",- collections = "collections"+ collections = "collections",+ sales = "sales",+ vouchers = "vouchers",+ pages = "pages"}export const languageEntityPath = (diff --git a/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsx b/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsxindex b2b80cbc9e..aba995ede6 100644--- a/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsx+++ b/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsx@@ -14,7 +14,10 @@ import TranslationsEntitiesListPage, {import {TypedCategoryTranslations,TypedCollectionTranslations,- TypedProductTranslations+ TypedPageTranslations,+ TypedProductTranslations,+ TypedSaleTranslations,+ TypedVoucherTranslations} from "../queries";import {languageEntityUrl,@@ -66,12 +69,33 @@ const TranslationsEntities: React.FC<TranslationsEntitiesProps> = ({tab: TranslatableEntities.collections})),+ onPagesTabClick: () =>+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.pages+ })+ ),onProductsTabClick: () =>navigate("?" +stringifyQs({tab: TranslatableEntities.products})+ ),+ onSalesTabClick: () =>+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.sales+ })+ ),+ onVouchersTabClick: () =>+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.vouchers+ }))};const lang = maybe(() =>@@ -244,6 +268,138 @@ const TranslationsEntities: React.FC<TranslationsEntitiesProps> = ({);}}</TypedCollectionTranslations>+ ) : params.tab === "sales" ? (+ <TypedSaleTranslations+ variables={{ language: language as any, ...paginationState }}+ >+ {({ data, loading }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.sales.pageInfo),+ paginationState,+ params+ );++ return (+ <TranslationsEntitiesList+ disabled={loading}+ entities={maybe(() =>+ data.sales.edges+ .map(edge => edge.node)+ .map(node => ({+ completion: {+ current: node.translation+ ? +!!node.translation.name+ : 0,+ max: 1+ },+ id: node.id,+ name: node.name+ }))+ )}+ onRowClick={id =>+ navigate(+ languageEntityUrl(language, TranslatableEntities.sales, id)+ )+ }+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ pageInfo={pageInfo}+ />+ );+ }}+ </TypedSaleTranslations>+ ) : params.tab === "vouchers" ? (+ <TypedVoucherTranslations+ variables={{ language: language as any, ...paginationState }}+ >+ {({ data, loading }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.vouchers.pageInfo),+ paginationState,+ params+ );++ return (+ <TranslationsEntitiesList+ disabled={loading}+ entities={maybe(() =>+ data.vouchers.edges+ .map(edge => edge.node)+ .map(node => ({+ completion: {+ current: node.translation+ ? +!!node.translation.name+ : 0,+ max: 1+ },+ id: node.id,+ name: node.name+ }))+ )}+ onRowClick={id =>+ navigate(+ languageEntityUrl(+ language,+ TranslatableEntities.vouchers,+ id+ )+ )+ }+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ pageInfo={pageInfo}+ />+ );+ }}+ </TypedVoucherTranslations>+ ) : params.tab === "pages" ? (+ <TypedPageTranslations+ variables={{ language: language as any, ...paginationState }}+ >+ {({ data, loading }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.pages.pageInfo),+ paginationState,+ params+ );++ return (+ <TranslationsEntitiesList+ disabled={loading}+ entities={maybe(() =>+ data.pages.edges+ .map(edge => edge.node)+ .map(node => ({+ completion: {+ current: node.translation+ ? [+ node.translation.contentJson,+ node.translation.seoDescription,+ node.translation.seoTitle,+ node.translation.title+ ].reduce(+ (acc, field) => acc + (field !== null ? 1 : 0),+ 0+ )+ : 0,+ max: 4+ },+ id: node.id,+ name: node.title+ }))+ )}+ onRowClick={id =>+ navigate(+ languageEntityUrl(language, TranslatableEntities.pages, id)+ )+ }+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ pageInfo={pageInfo}+ />+ );+ }}+ </TypedPageTranslations>) : null}</TranslationsEntitiesListPage>);diff --git a/saleor/static/dashboard-next/translations/views/TranslationsPages.tsx b/saleor/static/dashboard-next/translations/views/TranslationsPages.tsxnew file mode 100644index 0000000000..6ec6fe33f1--- /dev/null+++ b/saleor/static/dashboard-next/translations/views/TranslationsPages.tsx@@ -0,0 +1,104 @@+import { stringify as stringifyQs } from "qs";+import * as React from "react";++import useNavigator from "../../hooks/useNavigator";+import useNotifier from "../../hooks/useNotifier";+import i18n from "../../i18n";+import { getMutationState, maybe } from "../../misc";+import {+ LanguageCodeEnum,+ PageTranslationInput+} from "../../types/globalTypes";+import TranslationsPagesPage, {+ fieldNames+} from "../components/TranslationsPagesPage";+import { TypedUpdatePageTranslations } from "../mutations";+import { TypedPageTranslationDetails } from "../queries";+import { UpdatePageTranslations } from "../types/UpdatePageTranslations";++export interface TranslationsPagesQueryParams {+ activeField: string;+}+export interface TranslationsPagesProps {+ id: string;+ languageCode: LanguageCodeEnum;+ params: TranslationsPagesQueryParams;+}++const TranslationsPages: React.FC<TranslationsPagesProps> = ({+ id,+ languageCode,+ params+}) => {+ const navigate = useNavigator();+ const notify = useNotifier();++ const onEdit = (field: string) =>+ navigate(+ "?" ++ stringifyQs({+ activeField: field+ }),+ true+ );+ const onUpdate = (data: UpdatePageTranslations) => {+ if (data.pageTranslate.errors.length === 0) {+ notify({+ text: i18n.t("Translation Saved")+ });+ navigate("?", true);+ }+ };++ return (+ <TypedPageTranslationDetails variables={{ id, language: languageCode }}>+ {pageTranslations => (+ <TypedUpdatePageTranslations onCompleted={onUpdate}>+ {(updateTranslations, updateTranslationsOpts) => {+ const handleSubmit = (field: string, data: string) => {+ const input: PageTranslationInput = {};+ if (field === fieldNames.contentJson) {+ input.contentJson = JSON.stringify(data);+ } else if (field === fieldNames.title) {+ input.title = data;+ } else if (field === fieldNames.seoDescription) {+ input.seoDescription = data;+ } else if (field === fieldNames.seoTitle) {+ input.seoTitle = data;+ }+ updateTranslations({+ variables: {+ id,+ input,+ language: languageCode+ }+ });+ };++ const saveButtonState = getMutationState(+ updateTranslationsOpts.called,+ updateTranslationsOpts.loading,+ maybe(() => updateTranslationsOpts.data.pageTranslate.errors, [])+ );++ return (+ <TranslationsPagesPage+ activeField={params.activeField}+ disabled={+ pageTranslations.loading || updateTranslationsOpts.loading+ }+ languageCode={languageCode}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={handleSubmit}+ page={maybe(() => pageTranslations.data.page)}+ />+ );+ }}+ </TypedUpdatePageTranslations>+ )}+ </TypedPageTranslationDetails>+ );+};+TranslationsPages.displayName = "TranslationsPages";+export default TranslationsPages;diff --git a/saleor/static/dashboard-next/translations/views/TranslationsSales.tsx b/saleor/static/dashboard-next/translations/views/TranslationsSales.tsxnew file mode 100644index 0000000000..af593e573b--- /dev/null+++ b/saleor/static/dashboard-next/translations/views/TranslationsSales.tsx@@ -0,0 +1,98 @@+import { stringify as stringifyQs } from "qs";+import * as React from "react";++import useNavigator from "../../hooks/useNavigator";+import useNotifier from "../../hooks/useNotifier";+import i18n from "../../i18n";+import { getMutationState, maybe } from "../../misc";+import {+ LanguageCodeEnum,+ NameTranslationInput+} from "../../types/globalTypes";+import TranslationsSalesPage, {+ fieldNames+} from "../components/TranslationsSalesPage";+import { TypedUpdateSaleTranslations } from "../mutations";+import { TypedSaleTranslationDetails } from "../queries";+import { UpdateSaleTranslations } from "../types/UpdateSaleTranslations";++export interface TranslationsSalesQueryParams {+ activeField: string;+}+export interface TranslationsSalesProps {+ id: string;+ languageCode: LanguageCodeEnum;+ params: TranslationsSalesQueryParams;+}++const TranslationsSales: React.FC<TranslationsSalesProps> = ({+ id,+ languageCode,+ params+}) => {+ const navigate = useNavigator();+ const notify = useNotifier();++ const onEdit = (field: string) =>+ navigate(+ "?" ++ stringifyQs({+ activeField: field+ }),+ true+ );+ const onUpdate = (data: UpdateSaleTranslations) => {+ if (data.saleTranslate.errors.length === 0) {+ notify({+ text: i18n.t("Translation Saved")+ });+ navigate("?", true);+ }+ };++ return (+ <TypedSaleTranslationDetails variables={{ id, language: languageCode }}>+ {saleTranslations => (+ <TypedUpdateSaleTranslations onCompleted={onUpdate}>+ {(updateTranslations, updateTranslationsOpts) => {+ const handleSubmit = (field: string, data: string) => {+ const input: NameTranslationInput = {};+ if (field === fieldNames.name) {+ input.name = data;+ }+ updateTranslations({+ variables: {+ id,+ input,+ language: languageCode+ }+ });+ };++ const saveButtonState = getMutationState(+ updateTranslationsOpts.called,+ updateTranslationsOpts.loading,+ maybe(() => updateTranslationsOpts.data.saleTranslate.errors, [])+ );++ return (+ <TranslationsSalesPage+ activeField={params.activeField}+ disabled={+ saleTranslations.loading || updateTranslationsOpts.loading+ }+ languageCode={languageCode}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={handleSubmit}+ sale={maybe(() => saleTranslations.data.sale)}+ />+ );+ }}+ </TypedUpdateSaleTranslations>+ )}+ </TypedSaleTranslationDetails>+ );+};+TranslationsSales.displayName = "TranslationsSales";+export default TranslationsSales;diff --git a/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsx b/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsxnew file mode 100644index 0000000000..b8f483433b--- /dev/null+++ b/saleor/static/dashboard-next/translations/views/TranslationsVouchers.tsx@@ -0,0 +1,101 @@+import { stringify as stringifyQs } from "qs";+import * as React from "react";++import useNavigator from "../../hooks/useNavigator";+import useNotifier from "../../hooks/useNotifier";+import i18n from "../../i18n";+import { getMutationState, maybe } from "../../misc";+import {+ LanguageCodeEnum,+ NameTranslationInput+} from "../../types/globalTypes";+import TranslationsVouchersPage, {+ fieldNames+} from "../components/TranslationsVouchersPage";+import { TypedUpdateVoucherTranslations } from "../mutations";+import { TypedVoucherTranslationDetails } from "../queries";+import { UpdateVoucherTranslations } from "../types/UpdateVoucherTranslations";++export interface TranslationsVouchersQueryParams {+ activeField: string;+}+export interface TranslationsVouchersProps {+ id: string;+ languageCode: LanguageCodeEnum;+ params: TranslationsVouchersQueryParams;+}++const TranslationsVouchers: React.FC<TranslationsVouchersProps> = ({+ id,+ languageCode,+ params+}) => {+ const navigate = useNavigator();+ const notify = useNotifier();++ const onEdit = (field: string) =>+ navigate(+ "?" ++ stringifyQs({+ activeField: field+ }),+ true+ );+ const onUpdate = (data: UpdateVoucherTranslations) => {+ if (data.voucherTranslate.errors.length === 0) {+ notify({+ text: i18n.t("Translation Saved")+ });+ navigate("?", true);+ }+ };++ return (+ <TypedVoucherTranslationDetails variables={{ id, language: languageCode }}>+ {voucherTranslations => (+ <TypedUpdateVoucherTranslations onCompleted={onUpdate}>+ {(updateTranslations, updateTranslationsOpts) => {+ const handleSubmit = (field: string, data: string) => {+ const input: NameTranslationInput = {};+ if (field === fieldNames.name) {+ input.name = data;+ }+ updateTranslations({+ variables: {+ id,+ input,+ language: languageCode+ }+ });+ };++ const saveButtonState = getMutationState(+ updateTranslationsOpts.called,+ updateTranslationsOpts.loading,+ maybe(+ () => updateTranslationsOpts.data.voucherTranslate.errors,+ []+ )+ );++ return (+ <TranslationsVouchersPage+ activeField={params.activeField}+ disabled={+ voucherTranslations.loading || updateTranslationsOpts.loading+ }+ languageCode={languageCode}+ saveButtonState={saveButtonState}+ onEdit={onEdit}+ onSubmit={handleSubmit}+ voucher={maybe(() => voucherTranslations.data.voucher)}+ />+ );+ }}+ </TypedUpdateVoucherTranslations>+ )}+ </TypedVoucherTranslationDetails>+ );+};+TranslationsVouchers.displayName = "TranslationsVouchers";+export default TranslationsVouchers;diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex f339ef3358..724bfb4bf6 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -32,42 +32,10 @@ export enum FulfillmentStatus {}export enum LanguageCodeEnum {- AR = "AR",- AZ = "AZ",- BG = "BG",- BN = "BN",- CA = "CA",- CS = "CS",- DA = "DA",DE = "DE",EN = "EN",ES = "ES",- ET = "ET",- FA = "FA",- FR = "FR",- HI = "HI",- HU = "HU",- ID = "ID",- IT = "IT",- JA = "JA",- KO = "KO",- MN = "MN",- NB = "NB",- NL = "NL",PL = "PL",- PT_BR = "PT_BR",- RO = "RO",- RU = "RU",- SK = "SK",- SR = "SR",- SV = "SV",- SW = "SW",- TH = "TH",- TR = "TR",- UK = "UK",- VI = "VI",- ZH_HANS = "ZH_HANS",- ZH_HANT = "ZH_HANT",}export enum OrderAction {@@ -331,6 +299,10 @@ export interface FulfillmentUpdateTrackingInput {notifyCustomer?: boolean | null;}+export interface NameTranslationInput {+ name?: string | null;+}+export interface OrderAddNoteInput {message?: string | null;}@@ -364,6 +336,14 @@ export interface PageInput {seo?: SeoInput | null;}+export interface PageTranslationInput {+ seoTitle?: string | null;+ seoDescription?: string | null;+ title?: string | null;+ content?: string | null;+ contentJson?: any | null;+}+export interface ProductTypeInput {name?: string | null;hasVariants?: boolean | null;