-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from reactioncommerce/refactor-settings-forms…
…-to-use-gql Refactor shop settings forms to use GraphQL
- Loading branch information
Showing
50 changed files
with
1,372 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
imports/plugins/core/address/client/components/AddressValidationSettingsRegion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
priority: 900, | ||
MainComponent: AddressValidationSettingsRegion, | ||
path: "/settings/address-validation-settings", | ||
priority: 170, | ||
sidebarI18nLabel: "addressValidation.title" | ||
}); | ||
|
||
registerBlock({ | ||
region: "AddressValidationSettings", | ||
name: "AddressValidationSettings", | ||
component: ShopAddressValidationSettings, | ||
priority: 1 | ||
}); |
43 changes: 43 additions & 0 deletions
43
imports/plugins/core/dashboard/client/components/SettingsDashboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 ( | ||
<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> | ||
} | ||
/> | ||
); | ||
} |
66 changes: 66 additions & 0 deletions
66
imports/plugins/core/dashboard/client/components/SettingsList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React 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) => ( | ||
<ListItem | ||
key={`listItem-${setting.path}`} | ||
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> | ||
)); | ||
} | ||
|
||
return ( | ||
<List> | ||
{settingsRoutes && Array.isArray(settingsRoutes) && settingsList} | ||
</List> | ||
); | ||
} |
Oops, something went wrong.