Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor shop settings forms to use GraphQL #206

Merged
merged 48 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3df09ac
refactor: update settings forms to use GraphQL
willopez Feb 5, 2020
98ef0ea
refactor: add spacing around settings sections
willopez Feb 5, 2020
49a946f
refactor: add general and address settings panels
willopez Feb 6, 2020
b99a343
chore: update reacto-form
willopez Feb 7, 2020
900a2f2
refactor: wire up a couple of shop settings fields
willopez Feb 7, 2020
fd391a2
refactor: wire up general settings
willopez Feb 7, 2020
c0f2e8f
Merge branch 'trunk' of github.com:reactioncommerce/reaction-admin in…
willopez Feb 8, 2020
d3311e9
chore: upgrade MUI and reacto-form
willopez Feb 11, 2020
19c54e8
refactor: fix various bugs in general settings form
willopez Feb 11, 2020
087c92a
refactor: wire up address form
willopez Feb 11, 2020
76552f6
refactor: add consistent spacing
willopez Feb 11, 2020
ee3dd52
refactor: move GraphQL operations into a separate folder
willopez Feb 12, 2020
64f4878
chore: add missing translations
willopez Feb 13, 2020
8ff8521
Merge branch 'trunk' into refactor-settings-forms-to-use-gql
willopez Feb 13, 2020
690696d
Merge branch 'trunk' of github.com:reactioncommerce/reaction-admin in…
willopez Feb 26, 2020
a0d9cd4
refactor: use currentShopId hook
willopez Feb 28, 2020
f3a0736
refactor: expose loading prop in useShopSettings hook
willopez Feb 29, 2020
73a7ac2
refactor: expose loading prop for real
willopez Feb 29, 2020
89782cd
refactor: add settings sidebar and revamp shop and address settings
willopez Feb 29, 2020
2dcb24a
fix: lint error
willopez Feb 29, 2020
b95ffca
chore: upgrade Catalyst
willopez Mar 2, 2020
ff87443
refactor: move address form to a dialog
willopez Mar 2, 2020
cf84873
refactor: use MUI loading component
willopez Mar 2, 2020
2e139ef
refactor: add allow guest checkout to shop settins panel
willopez Mar 2, 2020
15bb601
Merge branch 'trunk' of github.com:reactioncommerce/reaction-admin in…
willopez Mar 3, 2020
fef2fee
refactor: remove settings submenu from main sidebar
willopez Mar 3, 2020
14c4836
refactor: add min-width to secondary sidebar
willopez Mar 3, 2020
bbbc708
refactor: integrate the primary/detail layout into settings view
willopez Mar 3, 2020
873a8f3
refactor: add initial view to address settings
willopez Mar 4, 2020
b85dc17
refactor: add tax settings block region
willopez Mar 4, 2020
4a1c795
Merge branch 'trunk' of github.com:reactioncommerce/reaction-admin in…
willopez Mar 4, 2020
55dd9b1
fix: typos
willopez Mar 5, 2020
d972dd2
refactor: remove unnecessary MUI styles package
willopez Mar 5, 2020
a18b558
refactor: use makeStyles from core MUI package
willopez Mar 5, 2020
64464d9
refactor: add shipping settings block region
willopez Mar 5, 2020
54ded41
refactor: add address validation services block region
willopez Mar 5, 2020
5d7f101
refactor: add headers to settings views
willopez Mar 5, 2020
f06913b
fix: lint error
willopez Mar 5, 2020
b421261
refactor: set correct priority
willopez Mar 5, 2020
7e8fe43
fix: typo
willopez Mar 5, 2020
a3b4cd9
refactor: add system information region
willopez Mar 5, 2020
812f392
refactor: add email settings region
willopez Mar 5, 2020
a4d3178
refactor: add localization settings region
willopez Mar 5, 2020
022e17e
refactor: add email templates settings region
willopez Mar 5, 2020
e19ed57
refactor: remove unnecesary Fragment components
willopez Mar 5, 2020
31d56de
chore: fix settings sidebar width
willopez Mar 5, 2020
128acad
fix: shop settings form mobile styles
willopez Mar 5, 2020
78d56de
refactor: remove styled components usage
willopez Mar 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions imports/client/ui/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import { compose, withState } from "recompose";
import { NavLink, withRouter } from "react-router-dom";
import classNames from "classnames";
import PropTypes from "prop-types";
import AppBar from "@material-ui/core/AppBar";
import Collapse from "@material-ui/core/Collapse";
import Fab from "@material-ui/core/Fab";
import Hidden from "@material-ui/core/Hidden";
import Toolbar from "@material-ui/core/Toolbar";
Expand All @@ -14,7 +12,6 @@ import ListItemIcon from "@material-ui/core/ListItemIcon";
import ListItemText from "@material-ui/core/ListItemText";
import Drawer from "@material-ui/core/Drawer";
import withStyles from "@material-ui/core/styles/withStyles";
import SettingsIcon from "mdi-material-ui/Settings";
import CloseIcon from "mdi-material-ui/Close";
import { Translation } from "/imports/plugins/core/ui/client/components";
import useIsAppLoading from "/imports/client/ui/hooks/useIsAppLoading.js";
Expand Down Expand Up @@ -97,7 +94,6 @@ const styles = (theme) => ({
function Sidebar(props) {
const {
classes,
history,
isMobile,
isSidebarOpen,
onDrawerClose,
Expand All @@ -108,7 +104,6 @@ function Sidebar(props) {
const [isAppLoading] = useIsAppLoading();
const [currentShopId] = useCurrentShopId();
const primaryRoutes = useOperatorRoutes({ groups: ["navigation"] });
const settingRoutes = useOperatorRoutes({ groups: ["settings"] });

let drawerProps = {
classes: {
Expand Down Expand Up @@ -158,53 +153,6 @@ function Sidebar(props) {
</ListItem>
</NavLink>
))}

<ListItem
button
className={classes.listItem}
onClick={() => {
// Push the first setting route when opened, but not on mobile
if (!isSettingsOpen && !isMobile) {
const [firstRoute] = settingRoutes;

if (firstRoute) {
history.push(firstRoute.path);
}
}
setIsSettingsOpen(!isSettingsOpen);
}}
>
<ListItemIcon className={classNames(classes.icon, { [classes.iconActive]: isSettingsOpen })}>
<SettingsIcon />
</ListItemIcon>
<ListItemText
disableTypography
className={classes.listItemText}
>
<Translation i18nKey={"app.settings"} />
</ListItemText>
</ListItem>

<Collapse in={isSettingsOpen}>
{settingRoutes.map((route) => (
<NavLink
activeClassName={activeClassName}
className={classes.link}
to={route.path}
key={route.path}
onClick={onDrawerClose}
>
<ListItem button className={classes.listItemNested}>
<ListItemText
disableTypography
className={classes.listItemText}
>
<Translation defaultValue="" i18nKey={route.sidebarI18nLabel} />
</ListItemText>
</ListItem>
</NavLink>
))}
</Collapse>
</List>
);
}
Expand Down
4 changes: 2 additions & 2 deletions imports/client/ui/layouts/ContentViewFullLayout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Component provies a fill width and height, non-scrollable container
* for dashboard layouts that want to defin their on scroll zones.
* Component provides a fill width and height, non-scrollable container
* for dashboard layouts that want to define their on scroll zones.
*/
import React from "react";
import PropTypes from "prop-types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const useStyles = makeStyles((theme) => ({
},
sidebar: {
flex: "1 1 auto",
minWidth: 250,
maxWidth: 330,
height: `calc(100vh - ${theme.mixins.toolbar.minHeight}px)`,
overflowY: "auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Button from "@reactioncommerce/catalyst/Button";
import Grid from "@material-ui/core/Grid";
import MenuItem from "@material-ui/core/MenuItem";
import TextField from "@material-ui/core/TextField";
import { makeStyles } from "@material-ui/styles";
import { makeStyles } from "@material-ui/core";
import muiOptions from "reacto-form/cjs/muiOptions";
import useReactoForm from "reacto-form/cjs/useReactoForm";

Expand Down Expand Up @@ -217,7 +217,7 @@ export default function AddressValidationSettingsForm(props) {
<Button
className={classes.deleteButton}
color="primary"
isDisabled={isSubmitting}
disabled={isSubmitting}
onClick={() => {
deleteRule({
variables: {
Expand All @@ -234,7 +234,7 @@ export default function AddressValidationSettingsForm(props) {
</Button>}
<Button
color="primary"
isDisabled={isSubmitting}
disabled={isSubmitting}
onClick={submitForm}
variant="contained"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import i18next from "i18next";
import { Blocks } from "@reactioncommerce/reaction-components";
import {
makeStyles,
Typography
} from "@material-ui/core";

const useStyles = makeStyles((theme) => ({
header: {
marginBottom: theme.spacing(4)
}
}));

/**
* @summary Renders payment settings page
* @param {Object} props Component props
* @return {React.Node} React node
*/
export default function AddressValidationSettingsRegion(props) {
const classes = useStyles();
return (
<>
<Typography variant="h2" className={classes.header}>
{i18next.t("admin.settings.addressValidation.header")}
</Typography>
<Blocks region="AddressValidationSettings" blockProps={props} />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import Dialog from "@material-ui/core/Dialog";
import DialogContent from "@material-ui/core/DialogContent";
import { makeStyles } from "@material-ui/styles";
import { makeStyles } from "@material-ui/core";
import CountryOptions from "@reactioncommerce/api-utils/CountryOptions.js";
import { i18next } from "/client/api";
import AddressValidationSettingsForm from "./AddressValidationSettingsForm";
Expand Down
13 changes: 11 additions & 2 deletions imports/plugins/core/address/client/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { registerOperatorRoute } from "/imports/client/ui";
import AddressValidationSettingsRegion from "./components/AddressValidationSettingsRegion";
import ShopAddressValidationSettings from "./containers/ShopAddressValidationSettings";
import { registerBlock } from "@reactioncommerce/reaction-components";

registerOperatorRoute({
group: "settings",
MainComponent: ShopAddressValidationSettings,
path: "/address-validation-settings",
MainComponent: AddressValidationSettingsRegion,
path: "/settings/address-validation-settings",
priority: 900,
sidebarI18nLabel: "addressValidation.title"
});

registerBlock({
region: "AddressValidationSettings",
name: "AddressValidationSettings",
component: ShopAddressValidationSettings,
priority: 1
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react";
import i18next from "i18next";
import { Switch, Route } from "react-router-dom";
import {
Container
} from "@material-ui/core";
import PrimaryAppBar from "/imports/client/ui/components/PrimaryAppBar";
import ContentViewPrimaryDetailLayout from "/imports/client/ui/layouts/ContentViewPrimaryDetailLayout";
import useOperatorRoutes from "/imports/client/ui/hooks/useOperatorRoutes";
import SettingsList from "./SettingsList";

/**
* @name SettingsDashboard
* @returns {React.component} a functional React component
*/
export default function SettingsDashboard() {
const settingsRoutes = useOperatorRoutes({ groups: ["settings"] });
return (
<>
willopez marked this conversation as resolved.
Show resolved Hide resolved
<ContentViewPrimaryDetailLayout
AppBarComponent={
<PrimaryAppBar title={i18next.t("admin.settings.settingsLabel")} />
}
PrimaryComponent={
<SettingsList />
}
DetailComponent={
<Container maxWidth="md">
<Switch>
{
settingsRoutes.map((settingRoute) => (
<Route
key={settingRoute.path}
component={settingRoute.MainComponent}
path={settingRoute.path}
/>
))
}
</Switch>
</Container>
}
/>
</>
);
}
67 changes: 67 additions & 0 deletions imports/plugins/core/dashboard/client/components/SettingsList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Fragment } from "react";
import i18next from "i18next";
import {
List,
ListItemText,
makeStyles,
ListItem
} from "@material-ui/core";
import clsx from "classnames";
import { useHistory } from "react-router-dom";
import useOperatorRoutes from "imports/client/ui/hooks/useOperatorRoutes";

const useStyles = makeStyles((theme) => ({
listItemContainer: {
"&:hover $listItemAction": {
display: "block"
}
},
listItem: {
paddingLeft: theme.spacing(4)
}
}));

/**
* @summary A list settings for a shop
* @returns {Node} React node
*/
export default function SettingsList() {
const classes = useStyles();
const history = useHistory();
const settingsRoutes = useOperatorRoutes({ groups: ["settings"] });
let settingsList = [];

if (Array.isArray(settingsRoutes)) {
settingsList = settingsRoutes.map((setting) => (
<Fragment key={`listItem-${setting.path}`}>
willopez marked this conversation as resolved.
Show resolved Hide resolved
<ListItem
component="nav"
ContainerProps={{
className: classes.listItemContainer
}}
ContainerComponent={({ children, ...props }) => (
<li {...props}>
{i18next.t(setting.sidebarI18nLabel) }
{children}
</li>
)}
className={clsx({
[classes.listItem]: true
})}
button
onClick={() => history.push(setting.path)}
>
<ListItemText
primary={i18next.t(setting.sidebarI18nLabel)}
/>
</ListItem>
</Fragment>
));
}

return (
<List>
{settingsRoutes && Array.isArray(settingsRoutes) && settingsList}
</List>
);
}
Loading