diff --git a/src/components/TableHead/TableHead.tsx b/src/components/TableHead/TableHead.tsx index 82a078e83..0ee28e0ec 100644 --- a/src/components/TableHead/TableHead.tsx +++ b/src/components/TableHead/TableHead.tsx @@ -23,10 +23,10 @@ export interface TableHeadProps extends MuiTableHeadProps { colSpan: number; disabled: boolean; dragRows?: boolean; - selected: number; + selected?: number; items: Node[]; toolbar?: React.ReactNode | React.ReactNodeArray; - toggleAll: (items: Node[], selected: number) => void; + toggleAll?: (items: Node[], selected: number) => void; } const styles = (theme: Theme) => @@ -101,25 +101,26 @@ const TableHead = withStyles(styles, { })} /> )} - {(items === undefined || items.length > 0) && ( - - 0) && + (selected && ( + selected && selected > 0 + [classes.checkboxSelected]: selected, + [classes.dragRows]: dragRows })} - checked={selected === 0 ? false : true} - disabled={disabled} - onChange={() => toggleAll(items, selected)} - /> - - )} + > + selected && selected > 0 + })} + checked={selected === 0 ? false : true} + disabled={disabled} + onChange={() => toggleAll(items, selected)} + /> + + ))} {selected ? ( <>
- - {i18n.t("Status")} - + {i18n.t("Status")} ; + errors: FormErrors<"name" | "configuration">; disabled: boolean; onChange: (event: React.ChangeEvent) => void; } @@ -64,6 +61,7 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })( ? configuration.value === "true" : configuration.value } + disabled={disabled} label={configuration.label} name={configuration.name} onChange={onChange} diff --git a/src/plugins/components/PluginsDetailsPage/PluginsDetailsPage.tsx b/src/plugins/components/PluginsDetailsPage/PluginsDetailsPage.tsx index 34f34b72d..43ea9101b 100644 --- a/src/plugins/components/PluginsDetailsPage/PluginsDetailsPage.tsx +++ b/src/plugins/components/PluginsDetailsPage/PluginsDetailsPage.tsx @@ -11,6 +11,7 @@ import { UserError } from "@saleor/types"; import React from "react"; import i18n from "../../../i18n"; +import { Plugin_plugin } from "../../types/Plugin"; import PluginInfo from "../PluginInfo"; import PluginSettings from "../PluginSettings"; @@ -30,7 +31,7 @@ export interface FormData { export interface PluginsDetailsPageProps { disabled: boolean; errors: UserError[]; - plugin: FormData; + plugin: Plugin_plugin; saveButtonBarState: ConfirmButtonTransitionState; onBack: () => void; onSubmit: (data: FormData) => void; @@ -54,23 +55,22 @@ const PluginsDetailsPage: React.StatelessComponent = ({ return (
{({ data, errors, hasChanged, submit, set, triggerChange }) => { - const newData = { - active: data.active, - configuration: data.configuration - }; - const onChange = event => { + const newData = { + active: data.active, + configuration: data.configuration + }; const { name, value } = event.target; name === "active" ? (newData.active = value) : (newData.active = data.active); - newData.configuration && + if (newData.configuration) { newData.configuration.map(item => { if (item.name === name) { item.value = value; } }); - + } triggerChange(); set(newData); }; diff --git a/src/plugins/components/PluginsList/PluginsList.tsx b/src/plugins/components/PluginsList/PluginsList.tsx index 1c2244465..71cb0e4e5 100644 --- a/src/plugins/components/PluginsList/PluginsList.tsx +++ b/src/plugins/components/PluginsList/PluginsList.tsx @@ -13,17 +13,17 @@ import TableRow from "@material-ui/core/TableRow"; import EditIcon from "@material-ui/icons/Edit"; import React from "react"; -import Checkbox from "@saleor/components/Checkbox"; import Skeleton from "@saleor/components/Skeleton"; import StatusLabel from "@saleor/components/StatusLabel"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; import i18n from "@saleor/i18n"; import { maybe, renderCollection } from "@saleor/misc"; -import { ListActionsWithoutToolbar, ListProps } from "@saleor/types"; +import { ListProps } from "@saleor/types"; +import { translateBoolean } from "@saleor/utils/i18n"; import { Plugins_plugins_edges_node } from "../../types/Plugins"; -export interface PluginListProps extends ListProps, ListActionsWithoutToolbar { +export interface PluginListProps extends ListProps { plugins: Plugins_plugins_edges_node[]; } @@ -59,21 +59,15 @@ const PluginList = withStyles(styles, { name: "PluginList" })( pageInfo, onRowClick, onUpdateListSettings, - onPreviousPage, - isChecked, - selected, - toggle, - toggleAll + onPreviousPage }: PluginListProps & WithStyles) => { return ( {i18n.t("Name", { context: "table header" })} @@ -106,24 +100,13 @@ const PluginList = withStyles(styles, { name: "PluginList" })( {renderCollection( plugins, plugin => { - const isSelected = plugin ? isChecked(plugin.id) : false; - return ( - - toggle(plugin.id)} - /> - {maybe(() => plugin.name, )} @@ -131,7 +114,7 @@ const PluginList = withStyles(styles, { name: "PluginList" })( {maybe( () => ( ), diff --git a/src/plugins/components/PluginsListPage/PluginsListPage.tsx b/src/plugins/components/PluginsListPage/PluginsListPage.tsx index 14fa2d467..22cbc7f02 100644 --- a/src/plugins/components/PluginsListPage/PluginsListPage.tsx +++ b/src/plugins/components/PluginsListPage/PluginsListPage.tsx @@ -4,13 +4,11 @@ import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; import i18n from "@saleor/i18n"; -import { ListActionsWithoutToolbar, PageListProps } from "@saleor/types"; +import { PageListProps } from "@saleor/types"; import { Plugins_plugins_edges_node } from "../../types/Plugins"; import PluginsList from "../PluginsList/PluginsList"; -export interface PluginsListPageProps - extends PageListProps, - ListActionsWithoutToolbar { +export interface PluginsListPageProps extends PageListProps { plugins: Plugins_plugins_edges_node[]; onBack: () => void; } @@ -24,11 +22,7 @@ const PluginsListPage: React.StatelessComponent = ({ onRowClick, onUpdateListSettings, pageInfo, - plugins, - isChecked, - selected, - toggle, - toggleAll + plugins }) => ( {i18n.t("Configuration")} @@ -42,10 +36,6 @@ const PluginsListPage: React.StatelessComponent = ({ onUpdateListSettings={onUpdateListSettings} onRowClick={onRowClick} pageInfo={pageInfo} - isChecked={isChecked} - selected={selected} - toggle={toggle} - toggleAll={toggleAll} /> ); diff --git a/src/plugins/urls.ts b/src/plugins/urls.ts index c2bb025e7..e1362170d 100644 --- a/src/plugins/urls.ts +++ b/src/plugins/urls.ts @@ -1,21 +1,16 @@ import { stringify as stringifyQs } from "qs"; import urlJoin from "url-join"; -import { BulkAction, Dialog, Pagination, SingleAction } from "../types"; +import { Pagination, SingleAction } from "../types"; export const pluginsSection = "/plugins/"; export const pluginsListPath = pluginsSection; -export type PluginsListUrlDialog = "remove" | "remove-many"; -export type PluginsListUrlQueryParams = BulkAction & - Dialog & - Pagination & - SingleAction; +export type PluginsListUrlQueryParams = Pagination & SingleAction; export const pluginsListUrl = (params?: PluginsListUrlQueryParams) => pluginsListPath + "?" + stringifyQs(params); export const pluginsPath = (id: string) => urlJoin(pluginsSection, id); -export type PluginsUrlDialog = "edit-item" | "remove"; -export type PluginsUrlQueryParams = Dialog & SingleAction; +export type PluginsUrlQueryParams = SingleAction; export const pluginsUrl = (id: string, params?: PluginsUrlQueryParams) => pluginsPath(encodeURIComponent(id)) + "?" + stringifyQs(params); diff --git a/src/plugins/views/PluginsDetails.tsx b/src/plugins/views/PluginsDetails.tsx index 68e04a245..f5ae113a5 100644 --- a/src/plugins/views/PluginsDetails.tsx +++ b/src/plugins/views/PluginsDetails.tsx @@ -62,20 +62,23 @@ export const PluginsDetails: React.StatelessComponent = ({ plugin={maybe(() => PluginDetails.data.plugin)} onBack={() => navigate(pluginsListUrl())} onSubmit={formData => { - const configurationInput = []; - formData.configuration && - formData.configuration.map(item => { + let configurationInput = []; + if (formData.configuration) { + configurationInput = formData.configuration.map(item => { configurationInput.push({ name: item.name, value: item.value.toString() }); }); + } pluginUpdate({ variables: { id, input: { active: formData.active, configuration: configurationInput + ? configurationInput + : null } } }); diff --git a/src/plugins/views/PluginsList.tsx b/src/plugins/views/PluginsList.tsx index fdda7d422..8d0c00694 100644 --- a/src/plugins/views/PluginsList.tsx +++ b/src/plugins/views/PluginsList.tsx @@ -1,5 +1,4 @@ import { configurationMenuUrl } from "@saleor/configuration"; -import useBulkActions from "@saleor/hooks/useBulkActions"; import useListSettings from "@saleor/hooks/useListSettings"; import useNavigator from "@saleor/hooks/useNavigator"; import usePaginator, { @@ -21,9 +20,6 @@ export const PluginsList: React.StatelessComponent = ({ }) => { const navigate = useNavigator(); const paginate = usePaginator(); - const { isSelected, listElements, toggle, toggleAll } = useBulkActions( - params.ids - ); const { updateListSettings, settings } = useListSettings( ListViews.PLUGINS_LIST ); @@ -50,10 +46,6 @@ export const PluginsList: React.StatelessComponent = ({ onPreviousPage={loadPreviousPage} onUpdateListSettings={updateListSettings} onRowClick={id => () => navigate(pluginsUrl(id))} - isChecked={isSelected} - selected={listElements.length} - toggle={toggle} - toggleAll={toggleAll} /> ); diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index be3b27689..fbddaa2e6 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -10729,6 +10729,7 @@ exports[`Storyshots Views / Attributes / Attribute list default 1`] = `
+ 0
@@ -10738,22 +10739,6 @@ exports[`Storyshots Views / Attributes / Attribute list default 1`] = ` -
- - + 0 @@ -11463,24 +11449,6 @@ exports[`Storyshots Views / Attributes / Attribute list loading 1`] = ` -
- - + 0 @@ -12418,22 +12387,6 @@ exports[`Storyshots Views / Categories / Category list default 1`] = ` -
- - + 0 @@ -13066,22 +13020,6 @@ exports[`Storyshots Views / Categories / Category list loading 1`] = ` -
- - + 0 @@ -15748,24 +15687,6 @@ Ctrl + K" -
- - + 0 @@ -19809,22 +19731,6 @@ Ctrl + K" -
- - + 0 @@ -21354,22 +21261,6 @@ Ctrl + K" -
- - + 0 @@ -22502,24 +22394,6 @@ Ctrl + K" -
- - + 0 @@ -24120,22 +23995,6 @@ exports[`Storyshots Views / Collections / Collection list default 1`] = ` -
- - + 0 @@ -24574,24 +24434,6 @@ exports[`Storyshots Views / Collections / Collection list loading 1`] = ` -
- - + 0 @@ -34390,22 +34233,6 @@ exports[`Storyshots Views / Customers / Customer list default 1`] = ` -
- - + 0 @@ -35432,24 +35260,6 @@ exports[`Storyshots Views / Customers / Customer list loading 1`] = ` -
- - + 0 @@ -37011,22 +36822,6 @@ exports[`Storyshots Views / Discounts / Sale details collections 1`] = ` -
- - + 0 @@ -37603,22 +37399,6 @@ exports[`Storyshots Views / Discounts / Sale details default 1`] = ` -
- - + 0 @@ -38215,22 +37996,6 @@ exports[`Storyshots Views / Discounts / Sale details form errors 1`] = ` -
- - + 0 @@ -38816,24 +38582,6 @@ exports[`Storyshots Views / Discounts / Sale details loading 1`] = ` -
- - + 0 @@ -39438,22 +39187,6 @@ exports[`Storyshots Views / Discounts / Sale details products 1`] = ` -
- - + 0 @@ -40049,22 +39783,6 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` -
- - + 0 @@ -40505,22 +40224,6 @@ exports[`Storyshots Views / Discounts / Sale list loading 1`] = ` -
- - + 0 @@ -45414,22 +45118,6 @@ exports[`Storyshots Views / Discounts / Voucher list default 1`] = ` -
- - + 0 @@ -45767,22 +45456,6 @@ exports[`Storyshots Views / Discounts / Voucher list loading 1`] = ` -
- - + 0 @@ -48984,22 +48658,6 @@ exports[`Storyshots Views / Navigation / Menu list default 1`] = ` -
- - + 0 @@ -49320,24 +48979,6 @@ exports[`Storyshots Views / Navigation / Menu list loading 1`] = ` -
- - + 0 @@ -49878,22 +49520,6 @@ exports[`Storyshots Views / Orders / Draft order list default 1`] = ` -
- - + 0 @@ -51010,24 +50637,6 @@ exports[`Storyshots Views / Orders / Draft order list loading 1`] = ` -
- - + 0 @@ -66675,22 +66285,6 @@ exports[`Storyshots Views / Orders / Order list default 1`] = ` -
- - + 0 @@ -68300,24 +67895,6 @@ exports[`Storyshots Views / Orders / Order list loading 1`] = ` -
- - + 0 @@ -69562,22 +69140,6 @@ exports[`Storyshots Views / Orders / Order list with custom filters 1`] = ` -
- - + 0 @@ -73395,22 +72958,6 @@ exports[`Storyshots Views / Pages / Page list default 1`] = ` -
- - + 0 @@ -73773,24 +73321,6 @@ exports[`Storyshots Views / Pages / Page list loading 1`] = ` - - - -
- - -
Status -
+

- - - - - @@ -75254,21 +74753,6 @@ exports[`Storyshots Views / Plugins / Plugin list default 1`] = `
- - - - - @@ -76691,6 +76140,7 @@ exports[`Storyshots Views / Product types / Product type details default 1`] = `
+ 0 @@ -76704,22 +76154,6 @@ exports[`Storyshots Views / Product types / Product type details default 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id" scope="col" /> -
- - + 0 @@ -77340,22 +76775,6 @@ exports[`Storyshots Views / Product types / Product type details form errors 1`] class="MuiTableCell-root-id MuiTableCell-head-id" scope="col" /> -
- - + 0 @@ -77977,24 +77397,6 @@ exports[`Storyshots Views / Product types / Product type details loading 1`] = ` class="MuiTableCell-root-id MuiTableCell-head-id" scope="col" /> -
- - + 0 @@ -78606,22 +78009,6 @@ exports[`Storyshots Views / Product types / Product types list default 1`] = ` -
- - + 0 @@ -78987,24 +78375,6 @@ exports[`Storyshots Views / Product types / Product types list loading 1`] = ` -
- - + 0 @@ -85576,22 +84947,6 @@ Ctrl + K" -
- - + 0 @@ -88312,22 +87668,6 @@ Ctrl + K" -
- - + 0 @@ -91112,22 +90453,6 @@ exports[`Storyshots Views / Products / Product list default 1`] = ` -
- - + 0 @@ -92119,24 +91445,6 @@ exports[`Storyshots Views / Products / Product list loading 1`] = ` -
- - + 0 @@ -93474,22 +92783,6 @@ exports[`Storyshots Views / Products / Product list with custom filters 1`] = ` -
- - + 0 @@ -98320,22 +97614,6 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = ` -
- - + 0 @@ -98939,24 +98218,6 @@ exports[`Storyshots Views / Shipping / Shipping zones list loading 1`] = ` -
- - undefined, onBack: () => undefined, - plugins: pluginList, - selected: undefined, - toggle: () => undefined, - toggleAll: () => undefined + plugins: pluginList }; storiesOf("Views / Plugins / Plugin list", module)