Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add translatable entities list view
dominik-zeglen0c81fb67c2e3
diff --git a/saleor/static/dashboard-next/components/Paginator.tsx b/saleor/static/dashboard-next/components/Paginator.tsxindex 1d56402856..c2605529e0 100644--- a/saleor/static/dashboard-next/components/Paginator.tsx+++ b/saleor/static/dashboard-next/components/Paginator.tsx@@ -9,7 +9,7 @@ export interface PageInfo {hasPreviousPage: boolean;startCursor: string;}-interface PaginationState {+export interface PaginationState {after?: string;before?: string;first?: number;@@ -22,13 +22,11 @@ interface QueryString {}interface PaginatorProps {- children: (- props: {- loadNextPage: () => void;- loadPreviousPage: () => void;- pageInfo: PageInfo;- }- ) => React.ReactElement<any>;+ children: (props: {+ loadNextPage: () => void;+ loadPreviousPage: () => void;+ pageInfo: PageInfo;+ }) => React.ReactElement<any>;pageInfo: PageInfo;paginationState: PaginationState;queryString: QueryString;diff --git a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.tsindex 689ce8f483..b3b4fa6d74 100644--- a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts+++ b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts@@ -2,7 +2,7 @@/* eslint-disable */// This file was automatically generated and should not be edited.-import { WeightUnitsEnum } from "./../../../types/globalTypes";+import { WeightUnitsEnum, LanguageCodeEnum } from "./../../../types/globalTypes";// ====================================================// GraphQL query operation: ShopInfo@@ -28,7 +28,7 @@ export interface ShopInfo_shop_domain {export interface ShopInfo_shop_languages {__typename: "LanguageDisplay";- code: string;+ code: LanguageCodeEnum;language: string;}diff --git a/saleor/static/dashboard-next/hooks/usePaginator.ts b/saleor/static/dashboard-next/hooks/usePaginator.tsnew file mode 100644index 0000000000..842760476a--- /dev/null+++ b/saleor/static/dashboard-next/hooks/usePaginator.ts@@ -0,0 +1,53 @@+import { stringify as stringifyQs } from "qs";++import { PageInfo, PaginationState } from "../components/Paginator";+import { Pagination } from "../types";+import useNavigator from "./useNavigator";++function usePaginator() {+ const navigate = useNavigator();++ function paginate(+ pageInfo: PageInfo,+ paginationState: PaginationState,+ queryString: Pagination+ ) {+ const loadNextPage = () =>+ navigate(+ "?" ++ stringifyQs({+ ...queryString,+ after: pageInfo.endCursor,+ before: undefined+ }),+ true+ );++ const loadPreviousPage = () =>+ navigate(+ "?" ++ stringifyQs({+ ...queryString,+ after: undefined,+ before: pageInfo.startCursor+ }),+ true+ );++ const newPageInfo = pageInfo+ ? {+ ...pageInfo,+ hasNextPage: !!paginationState.before || pageInfo.hasNextPage,+ hasPreviousPage: !!paginationState.after || pageInfo.hasPreviousPage+ }+ : undefined;++ return {+ loadNextPage,+ loadPreviousPage,+ pageInfo: newPageInfo+ };+ }+ return paginate;+}+export default usePaginator;diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex f8146878d5..cc722d5439 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -131,6 +131,7 @@ function loadStories() {require("./stories/taxes/CountryTaxesPage");// Translations+ require("./stories/translations/TranslationsEntitiesListPage");require("./stories/translations/TranslationsLanguageListPage");}diff --git a/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx b/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsxnew file mode 100644index 0000000000..a5963cdcd6--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/translations/TranslationsEntitiesListPage.tsx@@ -0,0 +1,65 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import { pageListProps } from "../../../fixtures";+import TranslationsEntitiesListPage, {+ TranslationsEntitiesListPageProps+} from "../../../translations/components/TranslationsEntitiesListPage";+import { LanguageCodeEnum } from "../../../types/globalTypes";+import Decorator from "../../Decorator";++const props: TranslationsEntitiesListPageProps = {+ ...pageListProps.default,+ entities: [+ {+ completion: {+ current: 3,+ max: 8+ },+ id: "1",+ name: "Some product 1"+ },+ {+ completion: {+ current: 2,+ max: 5+ },+ id: "2",+ name: "Some product 2"+ },+ {+ completion: {+ current: 7,+ max: 11+ },+ id: "3",+ name: "Some product 3"+ }+ ],+ filters: {+ current: "products",+ onCategoriesTabClick: () => undefined,+ onProductsTabClick: () => undefined+ },+ language: {+ __typename: "LanguageDisplay",+ code: LanguageCodeEnum.EN,+ language: "English"+ },+ onBack: () => undefined,+ onRowClick: () => undefined+};++storiesOf("Views / Translations / Entity list", module)+ .addDecorator(Decorator)+ .add("default", () => <TranslationsEntitiesListPage {...props} />)+ .add("loading", () => (+ <TranslationsEntitiesListPage+ {...props}+ entities={undefined}+ disabled={true}+ />+ ))+ .add("no data", () => (+ <TranslationsEntitiesListPage {...props} entities={[]} />+ ));diff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsxnew file mode 100644index 0000000000..7aa25fa3de--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/TranslationsEntitiesList.tsx@@ -0,0 +1,130 @@+import { Omit } from "@material-ui/core";+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";+import Table from "@material-ui/core/Table";+import TableBody from "@material-ui/core/TableBody";+import TableCell from "@material-ui/core/TableCell";+import TableFooter from "@material-ui/core/TableFooter";+import TableHead from "@material-ui/core/TableHead";+import TableRow from "@material-ui/core/TableRow";+import * as classNames from "classnames";+import * as React from "react";+import { ListProps } from "../../../types";++import Skeleton from "../../../components/Skeleton";+import TablePagination from "../../../components/TablePagination";+import i18n from "../../../i18n";+import { maybe, renderCollection } from "../../../misc";++export interface TranslatableEntity {+ id: string;+ name: string;+ completion: {+ current: number;+ max: number;+ };+}++export interface TranslationsEntitiesListProps+ extends Omit<ListProps, "onRowClick"> {+ entities: TranslatableEntity[];+ onRowClick: (code: string) => void;+}++const styles = (theme: Theme) =>+ createStyles({+ tableRow: {+ cursor: "pointer"+ },+ textRight: {+ textAlign: "right"+ },+ wideColumn: {+ width: "80%"+ }+ });+const TranslationsEntitiesList = withStyles(styles, {+ name: "TranslationsEntitiesList"+})(+ ({+ classes,+ disabled,+ entities,+ onNextPage,+ onPreviousPage,+ onRowClick,+ pageInfo+ }: TranslationsEntitiesListProps & WithStyles<typeof styles>) => (+ <Table>+ <TableHead>+ <TableRow>+ <TableCell className={classes.wideColumn}>+ {i18n.t("Name", { context: "table header" })}+ </TableCell>+ <TableCell className={classes.textRight}>+ {i18n.t("Completed Translations", {+ context: "table header"+ })}+ </TableCell>+ </TableRow>+ </TableHead>+ <TableFooter>+ <TableRow>+ <TablePagination+ colSpan={2}+ hasNextPage={+ pageInfo && !disabled ? pageInfo.hasNextPage : undefined+ }+ onNextPage={onNextPage}+ hasPreviousPage={+ pageInfo && !disabled ? pageInfo.hasPreviousPage : undefined+ }+ onPreviousPage={onPreviousPage}+ />+ </TableRow>+ </TableFooter>+ <TableBody>+ {renderCollection(+ entities,+ entity => (+ <TableRow+ className={classNames({+ [classes.tableRow]: !!entity+ })}+ hover={!!entity}+ onClick={entity ? () => onRowClick(entity.id) : undefined}+ key={entity ? entity.id : "skeleton"}+ >+ <TableCell>+ {maybe<React.ReactNode>(() => entity.name, <Skeleton />)}+ </TableCell>+ <TableCell className={classes.textRight}>+ {maybe<React.ReactNode>(+ () =>+ i18n.t("{{ current }} of {{ max }}", {+ context: "translation progress",+ ...entity.completion+ }),+ <Skeleton />+ )}+ </TableCell>+ </TableRow>+ ),+ () => (+ <TableRow>+ <TableCell colSpan={2}>+ {i18n.t("No translatable entities found")}+ </TableCell>+ </TableRow>+ )+ )}+ </TableBody>+ </Table>+ )+);+TranslationsEntitiesList.displayName = "TranslationsEntitiesList";+export default TranslationsEntitiesList;diff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/index.ts b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/index.tsnew file mode 100644index 0000000000..dad1683e0d--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesList/index.ts@@ -0,0 +1,2 @@+export { default } from './TranslationsEntitiesList';+export * from './TranslationsEntitiesList';\ No newline at end of filediff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsx b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsxnew file mode 100644index 0000000000..d410ad8c65--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/TranslationsEntitiesListPage.tsx@@ -0,0 +1,59 @@+import Card from "@material-ui/core/Card";+import * as React from "react";++import AppHeader from "../../../components/AppHeader";+import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import { ShopInfo_shop_languages } from "../../../components/Shop/types/ShopInfo";+import FilterTabs, { FilterTab } from "../../../components/TableFilter";+import i18n from "../../../i18n";+import { TranslatableEntities } from "../../urls";++export interface TranslationsEntitiesListPageProps {+ children: React.ReactNode;+ filters: TranslationsEntitiesFilters;+ language: ShopInfo_shop_languages;+ onBack: () => void;+}++export interface TranslationsEntitiesFilters {+ current: TranslationsEntitiesListFilterTab;+ onCategoriesTabClick: () => void;+ onProductsTabClick: () => void;+}++export type TranslationsEntitiesListFilterTab = keyof typeof TranslatableEntities;++const TranslationsEntitiesListPage: React.StatelessComponent<+ TranslationsEntitiesListPageProps+> = ({ filters, language, onBack, children }) => (+ <Container>+ <AppHeader onBack={onBack}>{i18n.t("Languages")}</AppHeader>+ <PageHeader+ title={i18n.t("Translations to {{ language }}", {+ context: "object translation page header",+ language: language.language+ })}+ />+ <Card>+ <FilterTabs+ currentTab={([+ "categories",+ "products"+ ] as TranslationsEntitiesListFilterTab[]).indexOf(filters.current)}+ >+ <FilterTab+ label={i18n.t("Categories")}+ onClick={filters.onCategoriesTabClick}+ />+ <FilterTab+ label={i18n.t("Products")}+ onClick={filters.onProductsTabClick}+ />+ </FilterTabs>+ {children}+ </Card>+ </Container>+);+TranslationsEntitiesListPage.displayName = "TranslationsEntitiesListPage";+export default TranslationsEntitiesListPage;diff --git a/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/index.ts b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/index.tsnew file mode 100644index 0000000000..4af040422d--- /dev/null+++ b/saleor/static/dashboard-next/translations/components/TranslationsEntitiesListPage/index.ts@@ -0,0 +1,2 @@+export { default } from './TranslationsEntitiesListPage';+export * from './TranslationsEntitiesListPage';\ No newline at end of filediff --git a/saleor/static/dashboard-next/translations/index.tsx b/saleor/static/dashboard-next/translations/index.tsxindex 256ef44c39..9b6573a35a 100644--- a/saleor/static/dashboard-next/translations/index.tsx+++ b/saleor/static/dashboard-next/translations/index.tsx@@ -1,11 +1,36 @@+import { parse as parseQs } from "qs";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 { languageEntitiesPath, languageListPath } from "./urls";+import TranslationsEntitiesComponent, {+ TranslationsEntitiesListQueryParams+} from "./views/TranslationsEntities";import TranslationsLanguageList from "./views/TranslationsLanguageList";+type TranslationsEntitiesRouteProps = RouteComponentProps<{+ languageCode: string;+}>;+const TranslationsEntities: React.FC<TranslationsEntitiesRouteProps> = ({+ location,+ match+}) => {+ const qs = parseQs(location.search.substr(1));+ const params: TranslationsEntitiesListQueryParams = {+ after: qs.after,+ before: qs.before,+ tab: qs.tab+ };+ return (+ <TranslationsEntitiesComponent+ language={match.params.languageCode}+ params={params}+ />+ );+};+const TranslationsRouter: React.FC = () => (<><WindowTitle title={i18n.t("Translations")} />@@ -15,6 +40,11 @@ const TranslationsRouter: React.FC = () => (path={languageListPath}component={TranslationsLanguageList}/>+ <Route+ exact+ path={languageEntitiesPath(":languageCode")}+ component={TranslationsEntities}+ /></Switch></>);diff --git a/saleor/static/dashboard-next/translations/queries.ts b/saleor/static/dashboard-next/translations/queries.tsnew file mode 100644index 0000000000..355588373b--- /dev/null+++ b/saleor/static/dashboard-next/translations/queries.ts@@ -0,0 +1,145 @@+import gql from "graphql-tag";++import { pageInfoFragment, TypedQuery } from "../queries";+import {+ CategoryTranslations,+ CategoryTranslationsVariables+} from "./types/CategoryTranslations";+import {+ CollectionTranslations,+ CollectionTranslationsVariables+} from "./types/CollectionTranslations";+import {+ ProductTranslations,+ ProductTranslationsVariables+} from "./types/ProductTranslations";++export const categoryTranslationFragment = gql`+ fragment CategoryTranslationFragment on Category {+ id+ name+ translation(languageCode: $language) {+ id+ descriptionJson+ language {+ language+ }+ name+ seoDescription+ seoTitle+ }+ }+`;+export const collectionTranslationFragment = gql`+ fragment CollectionTranslationFragment on Collection {+ id+ name+ translation(languageCode: $language) {+ id+ descriptionJson+ language {+ language+ }+ name+ seoDescription+ seoTitle+ }+ }+`;+export const productTranslationFragment = gql`+ fragment ProductTranslationFragment on Product {+ id+ name+ translation(languageCode: $language) {+ id+ descriptionJson+ language {+ language+ }+ name+ seoDescription+ seoTitle+ }+ }+`;++const categoryTranslations = gql`+ ${pageInfoFragment}+ ${categoryTranslationFragment}+ query CategoryTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ categories(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...CategoryTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedCategoryTranslations = TypedQuery<+ CategoryTranslations,+ CategoryTranslationsVariables+>(categoryTranslations);++const collectionTranslations = gql`+ ${pageInfoFragment}+ ${collectionTranslationFragment}+ query CollectionTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ collections(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...CollectionTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedCollectionTranslations = TypedQuery<+ CollectionTranslations,+ CollectionTranslationsVariables+>(collectionTranslations);++const productTranslations = gql`+ ${pageInfoFragment}+ ${productTranslationFragment}+ query ProductTranslations(+ $language: LanguageCodeEnum!+ $first: Int+ $after: String+ $last: Int+ $before: String+ ) {+ products(before: $before, after: $after, first: $first, last: $last) {+ edges {+ node {+ ...ProductTranslationFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const TypedProductTranslations = TypedQuery<+ ProductTranslations,+ ProductTranslationsVariables+>(productTranslations);diff --git a/saleor/static/dashboard-next/translations/types/CategoryTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/CategoryTranslationFragment.tsnew file mode 100644index 0000000000..6c27c1e4fa--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/CategoryTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL fragment: CategoryTranslationFragment+// ====================================================++export interface CategoryTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface CategoryTranslationFragment_translation {+ __typename: "CategoryTranslation";+ id: string;+ descriptionJson: any;+ language: CategoryTranslationFragment_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface CategoryTranslationFragment {+ __typename: "Category";+ id: string;+ name: string;+ translation: CategoryTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/CategoryTranslations.ts b/saleor/static/dashboard-next/translations/types/CategoryTranslations.tsnew file mode 100644index 0000000000..53be14c396--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/CategoryTranslations.ts@@ -0,0 +1,62 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: CategoryTranslations+// ====================================================++export interface CategoryTranslations_categories_edges_node_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface CategoryTranslations_categories_edges_node_translation {+ __typename: "CategoryTranslation";+ id: string;+ descriptionJson: any;+ language: CategoryTranslations_categories_edges_node_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface CategoryTranslations_categories_edges_node {+ __typename: "Category";+ id: string;+ name: string;+ translation: CategoryTranslations_categories_edges_node_translation | null;+}++export interface CategoryTranslations_categories_edges {+ __typename: "CategoryCountableEdge";+ node: CategoryTranslations_categories_edges_node;+}++export interface CategoryTranslations_categories_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface CategoryTranslations_categories {+ __typename: "CategoryCountableConnection";+ edges: CategoryTranslations_categories_edges[];+ pageInfo: CategoryTranslations_categories_pageInfo;+}++export interface CategoryTranslations {+ categories: CategoryTranslations_categories | null;+}++export interface CategoryTranslationsVariables {+ language: LanguageCodeEnum;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/types/CollectionTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/CollectionTranslationFragment.tsnew file mode 100644index 0000000000..e4f48c376e--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/CollectionTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL fragment: CollectionTranslationFragment+// ====================================================++export interface CollectionTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface CollectionTranslationFragment_translation {+ __typename: "CollectionTranslation";+ id: string;+ descriptionJson: any;+ language: CollectionTranslationFragment_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface CollectionTranslationFragment {+ __typename: "Collection";+ id: string;+ name: string;+ translation: CollectionTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/CollectionTranslations.ts b/saleor/static/dashboard-next/translations/types/CollectionTranslations.tsnew file mode 100644index 0000000000..c1bebcc577--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/CollectionTranslations.ts@@ -0,0 +1,62 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: CollectionTranslations+// ====================================================++export interface CollectionTranslations_collections_edges_node_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface CollectionTranslations_collections_edges_node_translation {+ __typename: "CollectionTranslation";+ id: string;+ descriptionJson: any;+ language: CollectionTranslations_collections_edges_node_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface CollectionTranslations_collections_edges_node {+ __typename: "Collection";+ id: string;+ name: string;+ translation: CollectionTranslations_collections_edges_node_translation | null;+}++export interface CollectionTranslations_collections_edges {+ __typename: "CollectionCountableEdge";+ node: CollectionTranslations_collections_edges_node;+}++export interface CollectionTranslations_collections_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface CollectionTranslations_collections {+ __typename: "CollectionCountableConnection";+ edges: CollectionTranslations_collections_edges[];+ pageInfo: CollectionTranslations_collections_pageInfo;+}++export interface CollectionTranslations {+ collections: CollectionTranslations_collections | null;+}++export interface CollectionTranslationsVariables {+ language: LanguageCodeEnum;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/types/LanguageEntities.ts b/saleor/static/dashboard-next/translations/types/LanguageEntities.tsnew file mode 100644index 0000000000..d685a55395--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/LanguageEntities.ts@@ -0,0 +1,93 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum, TranslatableKinds } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: LanguageEntities+// ====================================================++export interface LanguageEntities_translations_edges_node_Collection {+ __typename: "Collection" | "Attribute" | "AttributeValue" | "ProductVariant" | "Page" | "ShippingMethod" | "Voucher" | "MenuItem";+}++export interface LanguageEntities_translations_edges_node_Product_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface LanguageEntities_translations_edges_node_Product_translation {+ __typename: "ProductTranslation";+ id: string;+ description: string;+ descriptionJson: any;+ language: LanguageEntities_translations_edges_node_Product_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface LanguageEntities_translations_edges_node_Product {+ __typename: "Product";+ id: string;+ name: string;+ translation: LanguageEntities_translations_edges_node_Product_translation | null;+}++export interface LanguageEntities_translations_edges_node_Category_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface LanguageEntities_translations_edges_node_Category_translation {+ __typename: "CategoryTranslation";+ id: string;+ description: string;+ descriptionJson: any;+ language: LanguageEntities_translations_edges_node_Category_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface LanguageEntities_translations_edges_node_Category {+ __typename: "Category";+ id: string;+ name: string;+ translation: LanguageEntities_translations_edges_node_Category_translation | null;+}++export type LanguageEntities_translations_edges_node = LanguageEntities_translations_edges_node_Collection | LanguageEntities_translations_edges_node_Product | LanguageEntities_translations_edges_node_Category;++export interface LanguageEntities_translations_edges {+ __typename: "TranslatableItemEdge";+ node: LanguageEntities_translations_edges_node;+}++export interface LanguageEntities_translations_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface LanguageEntities_translations {+ __typename: "TranslatableItemConnection";+ edges: LanguageEntities_translations_edges[];+ pageInfo: LanguageEntities_translations_pageInfo;+}++export interface LanguageEntities {+ translations: LanguageEntities_translations | null;+}++export interface LanguageEntitiesVariables {+ language: LanguageCodeEnum;+ kind: TranslatableKinds;+ first?: number | null;+ after?: string | null;+ last?: number | null;+ before?: string | null;+}diff --git a/saleor/static/dashboard-next/translations/types/ProductTranslationFragment.ts b/saleor/static/dashboard-next/translations/types/ProductTranslationFragment.tsnew file mode 100644index 0000000000..888c8a2661--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/ProductTranslationFragment.ts@@ -0,0 +1,29 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL fragment: ProductTranslationFragment+// ====================================================++export interface ProductTranslationFragment_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface ProductTranslationFragment_translation {+ __typename: "ProductTranslation";+ id: string;+ descriptionJson: any;+ language: ProductTranslationFragment_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface ProductTranslationFragment {+ __typename: "Product";+ id: string;+ name: string;+ translation: ProductTranslationFragment_translation | null;+}diff --git a/saleor/static/dashboard-next/translations/types/ProductTranslations.ts b/saleor/static/dashboard-next/translations/types/ProductTranslations.tsnew file mode 100644index 0000000000..6d91e78390--- /dev/null+++ b/saleor/static/dashboard-next/translations/types/ProductTranslations.ts@@ -0,0 +1,62 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { LanguageCodeEnum } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: ProductTranslations+// ====================================================++export interface ProductTranslations_products_edges_node_translation_language {+ __typename: "LanguageDisplay";+ language: string;+}++export interface ProductTranslations_products_edges_node_translation {+ __typename: "ProductTranslation";+ id: string;+ descriptionJson: any;+ language: ProductTranslations_products_edges_node_translation_language;+ name: string;+ seoDescription: string | null;+ seoTitle: string | null;+}++export interface ProductTranslations_products_edges_node {+ __typename: "Product";+ id: string;+ name: string;+ translation: ProductTranslations_products_edges_node_translation | null;+}++export interface ProductTranslations_products_edges {+ __typename: "ProductCountableEdge";+ node: ProductTranslations_products_edges_node;+}++export interface ProductTranslations_products_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface ProductTranslations_products {+ __typename: "ProductCountableConnection";+ edges: ProductTranslations_products_edges[];+ pageInfo: ProductTranslations_products_pageInfo;+}++export interface ProductTranslations {+ products: ProductTranslations_products | null;+}++export interface ProductTranslationsVariables {+ 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 01c7dddcb1..62969b4756 100644--- a/saleor/static/dashboard-next/translations/urls.ts+++ b/saleor/static/dashboard-next/translations/urls.ts@@ -9,4 +9,18 @@ export const languageEntitiesPath = (code: string) =>urlJoin(translationsSection, code);export const languageEntitiesUrl = languageEntitiesPath;-// export const language+export enum TranslatableEntities {+ categories = "categories",+ products = "products"+}++export const languageEntityPath = (+ code: string,+ entity: TranslatableEntities,+ id: string+) => urlJoin(languageEntitiesPath(code), entity.toString(), id);+export const languageEntityUrl = (+ code: string,+ entity: TranslatableEntities,+ id: string+) => languageEntityPath(code, entity, encodeURIComponent(id));diff --git a/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsx b/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsxnew file mode 100644index 0000000000..9e02a1092c--- /dev/null+++ b/saleor/static/dashboard-next/translations/views/TranslationsEntities.tsx@@ -0,0 +1,190 @@+import { stringify as stringifyQs } from "qs";+import * as React from "react";++import { createPaginationState } from "../../components/Paginator";+import useNavigator from "../../hooks/useNavigator";+import usePaginator from "../../hooks/usePaginator";+import useShop from "../../hooks/useShop";+import { maybe } from "../../misc";+import { Pagination } from "../../types";+import TranslationsEntitiesList from "../components/TranslationsEntitiesList";+import TranslationsEntitiesListPage, {+ TranslationsEntitiesListFilterTab+} from "../components/TranslationsEntitiesListPage";+import {+ TypedCategoryTranslations,+ TypedProductTranslations+} from "../queries";+import {+ languageEntityUrl,+ languageListUrl,+ TranslatableEntities+} from "../urls";++export type TranslationsEntitiesListQueryParams = Pagination & {+ tab: TranslationsEntitiesListFilterTab;+};++interface TranslationsEntitiesProps {+ language: string;+ params: TranslationsEntitiesListQueryParams;+}++const PAGINATE_BY = 20;++const TranslationsEntities: React.FC<TranslationsEntitiesProps> = ({+ language,+ params+}) => {+ const navigate = useNavigator();+ const paginate = usePaginator();+ const shop = useShop();++ if (Object.keys(TranslatableEntities).indexOf(params.tab) === -1) {+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.categories+ }),+ true+ );+ }++ const filterCallbacks = {+ onCategoriesTabClick: () =>+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.categories+ })+ ),+ onProductsTabClick: () =>+ navigate(+ "?" ++ stringifyQs({+ tab: TranslatableEntities.products+ })+ )+ };+ const lang = maybe(() =>+ shop.languages.find(languageFromList => languageFromList.code === language)+ );+ const paginationState = createPaginationState(PAGINATE_BY, params);++ return (+ <TranslationsEntitiesListPage+ filters={{+ current: params.tab,+ ...filterCallbacks+ }}+ language={lang}+ onBack={() => navigate(languageListUrl)}+ >+ {params.tab === "categories" ? (+ <TypedCategoryTranslations+ variables={{ language: language as any, ...paginationState }}+ >+ {({ data, loading }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.categories.pageInfo),+ paginationState,+ params+ );++ return (+ <TranslationsEntitiesList+ disabled={loading}+ entities={maybe(() =>+ data.categories.edges+ .map(edge => edge.node)+ .map(node => ({+ completion: {+ current: node.translation+ ? [+ node.translation.descriptionJson,+ node.translation.name,+ node.translation.seoDescription,+ node.translation.seoTitle+ ].reduce(+ (acc, field) => acc + (field !== null ? 1 : 0)+ )+ : 0,+ max: 4+ },+ id: node.id,+ name: node.name+ }))+ )}+ onRowClick={id =>+ navigate(+ languageEntityUrl(+ language,+ TranslatableEntities.categories,+ id+ )+ )+ }+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ pageInfo={pageInfo}+ />+ );+ }}+ </TypedCategoryTranslations>+ ) : params.tab === "products" ? (+ <TypedProductTranslations+ variables={{ language: language as any, ...paginationState }}+ >+ {({ data, loading }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.products.pageInfo),+ paginationState,+ params+ );++ return (+ <TranslationsEntitiesList+ disabled={loading}+ entities={maybe(() =>+ data.products.edges+ .map(edge => edge.node)+ .map(node => ({+ completion: {+ current: node.translation+ ? [+ node.translation.descriptionJson,+ node.translation.name,+ node.translation.seoDescription,+ node.translation.seoTitle+ ].reduce(+ (acc, field) => acc + (field !== null ? 1 : 0)+ )+ : 0,+ max: 4+ },+ id: node.id,+ name: node.name+ }))+ )}+ onRowClick={id =>+ navigate(+ languageEntityUrl(+ language,+ TranslatableEntities.products,+ id+ )+ )+ }+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ pageInfo={pageInfo}+ />+ );+ }}+ </TypedProductTranslations>+ ) : null}+ </TranslationsEntitiesListPage>+ );+};+TranslationsEntities.displayName = "TranslationsEntities";+export default TranslationsEntities;diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex 2315e295f6..45f03cdeb1 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -31,6 +31,45 @@ export enum FulfillmentStatus {FULFILLED = "FULFILLED",}+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 {CAPTURE = "CAPTURE",MARK_AS_PAID = "MARK_AS_PAID",