Hide toolbar, checkboxes, Fix small issues
This commit is contained in:
parent
be5be600c7
commit
89de66be65
11 changed files with 101 additions and 888 deletions
|
@ -23,10 +23,10 @@ export interface TableHeadProps extends MuiTableHeadProps {
|
||||||
colSpan: number;
|
colSpan: number;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
dragRows?: boolean;
|
dragRows?: boolean;
|
||||||
selected: number;
|
selected?: number;
|
||||||
items: Node[];
|
items: Node[];
|
||||||
toolbar?: React.ReactNode | React.ReactNodeArray;
|
toolbar?: React.ReactNode | React.ReactNodeArray;
|
||||||
toggleAll: (items: Node[], selected: number) => void;
|
toggleAll?: (items: Node[], selected: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = (theme: Theme) =>
|
const styles = (theme: Theme) =>
|
||||||
|
@ -101,7 +101,8 @@ const TableHead = withStyles(styles, {
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{(items === undefined || items.length > 0) && (
|
{(items === undefined || items.length > 0) &&
|
||||||
|
(selected && (
|
||||||
<TableCell
|
<TableCell
|
||||||
padding="checkbox"
|
padding="checkbox"
|
||||||
className={classNames({
|
className={classNames({
|
||||||
|
@ -119,7 +120,7 @@ const TableHead = withStyles(styles, {
|
||||||
onChange={() => toggleAll(items, selected)}
|
onChange={() => toggleAll(items, selected)}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
)}
|
))}
|
||||||
{selected ? (
|
{selected ? (
|
||||||
<>
|
<>
|
||||||
<TableCell
|
<TableCell
|
||||||
|
|
|
@ -18,13 +18,9 @@ interface PluginInfoProps {
|
||||||
|
|
||||||
const styles = createStyles({
|
const styles = createStyles({
|
||||||
status: {
|
status: {
|
||||||
color: "#3D3D3D",
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: 400,
|
|
||||||
paddingTop: 20
|
paddingTop: 20
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
color: "#616161",
|
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
paddingTop: 10
|
paddingTop: 10
|
||||||
}
|
}
|
||||||
|
@ -58,9 +54,7 @@ const PluginInfo = withStyles(styles, { name: "PluginInfo" })(
|
||||||
)}
|
)}
|
||||||
<FormSpacer />
|
<FormSpacer />
|
||||||
<Hr />
|
<Hr />
|
||||||
<Typography className={classes.status} variant="h6">
|
<Typography className={classes.status}>{i18n.t("Status")}</Typography>
|
||||||
{i18n.t("Status")}
|
|
||||||
</Typography>
|
|
||||||
<ControlledSwitch
|
<ControlledSwitch
|
||||||
checked={data.active}
|
checked={data.active}
|
||||||
label={"Set plugin as Active"}
|
label={"Set plugin as Active"}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
|
||||||
import TextField from "@material-ui/core/TextField";
|
import TextField from "@material-ui/core/TextField";
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import ControlledSwitch from "@saleor/components/ControlledSwitch";
|
import ControlledSwitch from "@saleor/components/ControlledSwitch";
|
||||||
|
import { FormErrors } from "@saleor/types";
|
||||||
import { ConfigurationTypeFieldEnum } from "@saleor/types/globalTypes";
|
import { ConfigurationTypeFieldEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import i18n from "../../../i18n";
|
import i18n from "../../../i18n";
|
||||||
|
@ -11,11 +12,7 @@ import { FormData } from "../PluginsDetailsPage";
|
||||||
|
|
||||||
interface PluginSettingsProps {
|
interface PluginSettingsProps {
|
||||||
data: FormData;
|
data: FormData;
|
||||||
errors: Partial<{
|
errors: FormErrors<"name" | "configuration">;
|
||||||
description: string;
|
|
||||||
domain: string;
|
|
||||||
name: string;
|
|
||||||
}>;
|
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +61,7 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
? configuration.value === "true"
|
? configuration.value === "true"
|
||||||
: configuration.value
|
: configuration.value
|
||||||
}
|
}
|
||||||
|
disabled={disabled}
|
||||||
label={configuration.label}
|
label={configuration.label}
|
||||||
name={configuration.name}
|
name={configuration.name}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { UserError } from "@saleor/types";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import i18n from "../../../i18n";
|
import i18n from "../../../i18n";
|
||||||
|
import { Plugin_plugin } from "../../types/Plugin";
|
||||||
import PluginInfo from "../PluginInfo";
|
import PluginInfo from "../PluginInfo";
|
||||||
import PluginSettings from "../PluginSettings";
|
import PluginSettings from "../PluginSettings";
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ export interface FormData {
|
||||||
export interface PluginsDetailsPageProps {
|
export interface PluginsDetailsPageProps {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: UserError[];
|
||||||
plugin: FormData;
|
plugin: Plugin_plugin;
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onSubmit: (data: FormData) => void;
|
onSubmit: (data: FormData) => void;
|
||||||
|
@ -54,23 +55,22 @@ const PluginsDetailsPage: React.StatelessComponent<PluginsDetailsPageProps> = ({
|
||||||
return (
|
return (
|
||||||
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
||||||
{({ data, errors, hasChanged, submit, set, triggerChange }) => {
|
{({ data, errors, hasChanged, submit, set, triggerChange }) => {
|
||||||
|
const onChange = event => {
|
||||||
const newData = {
|
const newData = {
|
||||||
active: data.active,
|
active: data.active,
|
||||||
configuration: data.configuration
|
configuration: data.configuration
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChange = event => {
|
|
||||||
const { name, value } = event.target;
|
const { name, value } = event.target;
|
||||||
name === "active"
|
name === "active"
|
||||||
? (newData.active = value)
|
? (newData.active = value)
|
||||||
: (newData.active = data.active);
|
: (newData.active = data.active);
|
||||||
newData.configuration &&
|
if (newData.configuration) {
|
||||||
newData.configuration.map(item => {
|
newData.configuration.map(item => {
|
||||||
if (item.name === name) {
|
if (item.name === name) {
|
||||||
item.value = value;
|
item.value = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
triggerChange();
|
triggerChange();
|
||||||
set(newData);
|
set(newData);
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,17 +13,17 @@ import TableRow from "@material-ui/core/TableRow";
|
||||||
import EditIcon from "@material-ui/icons/Edit";
|
import EditIcon from "@material-ui/icons/Edit";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import Checkbox from "@saleor/components/Checkbox";
|
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
import StatusLabel from "@saleor/components/StatusLabel";
|
import StatusLabel from "@saleor/components/StatusLabel";
|
||||||
import TableHead from "@saleor/components/TableHead";
|
import TableHead from "@saleor/components/TableHead";
|
||||||
import TablePagination from "@saleor/components/TablePagination";
|
import TablePagination from "@saleor/components/TablePagination";
|
||||||
import i18n from "@saleor/i18n";
|
import i18n from "@saleor/i18n";
|
||||||
import { maybe, renderCollection } from "@saleor/misc";
|
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";
|
import { Plugins_plugins_edges_node } from "../../types/Plugins";
|
||||||
|
|
||||||
export interface PluginListProps extends ListProps, ListActionsWithoutToolbar {
|
export interface PluginListProps extends ListProps {
|
||||||
plugins: Plugins_plugins_edges_node[];
|
plugins: Plugins_plugins_edges_node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,21 +59,15 @@ const PluginList = withStyles(styles, { name: "PluginList" })(
|
||||||
pageInfo,
|
pageInfo,
|
||||||
onRowClick,
|
onRowClick,
|
||||||
onUpdateListSettings,
|
onUpdateListSettings,
|
||||||
onPreviousPage,
|
onPreviousPage
|
||||||
isChecked,
|
|
||||||
selected,
|
|
||||||
toggle,
|
|
||||||
toggleAll
|
|
||||||
}: PluginListProps & WithStyles<typeof styles>) => {
|
}: PluginListProps & WithStyles<typeof styles>) => {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
selected={selected}
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
items={plugins}
|
items={plugins}
|
||||||
toggleAll={toggleAll}
|
|
||||||
>
|
>
|
||||||
<TableCell className={classes.colName} padding="dense">
|
<TableCell className={classes.colName} padding="dense">
|
||||||
{i18n.t("Name", { context: "table header" })}
|
{i18n.t("Name", { context: "table header" })}
|
||||||
|
@ -106,24 +100,13 @@ const PluginList = withStyles(styles, { name: "PluginList" })(
|
||||||
{renderCollection(
|
{renderCollection(
|
||||||
plugins,
|
plugins,
|
||||||
plugin => {
|
plugin => {
|
||||||
const isSelected = plugin ? isChecked(plugin.id) : false;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
hover={!!plugin}
|
hover={!!plugin}
|
||||||
className={!!plugin ? classes.link : undefined}
|
className={!!plugin ? classes.link : undefined}
|
||||||
onClick={plugin ? onRowClick(plugin.id) : undefined}
|
onClick={plugin ? onRowClick(plugin.id) : undefined}
|
||||||
key={plugin ? plugin.id : "skeleton"}
|
key={plugin ? plugin.id : "skeleton"}
|
||||||
selected={isSelected}
|
|
||||||
>
|
>
|
||||||
<TableCell padding="checkbox">
|
|
||||||
<Checkbox
|
|
||||||
checked={isSelected}
|
|
||||||
disabled={disabled}
|
|
||||||
disableClickPropagation
|
|
||||||
onChange={() => toggle(plugin.id)}
|
|
||||||
/>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className={classes.colName}>
|
<TableCell className={classes.colName}>
|
||||||
{maybe<React.ReactNode>(() => plugin.name, <Skeleton />)}
|
{maybe<React.ReactNode>(() => plugin.name, <Skeleton />)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
@ -131,7 +114,7 @@ const PluginList = withStyles(styles, { name: "PluginList" })(
|
||||||
{maybe<React.ReactNode>(
|
{maybe<React.ReactNode>(
|
||||||
() => (
|
() => (
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
label={plugin.active ? i18n.t("Yes") : i18n.t("No")}
|
label={translateBoolean(plugin.active)}
|
||||||
status={plugin.active ? "success" : "error"}
|
status={plugin.active ? "success" : "error"}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,13 +4,11 @@ import AppHeader from "@saleor/components/AppHeader";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import i18n from "@saleor/i18n";
|
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 { Plugins_plugins_edges_node } from "../../types/Plugins";
|
||||||
import PluginsList from "../PluginsList/PluginsList";
|
import PluginsList from "../PluginsList/PluginsList";
|
||||||
|
|
||||||
export interface PluginsListPageProps
|
export interface PluginsListPageProps extends PageListProps {
|
||||||
extends PageListProps,
|
|
||||||
ListActionsWithoutToolbar {
|
|
||||||
plugins: Plugins_plugins_edges_node[];
|
plugins: Plugins_plugins_edges_node[];
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
}
|
}
|
||||||
|
@ -24,11 +22,7 @@ const PluginsListPage: React.StatelessComponent<PluginsListPageProps> = ({
|
||||||
onRowClick,
|
onRowClick,
|
||||||
onUpdateListSettings,
|
onUpdateListSettings,
|
||||||
pageInfo,
|
pageInfo,
|
||||||
plugins,
|
plugins
|
||||||
isChecked,
|
|
||||||
selected,
|
|
||||||
toggle,
|
|
||||||
toggleAll
|
|
||||||
}) => (
|
}) => (
|
||||||
<Container>
|
<Container>
|
||||||
<AppHeader onBack={onBack}>{i18n.t("Configuration")}</AppHeader>
|
<AppHeader onBack={onBack}>{i18n.t("Configuration")}</AppHeader>
|
||||||
|
@ -42,10 +36,6 @@ const PluginsListPage: React.StatelessComponent<PluginsListPageProps> = ({
|
||||||
onUpdateListSettings={onUpdateListSettings}
|
onUpdateListSettings={onUpdateListSettings}
|
||||||
onRowClick={onRowClick}
|
onRowClick={onRowClick}
|
||||||
pageInfo={pageInfo}
|
pageInfo={pageInfo}
|
||||||
isChecked={isChecked}
|
|
||||||
selected={selected}
|
|
||||||
toggle={toggle}
|
|
||||||
toggleAll={toggleAll}
|
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
import { stringify as stringifyQs } from "qs";
|
import { stringify as stringifyQs } from "qs";
|
||||||
import urlJoin from "url-join";
|
import urlJoin from "url-join";
|
||||||
|
|
||||||
import { BulkAction, Dialog, Pagination, SingleAction } from "../types";
|
import { Pagination, SingleAction } from "../types";
|
||||||
|
|
||||||
export const pluginsSection = "/plugins/";
|
export const pluginsSection = "/plugins/";
|
||||||
|
|
||||||
export const pluginsListPath = pluginsSection;
|
export const pluginsListPath = pluginsSection;
|
||||||
export type PluginsListUrlDialog = "remove" | "remove-many";
|
export type PluginsListUrlQueryParams = Pagination & SingleAction;
|
||||||
export type PluginsListUrlQueryParams = BulkAction &
|
|
||||||
Dialog<PluginsListUrlDialog> &
|
|
||||||
Pagination &
|
|
||||||
SingleAction;
|
|
||||||
export const pluginsListUrl = (params?: PluginsListUrlQueryParams) =>
|
export const pluginsListUrl = (params?: PluginsListUrlQueryParams) =>
|
||||||
pluginsListPath + "?" + stringifyQs(params);
|
pluginsListPath + "?" + stringifyQs(params);
|
||||||
|
|
||||||
export const pluginsPath = (id: string) => urlJoin(pluginsSection, id);
|
export const pluginsPath = (id: string) => urlJoin(pluginsSection, id);
|
||||||
export type PluginsUrlDialog = "edit-item" | "remove";
|
export type PluginsUrlQueryParams = SingleAction;
|
||||||
export type PluginsUrlQueryParams = Dialog<PluginsUrlDialog> & SingleAction;
|
|
||||||
export const pluginsUrl = (id: string, params?: PluginsUrlQueryParams) =>
|
export const pluginsUrl = (id: string, params?: PluginsUrlQueryParams) =>
|
||||||
pluginsPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
pluginsPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
||||||
|
|
|
@ -62,20 +62,23 @@ export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
||||||
plugin={maybe(() => PluginDetails.data.plugin)}
|
plugin={maybe(() => PluginDetails.data.plugin)}
|
||||||
onBack={() => navigate(pluginsListUrl())}
|
onBack={() => navigate(pluginsListUrl())}
|
||||||
onSubmit={formData => {
|
onSubmit={formData => {
|
||||||
const configurationInput = [];
|
let configurationInput = [];
|
||||||
formData.configuration &&
|
if (formData.configuration) {
|
||||||
formData.configuration.map(item => {
|
configurationInput = formData.configuration.map(item => {
|
||||||
configurationInput.push({
|
configurationInput.push({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
value: item.value.toString()
|
value: item.value.toString()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
pluginUpdate({
|
pluginUpdate({
|
||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
input: {
|
input: {
|
||||||
active: formData.active,
|
active: formData.active,
|
||||||
configuration: configurationInput
|
configuration: configurationInput
|
||||||
|
? configurationInput
|
||||||
|
: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { configurationMenuUrl } from "@saleor/configuration";
|
import { configurationMenuUrl } from "@saleor/configuration";
|
||||||
import useBulkActions from "@saleor/hooks/useBulkActions";
|
|
||||||
import useListSettings from "@saleor/hooks/useListSettings";
|
import useListSettings from "@saleor/hooks/useListSettings";
|
||||||
import useNavigator from "@saleor/hooks/useNavigator";
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
import usePaginator, {
|
import usePaginator, {
|
||||||
|
@ -21,9 +20,6 @@ export const PluginsList: React.StatelessComponent<PluginsListProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigator();
|
const navigate = useNavigator();
|
||||||
const paginate = usePaginator();
|
const paginate = usePaginator();
|
||||||
const { isSelected, listElements, toggle, toggleAll } = useBulkActions(
|
|
||||||
params.ids
|
|
||||||
);
|
|
||||||
const { updateListSettings, settings } = useListSettings(
|
const { updateListSettings, settings } = useListSettings(
|
||||||
ListViews.PLUGINS_LIST
|
ListViews.PLUGINS_LIST
|
||||||
);
|
);
|
||||||
|
@ -50,10 +46,6 @@ export const PluginsList: React.StatelessComponent<PluginsListProps> = ({
|
||||||
onPreviousPage={loadPreviousPage}
|
onPreviousPage={loadPreviousPage}
|
||||||
onUpdateListSettings={updateListSettings}
|
onUpdateListSettings={updateListSettings}
|
||||||
onRowClick={id => () => navigate(pluginsUrl(id))}
|
onRowClick={id => () => navigate(pluginsUrl(id))}
|
||||||
isChecked={isSelected}
|
|
||||||
selected={listElements.length}
|
|
||||||
toggle={toggle}
|
|
||||||
toggleAll={toggleAll}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,12 +10,8 @@ import Decorator from "../../Decorator";
|
||||||
|
|
||||||
const props: PluginsListPageProps = {
|
const props: PluginsListPageProps = {
|
||||||
...pageListProps.default,
|
...pageListProps.default,
|
||||||
isChecked: () => undefined,
|
|
||||||
onBack: () => undefined,
|
onBack: () => undefined,
|
||||||
plugins: pluginList,
|
plugins: pluginList
|
||||||
selected: undefined,
|
|
||||||
toggle: () => undefined,
|
|
||||||
toggleAll: () => undefined
|
|
||||||
};
|
};
|
||||||
|
|
||||||
storiesOf("Views / Plugins / Plugin list", module)
|
storiesOf("Views / Plugins / Plugin list", module)
|
||||||
|
|
Loading…
Reference in a new issue