Skip to content

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

Rename consts, change typing

Krzysztof Bialoglowicz9b97df37ebf5
diff --git a/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx b/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
index fd62bc32f2..64cfa72701 100644
--- a/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
@@ -31,7 +31,7 @@ import ArrowDropdown from "../../icons/ArrowDropdown";
import Container from "../Container";
import AppActionContext from "./AppActionContext";
import AppHeaderContext from "./AppHeaderContext";
-import { appLoaderHeight, drawerWidth, drawerWidthSmall } from "./consts";
+import { appLoaderHeight, drawerWidth, drawerWidthExpanded } from "./consts";
import MenuList from "./MenuList";
import menuStructure from "./menuStructure";
import ResponsiveDrawer from "./ResponsiveDrawer";
@@ -57,7 +57,7 @@ const styles = (theme: Theme) =>
[theme.breakpoints.down("md")]: {
paddingLeft: 0
},
- paddingLeft: drawerWidth,
+ paddingLeft: drawerWidthExpanded,
position: "absolute",
transition: "padding-left 0.5s ease",
width: "100%"
@@ -66,7 +66,7 @@ const styles = (theme: Theme) =>
[theme.breakpoints.down("md")]: {
paddingLeft: 0
},
- paddingLeft: drawerWidthSmall
+ paddingLeft: drawerWidth
},
darkThemeSwitch: {
marginRight: theme.spacing.unit * 2
diff --git a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
index 9b1c76dd41..5ff5b7dd94 100644
--- a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
@@ -11,17 +11,16 @@ import SVG from "react-inlinesvg";
import { matchPath } from "react-router";
import useTheme from "@saleor/hooks/useTheme";
+import configureIcon from "../../../images/menu-configure-icon.svg";
import { User } from "../../auth/types/User";
import { configurationMenu, configurationMenuUrl } from "../../configuration";
import i18n from "../../i18n";
import { createHref } from "../../misc";
import { orderDraftListUrl, orderListUrl } from "../../orders/urls";
-import { drawerWidth, drawerWidthSmall } from "./consts";
+import { drawerWidth, drawerWidthExpanded } from "./consts";
import MenuNested from "./MenuNested";
import { IMenuItem } from "./menuStructure";
-import configureIcon from "../../../images/menu-configure-icon.svg";
-
const styles = (theme: Theme) =>
createStyles({
menuIcon: {
@@ -169,7 +168,7 @@ const styles = (theme: Theme) =>
menuListNestedOpen: {
[theme.breakpoints.down("sm")]: {
right: 0,
- width: drawerWidth,
+ width: drawerWidthExpanded,
zIndex: 2
},
right: -300,
@@ -206,14 +205,14 @@ const styles = (theme: Theme) =>
},
subMenuDrawerOpen: {
"&$subMenuDrawerSmall": {
- left: drawerWidthSmall,
- width: `calc(100vw - ${drawerWidthSmall})px`
+ left: drawerWidth,
+ width: `calc(100vw - ${drawerWidth})px`
},
- width: `calc(100vw - ${drawerWidth}px)`
+ width: `calc(100vw - ${drawerWidthExpanded}px)`
},
subMenuDrawerSmall: {
- left: drawerWidthSmall,
- width: `calc(100vw - ${drawerWidthSmall})px`
+ left: drawerWidth,
+ width: `calc(100vw - ${drawerWidth})px`
}
});
@@ -229,7 +228,7 @@ interface MenuListProps {
export interface IActiveSubMenu {
isActive: boolean;
- label: string;
+ label: string | null;
}
const MenuList = withStyles(styles, { name: "MenuList" })(
@@ -246,7 +245,7 @@ const MenuList = withStyles(styles, { name: "MenuList" })(
const { isDark } = useTheme();
const [activeSubMenu, setActiveSubMenu] = React.useState<IActiveSubMenu>({
isActive: false,
- label: ""
+ label: null
});
const handleSubMenu = itemLabel => {
@@ -260,7 +259,7 @@ const MenuList = withStyles(styles, { name: "MenuList" })(
const closeSubMenu = (menuItemUrl, event) => {
setActiveSubMenu({
isActive: false,
- label: ""
+ label: null
});
if (menuItemUrl && event) {
onMenuItemClick(menuItemUrl, event);
diff --git a/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx b/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx
index 15cfa7dc4b..a9fbefb4d1 100644
--- a/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/MenuNested.tsx
@@ -5,12 +5,11 @@ import React from "react";
import SVG from "react-inlinesvg";
import useTheme from "@saleor/hooks/useTheme";
+import menuArrowIcon from "../../../images/menu-arrow-icon.svg";
import { createHref } from "../../misc";
import { IActiveSubMenu } from "./MenuList";
import { IMenuItem } from "./menuStructure";
-import menuArrowIcon from "../../../images/menu-arrow-icon.svg";
-
export interface MenuNestedProps {
activeItem: IActiveSubMenu;
ariaLabel: string;
@@ -31,7 +30,7 @@ export interface MenuNestedProps {
| "subHeaderTitle",
string
>;
- closeSubMenu: ({}) => void;
+ closeSubMenu: ({ isActive, label }: IActiveSubMenu) => void;
icon: string;
menuItem: IMenuItem;
title: string;
@@ -55,7 +54,7 @@ const MenuNested: React.FC<MenuNestedProps> = ({
onMenuItemClick(menuItemUrl, event);
closeSubMenu({
isActive: false,
- label: ""
+ label: null
});
event.stopPropagation();
event.preventDefault();
@@ -91,7 +90,7 @@ const MenuNested: React.FC<MenuNestedProps> = ({
onClick={() =>
closeSubMenu({
isActive: false,
- label: ""
+ label: null
})
}
>
diff --git a/saleor/static/dashboard-next/components/AppLayout/ResponsiveDrawer.tsx b/saleor/static/dashboard-next/components/AppLayout/ResponsiveDrawer.tsx
index 788750be37..e04be9c5e4 100644
--- a/saleor/static/dashboard-next/components/AppLayout/ResponsiveDrawer.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/ResponsiveDrawer.tsx
@@ -7,7 +7,7 @@ import {
WithStyles
} from "@material-ui/core/styles";
import React from "react";
-import { drawerWidth, drawerWidthSmall } from "./consts";
+import { drawerWidth, drawerWidthExpanded } from "./consts";
const styles = (theme: Theme) =>
createStyles({
@@ -19,15 +19,15 @@ const styles = (theme: Theme) =>
padding: 0,
position: "fixed" as "fixed",
transition: "width 0.5s ease",
- width: drawerWidth
+ width: drawerWidthExpanded
},
drawerDesktopSmall: {
overflow: "visible",
transition: "width 0.5s ease",
- width: drawerWidthSmall
+ width: drawerWidth
},
drawerMobile: {
- width: drawerWidth
+ width: drawerWidthExpanded
}
});
diff --git a/saleor/static/dashboard-next/components/AppLayout/consts.ts b/saleor/static/dashboard-next/components/AppLayout/consts.ts
index 5052c7b568..a6d98fbba8 100644
--- a/saleor/static/dashboard-next/components/AppLayout/consts.ts
+++ b/saleor/static/dashboard-next/components/AppLayout/consts.ts
@@ -1,4 +1,4 @@
-export const drawerWidth = 256;
-export const drawerWidthSmall = 80;
+export const drawerWidthExpanded = 256;
+export const drawerWidth = 80;
export const navigationBarHeight = 64;
export const appLoaderHeight = 4;