Skip to content

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

Add staff list page component

dominik-zeglenfa22f6679a49
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index 5ddfab2749..1e29e1141a 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -119,6 +119,8 @@ render(
document.querySelector("#dashboard-app")
);
+export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
+
export interface ListProps {
disabled: boolean;
pageInfo?: {
diff --git a/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx
new file mode 100644
index 0000000000..a106a92c7a
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx
@@ -0,0 +1,97 @@
+import Button from "@material-ui/core/Button";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import { withStyles } from "@material-ui/core/styles";
+import TextField from "@material-ui/core/TextField";
+import Typography from "@material-ui/core/Typography";
+import * as React from "react";
+
+import { ControlledCheckbox } from "../../../components/ControlledCheckbox";
+import Form from "../../../components/Form";
+import i18n from "../../../i18n";
+
+interface FormData {
+ email: string;
+ fullAccess: boolean;
+}
+interface StaffAddMemberDialogProps {
+ open: boolean;
+ onClose: () => void;
+ onConfirm: (data: FormData) => void;
+}
+
+const initialForm: FormData = {
+ email: "",
+ fullAccess: false
+};
+
+const decorate = withStyles(theme => ({
+ hr: {
+ backgroundColor: "#eaeaea",
+ border: "none",
+ height: 1,
+ marginBottom: 0
+ },
+ sectionTitle: {
+ fontWeight: 600 as 600,
+ marginBottom: theme.spacing.unit,
+ marginTop: theme.spacing.unit * 2
+ }
+}));
+const StaffAddMemberDialog = decorate<StaffAddMemberDialogProps>(
+ ({ classes, open, onClose, onConfirm }) => (
+ <Dialog open={open}>
+ <Form initial={initialForm} onSubmit={onConfirm}>
+ {({ change, data, hasChanged }) => (
+ <>
+ <DialogTitle>{i18n.t("Add Staff Member")}</DialogTitle>
+ <DialogContent>
+ <TextField
+ fullWidth
+ label={i18n.t("E-mail")}
+ name="email"
+ onChange={change}
+ type="email"
+ value={data.email}
+ />
+ </DialogContent>
+ <hr className={classes.hr} />
+ <DialogContent>
+ <Typography className={classes.sectionTitle}>
+ {i18n.t("Permissions")}
+ </Typography>
+ <Typography>
+ {i18n.t(
+ "Expand or restrict user’s permissions to access certain part of saleor system."
+ )}
+ </Typography>
+ <ControlledCheckbox
+ checked={data.fullAccess}
+ label={i18n.t("User has full access")}
+ name="fullAccess"
+ onChange={change}
+ />
+ </DialogContent>
+ <DialogActions>
+ <Button onClick={onClose}>
+ {i18n.t("Cancel", { context: "button" })}
+ </Button>
+ <Button
+ color="primary"
+ disabled={!hasChanged}
+ variant="raised"
+ type="submit"
+ >
+ {i18n.t("Send invite", { context: "button" })}
+ </Button>
+ </DialogActions>
+ </>
+ )}
+ </Form>
+ </Dialog>
+ )
+);
+StaffAddMemberDialog.displayName = "StaffAddMemberDialog";
+export default StaffAddMemberDialog;
diff --git a/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/index.ts b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/index.ts
new file mode 100644
index 0000000000..d018057605
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffAddMemberDialog";
+export * from "./StaffAddMemberDialog";
diff --git a/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx
new file mode 100644
index 0000000000..2ed4e45919
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx
@@ -0,0 +1,112 @@
+import Card from "@material-ui/core/Card";
+import { 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, Omit } from "../../..";
+import Skeleton from "../../../components/Skeleton";
+import StatusLabel from "../../../components/StatusLabel";
+import TablePagination from "../../../components/TablePagination";
+import i18n from "../../../i18n";
+import { renderCollection } from "../../../misc";
+import { StaffList_staffUsers_edges_node } from "../../types/StaffList";
+
+interface StaffListProps extends ListProps {
+ staffMembers: Array<Omit<StaffList_staffUsers_edges_node, "__typename">>;
+}
+
+const decorate = withStyles({
+ tableRow: {
+ cursor: "pointer" as "pointer"
+ }
+});
+const StaffList = decorate<StaffListProps>(
+ ({
+ classes,
+ disabled,
+ onNextPage,
+ onPreviousPage,
+ onRowClick,
+ pageInfo,
+ staffMembers
+ }) => (
+ <Card>
+ <Table>
+ <TableHead>
+ <TableRow>
+ <TableCell>{i18n.t("E-mail", { context: "object" })}</TableCell>
+ <TableCell>{i18n.t("Status", { context: "object" })}</TableCell>
+ </TableRow>
+ </TableHead>
+ <TableFooter>
+ <TableRow>
+ <TablePagination
+ colSpan={3}
+ hasNextPage={
+ pageInfo && !disabled ? pageInfo.hasNextPage : undefined
+ }
+ onNextPage={onNextPage}
+ hasPreviousPage={
+ pageInfo && !disabled ? pageInfo.hasPreviousPage : undefined
+ }
+ onPreviousPage={onPreviousPage}
+ />
+ </TableRow>
+ </TableFooter>
+ <TableBody>
+ {renderCollection(
+ staffMembers,
+ staffMember => (
+ <TableRow
+ className={classNames({
+ [classes.tableRow]: !!staffMember
+ })}
+ hover={!!staffMember}
+ key={staffMember ? staffMember.id : "skeleton"}
+ >
+ <TableCell>
+ {staffMember ? (
+ <span onClick={onRowClick(staffMember.id)}>
+ {staffMember.email}
+ </span>
+ ) : (
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell>
+ {staffMember && staffMember.isActive !== undefined ? (
+ <StatusLabel
+ label={
+ staffMember.isActive
+ ? i18n.t("Active", { context: "status" })
+ : i18n.t("Inactive", { context: "status" })
+ }
+ status={staffMember.isActive ? "success" : "error"}
+ />
+ ) : (
+ <Skeleton />
+ )}
+ </TableCell>
+ </TableRow>
+ ),
+ () => (
+ <TableRow>
+ <TableCell colSpan={2}>
+ {i18n.t("No staff members found")}
+ </TableCell>
+ </TableRow>
+ )
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )
+);
+StaffList.displayName = "StaffList";
+export default StaffList;
diff --git a/saleor/static/dashboard-next/staff/components/StaffList/index.ts b/saleor/static/dashboard-next/staff/components/StaffList/index.ts
new file mode 100644
index 0000000000..524579391f
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffList/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffList";
+export * from "./StaffList";
diff --git a/saleor/static/dashboard-next/staff/components/StaffListPage/StaffListPage.tsx b/saleor/static/dashboard-next/staff/components/StaffListPage/StaffListPage.tsx
new file mode 100644
index 0000000000..66fe5a5fbd
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffListPage/StaffListPage.tsx
@@ -0,0 +1,59 @@
+import Button from "@material-ui/core/Button";
+import AddIcon from "@material-ui/icons/Add";
+import * as React from "react";
+
+import { Omit, PageListProps } from "../../..";
+import { Container } from "../../../components/Container";
+import PageHeader from "../../../components/PageHeader";
+import Toggle from "../../../components/Toggle";
+import i18n from "../../../i18n";
+import { StaffList_staffUsers_edges_node } from "../../types/StaffList";
+import StaffAddMemberDialog from "../StaffAddMemberDialog/StaffAddMemberDialog";
+import StaffList from "../StaffList/StaffList";
+
+export interface StaffListPageProps extends PageListProps {
+ staffMembers: Array<Omit<StaffList_staffUsers_edges_node, "__typename">>;
+}
+
+const StaffListPage: React.StatelessComponent<StaffListPageProps> = ({
+ disabled,
+ pageInfo,
+ staffMembers,
+ onAdd,
+ onNextPage,
+ onPreviousPage,
+ onRowClick
+}) => (
+ <Toggle>
+ {(openedAddStaffMemberDialog, { toggle: toggleAddStaffMemberDialog }) => (
+ <Container width="md">
+ <PageHeader title={i18n.t("Staff members", { context: "page title" })}>
+ <Button
+ color="secondary"
+ disabled={disabled}
+ variant="contained"
+ onClick={toggleAddStaffMemberDialog}
+ >
+ {i18n.t("Add staff member", { context: "button" })}
+ <AddIcon />
+ </Button>
+ </PageHeader>
+ <StaffList
+ disabled={disabled}
+ pageInfo={pageInfo}
+ staffMembers={staffMembers}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ onRowClick={onRowClick}
+ />
+ <StaffAddMemberDialog
+ open={openedAddStaffMemberDialog}
+ onClose={toggleAddStaffMemberDialog}
+ onConfirm={onAdd}
+ />
+ </Container>
+ )}
+ </Toggle>
+);
+StaffListPage.displayName = "StaffListPage";
+export default StaffListPage;
diff --git a/saleor/static/dashboard-next/staff/components/StaffListPage/index.ts b/saleor/static/dashboard-next/staff/components/StaffListPage/index.ts
new file mode 100644
index 0000000000..acbe4f3dfd
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/components/StaffListPage/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./StaffListPage";
+export * from "./StaffListPage";
diff --git a/saleor/static/dashboard-next/staff/fixtures.ts b/saleor/static/dashboard-next/staff/fixtures.ts
new file mode 100644
index 0000000000..c30a9fc928
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/fixtures.ts
@@ -0,0 +1,793 @@
+export const staffMembers = [
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: false
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: false
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: false
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: false
+ },
+ {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true
+ }
+];
+export const staffMember = {
+ email: "[email protected]",
+ id: "VXNlcjoyMQ==",
+ isActive: true,
+ permissions: [
+ {
+ code: "account.add_address",
+ name: "Can add address"
+ },
+ {
+ code: "account.change_address",
+ name: "Can change address"
+ },
+ {
+ code: "account.delete_address",
+ name: "Can delete address"
+ },
+ {
+ code: "account.add_customernote",
+ name: "Can add customer note"
+ },
+ {
+ code: "account.change_customernote",
+ name: "Can change customer note"
+ },
+ {
+ code: "account.delete_customernote",
+ name: "Can delete customer note"
+ },
+ {
+ code: "account.add_user",
+ name: "Can add user"
+ },
+ {
+ code: "account.change_user",
+ name: "Can change user"
+ },
+ {
+ code: "account.delete_user",
+ name: "Can delete user"
+ },
+ {
+ code: "account.impersonate_users",
+ name: "Impersonate customers."
+ },
+ {
+ code: "account.manage_staff",
+ name: "Manage staff."
+ },
+ {
+ code: "account.manage_users",
+ name: "Manage customers."
+ },
+ {
+ code: "auth.add_group",
+ name: "Can add group"
+ },
+ {
+ code: "auth.change_group",
+ name: "Can change group"
+ },
+ {
+ code: "auth.delete_group",
+ name: "Can delete group"
+ },
+ {
+ code: "auth.add_permission",
+ name: "Can add permission"
+ },
+ {
+ code: "auth.change_permission",
+ name: "Can change permission"
+ },
+ {
+ code: "auth.delete_permission",
+ name: "Can delete permission"
+ },
+ {
+ code: "checkout.add_cart",
+ name: "Can add cart"
+ },
+ {
+ code: "checkout.change_cart",
+ name: "Can change cart"
+ },
+ {
+ code: "checkout.delete_cart",
+ name: "Can delete cart"
+ },
+ {
+ code: "checkout.add_cartline",
+ name: "Can add cart line"
+ },
+ {
+ code: "checkout.change_cartline",
+ name: "Can change cart line"
+ },
+ {
+ code: "checkout.delete_cartline",
+ name: "Can delete cart line"
+ },
+ {
+ code: "contenttypes.add_contenttype",
+ name: "Can add content type"
+ },
+ {
+ code: "contenttypes.change_contenttype",
+ name: "Can change content type"
+ },
+ {
+ code: "contenttypes.delete_contenttype",
+ name: "Can delete content type"
+ },
+ {
+ code: "discount.add_sale",
+ name: "Can add sale"
+ },
+ {
+ code: "discount.change_sale",
+ name: "Can change sale"
+ },
+ {
+ code: "discount.delete_sale",
+ name: "Can delete sale"
+ },
+ {
+ code: "discount.manage_discounts",
+ name: "Manage sales and vouchers."
+ },
+ {
+ code: "discount.add_voucher",
+ name: "Can add voucher"
+ },
+ {
+ code: "discount.change_voucher",
+ name: "Can change voucher"
+ },
+ {
+ code: "discount.delete_voucher",
+ name: "Can delete voucher"
+ },
+ {
+ code: "discount.add_vouchertranslation",
+ name: "Can add voucher translation"
+ },
+ {
+ code: "discount.change_vouchertranslation",
+ name: "Can change voucher translation"
+ },
+ {
+ code: "discount.delete_vouchertranslation",
+ name: "Can delete voucher translation"
+ },
+ {
+ code: "django_celery_results.add_taskresult",
+ name: "Can add task result"
+ },
+ {
+ code: "django_celery_results.change_taskresult",
+ name: "Can change task result"
+ },
+ {
+ code: "django_celery_results.delete_taskresult",
+ name: "Can delete task result"
+ },
+ {
+ code: "django_prices_openexchangerates.add_conversionrate",
+ name: "Can add conversion rate"
+ },
+ {
+ code: "django_prices_openexchangerates.change_conversionrate",
+ name: "Can change conversion rate"
+ },
+ {
+ code: "django_prices_openexchangerates.delete_conversionrate",
+ name: "Can delete conversion rate"
+ },
+ {
+ code: "django_prices_vatlayer.add_ratetypes",
+ name: "Can add rate types"
+ },
+ {
+ code: "django_prices_vatlayer.change_ratetypes",
+ name: "Can change rate types"
+ },
+ {
+ code: "django_prices_vatlayer.delete_ratetypes",
+ name: "Can delete rate types"
+ },
+ {
+ code: "django_prices_vatlayer.add_vat",
+ name: "Can add vat"
+ },
+ {
+ code: "django_prices_vatlayer.change_vat",
+ name: "Can change vat"
+ },
+ {
+ code: "django_prices_vatlayer.delete_vat",
+ name: "Can delete vat"
+ },
+ {
+ code: "impersonate.add_impersonationlog",
+ name: "Can add impersonation log"
+ },
+ {
+ code: "impersonate.change_impersonationlog",
+ name: "Can change impersonation log"
+ },
+ {
+ code: "impersonate.delete_impersonationlog",
+ name: "Can delete impersonation log"
+ },
+ {
+ code: "menu.add_menu",
+ name: "Can add menu"
+ },
+ {
+ code: "menu.change_menu",
+ name: "Can change menu"
+ },
+ {
+ code: "menu.delete_menu",
+ name: "Can delete menu"
+ },
+ {
+ code: "menu.manage_menus",
+ name: "Manage navigation."
+ },
+ {
+ code: "menu.add_menuitem",
+ name: "Can add menu item"
+ },
+ {
+ code: "menu.change_menuitem",
+ name: "Can change menu item"
+ },
+ {
+ code: "menu.delete_menuitem",
+ name: "Can delete menu item"
+ },
+ {
+ code: "menu.add_menuitemtranslation",
+ name: "Can add menu item translation"
+ },
+ {
+ code: "menu.change_menuitemtranslation",
+ name: "Can change menu item translation"
+ },
+ {
+ code: "menu.delete_menuitemtranslation",
+ name: "Can delete menu item translation"
+ },
+ {
+ code: "order.add_fulfillment",
+ name: "Can add fulfillment"
+ },
+ {
+ code: "order.change_fulfillment",
+ name: "Can change fulfillment"
+ },
+ {
+ code: "order.delete_fulfillment",
+ name: "Can delete fulfillment"
+ },
+ {
+ code: "order.add_fulfillmentline",
+ name: "Can add fulfillment line"
+ },
+ {
+ code: "order.change_fulfillmentline",
+ name: "Can change fulfillment line"
+ },
+ {
+ code: "order.delete_fulfillmentline",
+ name: "Can delete fulfillment line"
+ },
+ {
+ code: "order.add_order",
+ name: "Can add order"
+ },
+ {
+ code: "order.change_order",
+ name: "Can change order"
+ },
+ {
+ code: "order.delete_order",
+ name: "Can delete order"
+ },
+ {
+ code: "order.manage_orders",
+ name: "Manage orders."
+ },
+ {
+ code: "order.add_orderevent",
+ name: "Can add order event"
+ },
+ {
+ code: "order.change_orderevent",
+ name: "Can change order event"
+ },
+ {
+ code: "order.delete_orderevent",
+ name: "Can delete order event"
+ },
+ {
+ code: "order.add_orderhistoryentry",
+ name: "Can add order history entry"
+ },
+ {
+ code: "order.change_orderhistoryentry",
+ name: "Can change order history entry"
+ },
+ {
+ code: "order.delete_orderhistoryentry",
+ name: "Can delete order history entry"
+ },
+ {
+ code: "order.add_orderline",
+ name: "Can add order line"
+ },
+ {
+ code: "order.change_orderline",
+ name: "Can change order line"
+ },
+ {
+ code: "order.delete_orderline",
+ name: "Can delete order line"
+ },
+ {
+ code: "order.add_ordernote",
+ name: "Can add order note"
+ },
+ {
+ code: "order.change_ordernote",
+ name: "Can change order note"
+ },
+ {
+ code: "order.delete_ordernote",
+ name: "Can delete order note"
+ },
+ {
+ code: "order.add_payment",
+ name: "Can add payment"
+ },
+ {
+ code: "order.change_payment",
+ name: "Can change payment"
+ },
+ {
+ code: "order.delete_payment",
+ name: "Can delete payment"
+ },
+ {
+ code: "page.add_page",
+ name: "Can add page"
+ },
+ {
+ code: "page.change_page",
+ name: "Can change page"
+ },
+ {
+ code: "page.delete_page",
+ name: "Can delete page"
+ },
+ {
+ code: "page.manage_pages",
+ name: "Manage pages."
+ },
+ {
+ code: "page.add_pagetranslation",
+ name: "Can add page translation"
+ },
+ {
+ code: "page.change_pagetranslation",
+ name: "Can change page translation"
+ },
+ {
+ code: "page.delete_pagetranslation",
+ name: "Can delete page translation"
+ },
+ {
+ code: "product.add_attributechoicevalue",
+ name: "Can add attribute choice value"
+ },
+ {
+ code: "product.change_attributechoicevalue",
+ name: "Can change attribute choice value"
+ },
+ {
+ code: "product.delete_attributechoicevalue",
+ name: "Can delete attribute choice value"
+ },
+ {
+ code: "product.add_attributechoicevaluetranslation",
+ name: "Can add attribute choice value translation"
+ },
+ {
+ code: "product.change_attributechoicevaluetranslation",
+ name: "Can change attribute choice value translation"
+ },
+ {
+ code: "product.delete_attributechoicevaluetranslation",
+ name: "Can delete attribute choice value translation"
+ },
+ {
+ code: "product.add_category",
+ name: "Can add category"
+ },
+ {
+ code: "product.change_category",
+ name: "Can change category"
+ },
+ {
+ code: "product.delete_category",
+ name: "Can delete category"
+ },
+ {
+ code: "product.add_categorytranslation",
+ name: "Can add category translation"
+ },
+ {
+ code: "product.change_categorytranslation",
+ name: "Can change category translation"
+ },
+ {
+ code: "product.delete_categorytranslation",
+ name: "Can delete category translation"
+ },
+ {
+ code: "product.add_collection",
+ name: "Can add collection"
+ },
+ {
+ code: "product.change_collection",
+ name: "Can change collection"
+ },
+ {
+ code: "product.delete_collection",
+ name: "Can delete collection"
+ },
+ {
+ code: "product.add_collectiontranslation",
+ name: "Can add collection translation"
+ },
+ {
+ code: "product.change_collectiontranslation",
+ name: "Can change collection translation"
+ },
+ {
+ code: "product.delete_collectiontranslation",
+ name: "Can delete collection translation"
+ },
+ {
+ code: "product.add_product",
+ name: "Can add product"
+ },
+ {
+ code: "product.change_product",
+ name: "Can change product"
+ },
+ {
+ code: "product.delete_product",
+ name: "Can delete product"
+ },
+ {
+ code: "product.manage_products",
+ name: "Manage products."
+ },
+ {
+ code: "product.add_productattribute",
+ name: "Can add product attribute"
+ },
+ {
+ code: "product.change_productattribute",
+ name: "Can change product attribute"
+ },
+ {
+ code: "product.delete_productattribute",
+ name: "Can delete product attribute"
+ },
+ {
+ code: "product.add_productattributetranslation",
+ name: "Can add product attribute translation"
+ },
+ {
+ code: "product.change_productattributetranslation",
+ name: "Can change product attribute translation"
+ },
+ {
+ code: "product.delete_productattributetranslation",
+ name: "Can delete product attribute translation"
+ },
+ {
+ code: "product.add_productimage",
+ name: "Can add product image"
+ },
+ {
+ code: "product.change_productimage",
+ name: "Can change product image"
+ },
+ {
+ code: "product.delete_productimage",
+ name: "Can delete product image"
+ },
+ {
+ code: "product.add_producttranslation",
+ name: "Can add product translation"
+ },
+ {
+ code: "product.change_producttranslation",
+ name: "Can change product translation"
+ },
+ {
+ code: "product.delete_producttranslation",
+ name: "Can delete product translation"
+ },
+ {
+ code: "product.add_producttype",
+ name: "Can add product type"
+ },
+ {
+ code: "product.change_producttype",
+ name: "Can change product type"
+ },
+ {
+ code: "product.delete_producttype",
+ name: "Can delete product type"
+ },
+ {
+ code: "product.add_productvariant",
+ name: "Can add product variant"
+ },
+ {
+ code: "product.change_productvariant",
+ name: "Can change product variant"
+ },
+ {
+ code: "product.delete_productvariant",
+ name: "Can delete product variant"
+ },
+ {
+ code: "product.add_productvarianttranslation",
+ name: "Can add product variant translation"
+ },
+ {
+ code: "product.change_productvarianttranslation",
+ name: "Can change product variant translation"
+ },
+ {
+ code: "product.delete_productvarianttranslation",
+ name: "Can delete product variant translation"
+ },
+ {
+ code: "product.add_variantimage",
+ name: "Can add variant image"
+ },
+ {
+ code: "product.change_variantimage",
+ name: "Can change variant image"
+ },
+ {
+ code: "product.delete_variantimage",
+ name: "Can delete variant image"
+ },
+ {
+ code: "sessions.add_session",
+ name: "Can add session"
+ },
+ {
+ code: "sessions.change_session",
+ name: "Can change session"
+ },
+ {
+ code: "sessions.delete_session",
+ name: "Can delete session"
+ },
+ {
+ code: "shipping.add_shippingmethod",
+ name: "Can add shipping method"
+ },
+ {
+ code: "shipping.change_shippingmethod",
+ name: "Can change shipping method"
+ },
+ {
+ code: "shipping.delete_shippingmethod",
+ name: "Can delete shipping method"
+ },
+ {
+ code: "shipping.add_shippingmethodtranslation",
+ name: "Can add shipping method translation"
+ },
+ {
+ code: "shipping.change_shippingmethodtranslation",
+ name: "Can change shipping method translation"
+ },
+ {
+ code: "shipping.delete_shippingmethodtranslation",
+ name: "Can delete shipping method translation"
+ },
+ {
+ code: "shipping.add_shippingzone",
+ name: "Can add shipping zone"
+ },
+ {
+ code: "shipping.change_shippingzone",
+ name: "Can change shipping zone"
+ },
+ {
+ code: "shipping.delete_shippingzone",
+ name: "Can delete shipping zone"
+ },
+ {
+ code: "shipping.manage_shipping",
+ name: "Manage shipping."
+ },
+ {
+ code: "site.add_authorizationkey",
+ name: "Can add authorization key"
+ },
+ {
+ code: "site.change_authorizationkey",
+ name: "Can change authorization key"
+ },
+ {
+ code: "site.delete_authorizationkey",
+ name: "Can delete authorization key"
+ },
+ {
+ code: "site.add_sitesettings",
+ name: "Can add site settings"
+ },
+ {
+ code: "site.change_sitesettings",
+ name: "Can change site settings"
+ },
+ {
+ code: "site.delete_sitesettings",
+ name: "Can delete site settings"
+ },
+ {
+ code: "site.manage_settings",
+ name: "Manage settings."
+ },
+ {
+ code: "site.add_sitesettingstranslation",
+ name: "Can add site settings translation"
+ },
+ {
+ code: "site.change_sitesettingstranslation",
+ name: "Can change site settings translation"
+ },
+ {
+ code: "site.delete_sitesettingstranslation",
+ name: "Can delete site settings translation"
+ },
+ {
+ code: "sites.add_site",
+ name: "Can add site"
+ },
+ {
+ code: "sites.change_site",
+ name: "Can change site"
+ },
+ {
+ code: "sites.delete_site",
+ name: "Can delete site"
+ },
+ {
+ code: "social_django.add_association",
+ name: "Can add association"
+ },
+ {
+ code: "social_django.change_association",
+ name: "Can change association"
+ },
+ {
+ code: "social_django.delete_association",
+ name: "Can delete association"
+ },
+ {
+ code: "social_django.add_code",
+ name: "Can add code"
+ },
+ {
+ code: "social_django.change_code",
+ name: "Can change code"
+ },
+ {
+ code: "social_django.delete_code",
+ name: "Can delete code"
+ },
+ {
+ code: "social_django.add_nonce",
+ name: "Can add nonce"
+ },
+ {
+ code: "social_django.change_nonce",
+ name: "Can change nonce"
+ },
+ {
+ code: "social_django.delete_nonce",
+ name: "Can delete nonce"
+ },
+ {
+ code: "social_django.add_partial",
+ name: "Can add partial"
+ },
+ {
+ code: "social_django.change_partial",
+ name: "Can change partial"
+ },
+ {
+ code: "social_django.delete_partial",
+ name: "Can delete partial"
+ },
+ {
+ code: "social_django.add_usersocialauth",
+ name: "Can add user social auth"
+ },
+ {
+ code: "social_django.change_usersocialauth",
+ name: "Can change user social auth"
+ },
+ {
+ code: "social_django.delete_usersocialauth",
+ name: "Can delete user social auth"
+ }
+ ]
+};
diff --git a/saleor/static/dashboard-next/staff/queries.ts b/saleor/static/dashboard-next/staff/queries.ts
new file mode 100644
index 0000000000..bf12f50b5d
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/queries.ts
@@ -0,0 +1,60 @@
+import gql from "graphql-tag";
+import { TypedQuery } from "../queries";
+import { StaffList, StaffListVariables } from "./types/StaffList";
+import {
+ StaffMemberDetails,
+ StaffMemberDetailsVariables
+} from "./types/StaffMemberDetails";
+
+export const staffMemberFragment = gql`
+ fragment StaffMemberFragment on User {
+ id
+ email
+ isActive
+ }
+`;
+export const staffMemberDetailsFragment = gql`
+ ${staffMemberFragment}
+ fragment StaffMemberDetailsFragment on User {
+ ...StaffMemberFragment
+ permissions {
+ code
+ name
+ }
+ }
+`;
+const staffList = gql`
+ ${staffMemberFragment}
+ query StaffList($first: Int, $after: String, $last: Int, $before: String) {
+ staffUsers(before: $before, after: $after, first: $first, last: $last) {
+ edges {
+ cursor
+ node {
+ ...StaffMemberFragment
+ }
+ }
+ pageInfo {
+ hasPreviousPage
+ hasNextPage
+ startCursor
+ endCursor
+ }
+ }
+ }
+`;
+export const TypedStaffListQuery = TypedQuery<StaffList, StaffListVariables>(
+ staffList
+);
+
+export const staffMemberDetails = gql`
+ ${staffMemberDetailsFragment}
+ query StaffMemberDetails($id: ID!) {
+ user(id: $id) {
+ ...StaffMemberDetailsFragment
+ }
+ }
+`;
+export const TypedOrderDetailsQuery = TypedQuery<
+ StaffMemberDetails,
+ StaffMemberDetailsVariables
+>(staffMemberDetails);
diff --git a/saleor/static/dashboard-next/staff/types/StaffList.ts b/saleor/static/dashboard-next/staff/types/StaffList.ts
new file mode 100644
index 0000000000..b4c68eab6a
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/types/StaffList.ts
@@ -0,0 +1,44 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL query operation: StaffList
+// ====================================================
+
+export interface StaffList_staffUsers_edges_node {
+ __typename: "User";
+ id: string;
+ email: string;
+ isActive: boolean;
+}
+
+export interface StaffList_staffUsers_edges {
+ __typename: "UserCountableEdge";
+ cursor: string;
+ node: StaffList_staffUsers_edges_node;
+}
+
+export interface StaffList_staffUsers_pageInfo {
+ __typename: "PageInfo";
+ hasPreviousPage: boolean;
+ hasNextPage: boolean;
+ startCursor: string | null;
+ endCursor: string | null;
+}
+
+export interface StaffList_staffUsers {
+ __typename: "UserCountableConnection";
+ edges: StaffList_staffUsers_edges[];
+ pageInfo: StaffList_staffUsers_pageInfo;
+}
+
+export interface StaffList {
+ staffUsers: StaffList_staffUsers | null;
+}
+
+export interface StaffListVariables {
+ first?: number | null;
+ after?: string | null;
+ last?: number | null;
+ before?: string | null;
+}
diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts b/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts
new file mode 100644
index 0000000000..15bcf2c6da
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/types/StaffMemberDetails.ts
@@ -0,0 +1,28 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL query operation: StaffMemberDetails
+// ====================================================
+
+export interface StaffMemberDetails_user_permissions {
+ __typename: "PermissionDisplay";
+ code: string;
+ name: string;
+}
+
+export interface StaffMemberDetails_user {
+ __typename: "User";
+ id: string;
+ email: string;
+ isActive: boolean;
+ permissions: (StaffMemberDetails_user_permissions | null)[] | null;
+}
+
+export interface StaffMemberDetails {
+ user: StaffMemberDetails_user | null;
+}
+
+export interface StaffMemberDetailsVariables {
+ id: string;
+}
diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts b/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts
new file mode 100644
index 0000000000..0985344e8f
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/types/StaffMemberDetailsFragment.ts
@@ -0,0 +1,20 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL fragment: StaffMemberDetailsFragment
+// ====================================================
+
+export interface StaffMemberDetailsFragment_permissions {
+ __typename: "PermissionDisplay";
+ code: string;
+ name: string;
+}
+
+export interface StaffMemberDetailsFragment {
+ __typename: "User";
+ id: string;
+ email: string;
+ isActive: boolean;
+ permissions: (StaffMemberDetailsFragment_permissions | null)[] | null;
+}
diff --git a/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts b/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts
new file mode 100644
index 0000000000..1a9a9b30a4
--- /dev/null
+++ b/saleor/static/dashboard-next/staff/types/StaffMemberFragment.ts
@@ -0,0 +1,13 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL fragment: StaffMemberFragment
+// ====================================================
+
+export interface StaffMemberFragment {
+ __typename: "User";
+ id: string;
+ email: string;
+ isActive: boolean;
+}
diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.js
index 004027fa2c..0eae91a701 100644
--- a/saleor/static/dashboard-next/storybook/config.js
+++ b/saleor/static/dashboard-next/storybook/config.js
@@ -52,6 +52,9 @@ function loadStories() {
require("./stories/customers/CustomerEditPage");
require("./stories/customers/CustomerListPage");
+ // Staff
+ require("./stories/staff/StaffListPage")
+
// Pages
require("./stories/pages/PageContent");
require("./stories/pages/PageDeleteDialog");
diff --git a/saleor/static/dashboard-next/storybook/stories/staff/StaffListPage.tsx b/saleor/static/dashboard-next/storybook/stories/staff/StaffListPage.tsx
new file mode 100644
index 0000000000..7bc5636c9b
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/staff/StaffListPage.tsx
@@ -0,0 +1,22 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import { pageListProps } from "../../../fixtures";
+import StaffListPage, {
+ StaffListPageProps
+} from "../../../staff/components/StaffListPage";
+import { staffMembers } from "../../../staff/fixtures";
+import Decorator from "../../Decorator";
+
+const props: StaffListPageProps = {
+ onAdd: undefined,
+ staffMembers,
+ ...pageListProps.default
+};
+
+storiesOf("Views / Staff / Staff members", module)
+ .addDecorator(Decorator)
+ .add("default", () => <StaffListPage {...props} />)
+ .add("when loading", () => (
+ <StaffListPage {...props} disabled={true} staffMembers={undefined} />
+ ));