Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change resource prop to permissions
dominik-zeglenb1458df89f53
diff --git a/saleor/static/dashboard-next/AppRoot.tsx b/saleor/static/dashboard-next/AppRoot.tsxindex a6f1410354..6d20718e12 100644--- a/saleor/static/dashboard-next/AppRoot.tsx+++ b/saleor/static/dashboard-next/AppRoot.tsx@@ -475,7 +475,7 @@ export const AppRoot = decorate({configurationMenu.filter(menuItem =>user.permissions.map(perm => perm.code)- .includes(menuItem.resource)+ .includes(menuItem.permission)).length > 0 && (<aclassName={classes.menuListItem}diff --git a/saleor/static/dashboard-next/auth/components/SectionRoute.tsx b/saleor/static/dashboard-next/auth/components/SectionRoute.tsxindex 7469a7722f..7c3fb9964e 100644--- a/saleor/static/dashboard-next/auth/components/SectionRoute.tsx+++ b/saleor/static/dashboard-next/auth/components/SectionRoute.tsx@@ -7,16 +7,19 @@ import NotFound from "../../NotFound";import { hasPermission } from "../misc";interface SectionRouteProps extends RouteProps {- resource?: string;+ permissions?: string[];}export const SectionRoute: React.StatelessComponent<SectionRouteProps> = ({- resource,+ permissions,...props}) => (<UserContext.Consumer>{({ user }) =>- !resource || hasPermission(resource, user) ? (+ !permissions ||+ permissions+ .map(permission => hasPermission(permission, user))+ .reduce((prev, curr) => prev && curr) ? (<AppRoot><Route {...props} /></AppRoot>diff --git a/saleor/static/dashboard-next/configuration/ConfigurationPage.tsx b/saleor/static/dashboard-next/configuration/ConfigurationPage.tsxindex 46d4a3439f..5fc3ab84d2 100644--- a/saleor/static/dashboard-next/configuration/ConfigurationPage.tsx+++ b/saleor/static/dashboard-next/configuration/ConfigurationPage.tsx@@ -13,7 +13,7 @@ import i18n from "../i18n";export interface MenuItem {description: string;icon: React.ReactElement<IconProps>;- resource: string;+ permission: string;title: string;url?: string;}@@ -73,7 +73,9 @@ export const ConfigurationPage = decorate<ConfigurationPageProps>(<div className={classes.root}>{menu.filter(menuItem =>- user.permissions.map(perm => perm.code).includes(menuItem.resource)+ user.permissions+ .map(perm => perm.code)+ .includes(menuItem.permission)).map((menuItem, menuItemIndex) => (<Carddiff --git a/saleor/static/dashboard-next/configuration/index.tsx b/saleor/static/dashboard-next/configuration/index.tsxindex 2abcd3b4d4..9ae3eebd9c 100644--- a/saleor/static/dashboard-next/configuration/index.tsx+++ b/saleor/static/dashboard-next/configuration/index.tsx@@ -19,51 +19,51 @@ export const configurationMenu: MenuItem[] = [{description: i18n.t("Define types of products you sell"),icon: <Folder fontSize="inherit" />,- resource: "product.manage_products",+ permission: "product.manage_products",title: i18n.t("Product Types"),url: productTypeListUrl},{description: i18n.t("Define attributes of products yousell"),icon: <Ballot fontSize="inherit" />,- resource: "product.manage_products",+ permission: "product.manage_products",title: i18n.t("Attributes")},{description: i18n.t("Manage your employees and their permissions"),icon: <AccountCircle fontSize="inherit" />,- resource: "account.manage_staff",+ permission: "account.manage_staff",title: i18n.t("Staff Members"),url: staffListUrl},{description: i18n.t("Manage how you ship out orders."),icon: <LocalShipping fontSize="inherit" />,- resource: "shipping.manage_shipping",+ permission: "shipping.manage_shipping",title: i18n.t("Shipping Methods")},{description: i18n.t("Manage how your store charges tax"),icon: <Monetization fontSize="inherit" />,- resource: "product.manage_products",+ permission: "product.manage_products",title: i18n.t("Taxes")},{description: i18n.t("Define how users can navigate through your store"),icon: <Navigation fontSize="inherit" />,- resource: "menu.manage_menus",+ permission: "menu.manage_menus",title: i18n.t("Navigation")},{description: i18n.t("View and update your site settings"),icon: <StoreMall fontSize="inherit" />,- resource: "site.manage_settings",+ permission: "site.manage_settings",title: i18n.t("Site Settings")},{description: i18n.t("Manage and add additional pages"),icon: <Pages fontSize="inherit" />,- resource: "page.manage_pages",+ permission: "page.manage_pages",title: i18n.t("Pages")}];diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsxindex a553a53cd4..d880b64c62 100644--- a/saleor/static/dashboard-next/index.tsx+++ b/saleor/static/dashboard-next/index.tsx@@ -94,37 +94,37 @@ render(<Switch><SectionRoute exact path="/" component={HomePage} /><SectionRoute- resource="product.manage_products"+ permissions={["product.manage_products"]}path="/categories"component={CategorySection}/><SectionRoute- resource="page.manage_pages"+ permissions={["page.manage_pages"]}path="/pages"component={PageSection}/><SectionRoute- resource="order.manage_orders"+ permissions={["order.manage_orders"]}path="/orders"component={OrdersSection}/><SectionRoute- resource="product.manage_products"+ permissions={["product.manage_products"]}path="/products"component={ProductSection}/><SectionRoute- resource="product.manage_products"+ permissions={["product.manage_products"]}path="/productTypes"component={ProductTypesSection}/><SectionRoute- resource="account.manage_staff"+ permissions={["account.manage_staff"]}path="/staff"component={StaffSection}/>{configurationMenu.filter(menuItem =>- hasPermission(menuItem.resource, user)+ hasPermission(menuItem.permission, user)).length > 0 && (<SectionRouteexact