Fix types
This commit is contained in:
parent
08b6eb6eb5
commit
4d4f5b4b66
16 changed files with 153 additions and 194 deletions
|
@ -25,7 +25,7 @@ export interface TableHeadProps extends MuiTableHeadProps {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ const TableHead = withStyles(styles, {
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
<div className={classes.spacer} />
|
<div className={classes.spacer} />
|
||||||
<div className={classes.toolbar}>{toolbar}</div>
|
{toolbar && <div className={classes.toolbar}>{toolbar}</div>}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -21,6 +21,7 @@ export interface AppListViewSettings {
|
||||||
[ListViews.NAVIGATION_LIST]: ListSettings;
|
[ListViews.NAVIGATION_LIST]: ListSettings;
|
||||||
[ListViews.ORDER_LIST]: ListSettings;
|
[ListViews.ORDER_LIST]: ListSettings;
|
||||||
[ListViews.PAGES_LIST]: ListSettings;
|
[ListViews.PAGES_LIST]: ListSettings;
|
||||||
|
[ListViews.PLUGINS_LIST]: ListSettings;
|
||||||
[ListViews.PRODUCT_LIST]: ListSettings<ProductListColumns>;
|
[ListViews.PRODUCT_LIST]: ListSettings<ProductListColumns>;
|
||||||
[ListViews.SALES_LIST]: ListSettings;
|
[ListViews.SALES_LIST]: ListSettings;
|
||||||
[ListViews.SHIPPING_METHODS_LIST]: ListSettings;
|
[ListViews.SHIPPING_METHODS_LIST]: ListSettings;
|
||||||
|
@ -49,6 +50,9 @@ export const defaultListSettings: AppListViewSettings = {
|
||||||
[ListViews.PAGES_LIST]: {
|
[ListViews.PAGES_LIST]: {
|
||||||
rowNumber: PAGINATE_BY
|
rowNumber: PAGINATE_BY
|
||||||
},
|
},
|
||||||
|
[ListViews.PLUGINS_LIST]: {
|
||||||
|
rowNumber: PAGINATE_BY
|
||||||
|
},
|
||||||
[ListViews.PRODUCT_LIST]: {
|
[ListViews.PRODUCT_LIST]: {
|
||||||
columns: ["isPublished", "price", "productType"],
|
columns: ["isPublished", "price", "productType"],
|
||||||
rowNumber: PAGINATE_BY
|
rowNumber: PAGINATE_BY
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from "@material-ui/core/Card";
|
||||||
import CardContent from "@material-ui/core/CardContent";
|
import CardContent from "@material-ui/core/CardContent";
|
||||||
import {
|
import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
|
||||||
createStyles,
|
|
||||||
Theme,
|
|
||||||
withStyles,
|
|
||||||
WithStyles
|
|
||||||
} from "@material-ui/core/styles";
|
|
||||||
import TextField from "@material-ui/core/TextField";
|
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
@ -19,36 +13,27 @@ import { FormData } from "../PluginsDetailsPage";
|
||||||
|
|
||||||
interface PluginInfoProps {
|
interface PluginInfoProps {
|
||||||
data: FormData;
|
data: FormData;
|
||||||
errors: Partial<{
|
|
||||||
description: string;
|
|
||||||
domain: string;
|
|
||||||
name: string;
|
|
||||||
}>;
|
|
||||||
disabled: boolean;
|
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = (theme: Theme) =>
|
const styles = createStyles({
|
||||||
createStyles({
|
status: {
|
||||||
title: {
|
color: "#3D3D3D",
|
||||||
fontSize: 14,
|
fontSize: 16,
|
||||||
color: "#616161",
|
fontWeight: 400,
|
||||||
paddingTop: 10
|
paddingTop: 20
|
||||||
},
|
},
|
||||||
status: {
|
title: {
|
||||||
fontSize: 16,
|
color: "#616161",
|
||||||
color: "#3D3D3D",
|
fontSize: 14,
|
||||||
paddingTop: 20,
|
paddingTop: 10
|
||||||
fontWeight: "400"
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const PluginInfo = withStyles(styles, { name: "PluginInfo" })(
|
const PluginInfo = withStyles(styles, { name: "PluginInfo" })(
|
||||||
({
|
({
|
||||||
data,
|
data,
|
||||||
disabled,
|
|
||||||
classes,
|
classes,
|
||||||
errors,
|
|
||||||
onChange
|
onChange
|
||||||
}: PluginInfoProps & WithStyles<typeof styles>) => {
|
}: PluginInfoProps & WithStyles<typeof styles>) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from "@material-ui/core/Card";
|
||||||
import CardContent from "@material-ui/core/CardContent";
|
import CardContent from "@material-ui/core/CardContent";
|
||||||
import ControlledSwitch from "@saleor/components/ControlledSwitch";
|
import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
|
||||||
import {
|
|
||||||
createStyles,
|
|
||||||
Theme,
|
|
||||||
withStyles,
|
|
||||||
WithStyles
|
|
||||||
} from "@material-ui/core/styles";
|
|
||||||
import TextField from "@material-ui/core/TextField";
|
import TextField from "@material-ui/core/TextField";
|
||||||
import Typography from "@material-ui/core/Typography";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import FormSpacer from "@saleor/components/FormSpacer";
|
import ControlledSwitch from "@saleor/components/ControlledSwitch";
|
||||||
|
import React from "react";
|
||||||
import i18n from "../../../i18n";
|
import i18n from "../../../i18n";
|
||||||
import { FormData } from "../PluginsDetailsPage";
|
import { FormData } from "../PluginsDetailsPage";
|
||||||
|
|
||||||
|
@ -27,13 +19,12 @@ interface PluginSettingsProps {
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = (theme: Theme) =>
|
const styles = createStyles({
|
||||||
createStyles({
|
item: {
|
||||||
item: {
|
paddingBottom: 5,
|
||||||
marginBottom: 5,
|
paddingTop: 5
|
||||||
marginTop: 10
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
({
|
({
|
||||||
|
@ -42,7 +33,8 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
classes,
|
classes,
|
||||||
errors,
|
errors,
|
||||||
onChange
|
onChange
|
||||||
}: PluginSettingsProps & WithStyles<typeof styles>) => (
|
}: PluginSettingsProps & WithStyles<typeof styles>) => {
|
||||||
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
title={i18n.t("Plugin Settings", {
|
title={i18n.t("Plugin Settings", {
|
||||||
|
@ -51,10 +43,9 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
/>
|
/>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{data.configuration.map((configuration, index) => (
|
{data.configuration.map((configuration, index) => (
|
||||||
<div className={classes.item} key={`item-${index}`}>
|
<div className={classes.item} key={index}>
|
||||||
{configuration.type === "STRING" && (
|
{configuration.type === "STRING" && (
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.item}
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
error={!!errors.name}
|
error={!!errors.name}
|
||||||
label={configuration.label}
|
label={configuration.label}
|
||||||
|
@ -66,8 +57,7 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
)}
|
)}
|
||||||
{configuration.type === "BOOLEAN" && (
|
{configuration.type === "BOOLEAN" && (
|
||||||
<ControlledSwitch
|
<ControlledSwitch
|
||||||
className={classes.item}
|
checked={configuration.value === "true"}
|
||||||
checked={configuration.value}
|
|
||||||
label={configuration.label}
|
label={configuration.label}
|
||||||
name={configuration.name}
|
name={configuration.name}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
@ -78,6 +68,7 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
PluginSettings.displayName = "PluginSettings";
|
PluginSettings.displayName = "PluginSettings";
|
||||||
export default PluginSettings;
|
export default PluginSettings;
|
||||||
|
|
|
@ -1,42 +1,36 @@
|
||||||
import React from "react";
|
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import CardSpacer from "@saleor/components/CardSpacer";
|
|
||||||
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
import Form from "@saleor/components/Form";
|
import Form from "@saleor/components/Form";
|
||||||
import Grid from "@saleor/components/Grid";
|
import Grid from "@saleor/components/Grid";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
import SeoForm from "@saleor/components/SeoForm";
|
import { maybe } from "@saleor/misc";
|
||||||
import VisibilityCard from "@saleor/components/VisibilityCard";
|
import { UserError } from "@saleor/types";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
import i18n from "../../../i18n";
|
import i18n from "../../../i18n";
|
||||||
import { maybe } from "../../../misc";
|
|
||||||
import { UserError } from "../../../types";
|
|
||||||
import { PageDetails_page } from "../../types/PluginDetails";
|
|
||||||
import PluginInfo from "../PluginInfo";
|
import PluginInfo from "../PluginInfo";
|
||||||
import PluginSettings from "../PluginSettings";
|
import PluginSettings from "../PluginSettings";
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
name: string;
|
name?: string;
|
||||||
description: string;
|
description?: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
id: string;
|
configuration: Array<{
|
||||||
configuration: [
|
name: string;
|
||||||
{
|
value: string;
|
||||||
name: string;
|
type: string;
|
||||||
value: string;
|
helpText: string;
|
||||||
type: string;
|
label: string;
|
||||||
helpText: string;
|
}>;
|
||||||
label: string;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PageDetailsPageProps {
|
export interface PageDetailsPageProps {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: UserError[];
|
||||||
plugin: PageDetails_page;
|
plugin: FormData;
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onSubmit: (data: FormData) => void;
|
onSubmit: (data: FormData) => void;
|
||||||
|
@ -51,22 +45,14 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
|
||||||
onSubmit
|
onSubmit
|
||||||
}) => {
|
}) => {
|
||||||
const initialForm: FormData = {
|
const initialForm: FormData = {
|
||||||
name: maybe(() => plugin.name, ""),
|
|
||||||
description: maybe(() => plugin.description, ""),
|
|
||||||
active: maybe(() => plugin.active, false),
|
active: maybe(() => plugin.active, false),
|
||||||
configuration: maybe(() => plugin.configuration, [])
|
configuration: maybe(() => plugin.configuration, []),
|
||||||
|
description: maybe(() => plugin.description, ""),
|
||||||
|
name: maybe(() => plugin.name, "")
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
||||||
{({
|
{({ data, errors, hasChanged, submit, set, triggerChange }) => {
|
||||||
change,
|
|
||||||
data,
|
|
||||||
errors: formErrors,
|
|
||||||
hasChanged,
|
|
||||||
submit,
|
|
||||||
set,
|
|
||||||
triggerChange
|
|
||||||
}) => {
|
|
||||||
const newData = {
|
const newData = {
|
||||||
active: data.active,
|
active: data.active,
|
||||||
configuration: data.configuration
|
configuration: data.configuration
|
||||||
|
@ -104,12 +90,7 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<PluginInfo
|
<PluginInfo data={data} onChange={onChange} />
|
||||||
data={data}
|
|
||||||
errors={errors}
|
|
||||||
disabled={disabled}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
{data.configuration && (
|
{data.configuration && (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -20,28 +20,28 @@ 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 { ListActions, ListProps } from "@saleor/types";
|
import { ListActionsWithoutToolbar, ListProps } from "@saleor/types";
|
||||||
import { PageList_pages_edges_node } from "../../types/PageList";
|
import { PluginConfigurations_pluginConfigurations_edges_node } from "../../types/pluginConfigurations";
|
||||||
|
|
||||||
export interface PluginListProps extends ListProps, ListActions {
|
export interface PluginListProps extends ListProps, ListActionsWithoutToolbar {
|
||||||
plugins: PageList_pages_edges_node[];
|
plugins: PluginConfigurations_pluginConfigurations_edges_node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = (theme: Theme) =>
|
const styles = (theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
[theme.breakpoints.up("lg")]: {
|
[theme.breakpoints.up("lg")]: {
|
||||||
colActive: {},
|
|
||||||
colName: {},
|
|
||||||
colAction: {
|
colAction: {
|
||||||
textAlign: "right",
|
|
||||||
"& svg": {
|
"& svg": {
|
||||||
color: theme.palette.primary.main
|
color: theme.palette.primary.main
|
||||||
}
|
},
|
||||||
}
|
textAlign: "right"
|
||||||
|
},
|
||||||
|
colActive: {},
|
||||||
|
colName: {}
|
||||||
},
|
},
|
||||||
colName: {},
|
|
||||||
colActive: {},
|
|
||||||
colAction: {},
|
colAction: {},
|
||||||
|
colActive: {},
|
||||||
|
colName: {},
|
||||||
link: {
|
link: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,7 @@ const PluginList = withStyles(styles, { name: "PluginList" })(
|
||||||
isChecked,
|
isChecked,
|
||||||
selected,
|
selected,
|
||||||
toggle,
|
toggle,
|
||||||
toggleAll,
|
toggleAll
|
||||||
toolbar
|
|
||||||
}: PluginListProps & WithStyles<typeof styles>) => {
|
}: PluginListProps & WithStyles<typeof styles>) => {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
@ -75,7 +74,6 @@ const PluginList = withStyles(styles, { name: "PluginList" })(
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
items={plugins}
|
items={plugins}
|
||||||
toggleAll={toggleAll}
|
toggleAll={toggleAll}
|
||||||
toolbar={toolbar}
|
|
||||||
>
|
>
|
||||||
<TableCell className={classes.colName} padding="dense">
|
<TableCell className={classes.colName} padding="dense">
|
||||||
{i18n.t("Name", { context: "table header" })}
|
{i18n.t("Name", { context: "table header" })}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import Button from "@material-ui/core/Button";
|
|
||||||
import AddIcon from "@material-ui/icons/Add";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
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 { ListActions, PageListProps } from "@saleor/types";
|
import { ListActionsWithoutToolbar, PageListProps } from "@saleor/types";
|
||||||
import { PageList_pages_edges_node } from "../../types/PageList";
|
import { PluginConfigurations_pluginConfigurations_edges_node } from "../../types/PluginConfigurations";
|
||||||
import PluginsList from "../PluginsList/PluginsList";
|
import PluginsList from "../PluginsList/PluginsList";
|
||||||
|
|
||||||
export interface PluginsListPageProps extends PageListProps, ListActions {
|
export interface PluginsListPageProps
|
||||||
pages: PageList_pages_edges_node[];
|
extends PageListProps,
|
||||||
|
ListActionsWithoutToolbar {
|
||||||
|
plugins: PluginConfigurations_pluginConfigurations_edges_node[];
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,7 @@ const PluginsListPage: React.StatelessComponent<PluginsListPageProps> = ({
|
||||||
isChecked,
|
isChecked,
|
||||||
selected,
|
selected,
|
||||||
toggle,
|
toggle,
|
||||||
toggleAll,
|
toggleAll
|
||||||
toolbar
|
|
||||||
}) => (
|
}) => (
|
||||||
<Container>
|
<Container>
|
||||||
<AppHeader onBack={onBack}>{i18n.t("Configuration")}</AppHeader>
|
<AppHeader onBack={onBack}>{i18n.t("Configuration")}</AppHeader>
|
||||||
|
@ -47,7 +46,6 @@ const PluginsListPage: React.StatelessComponent<PluginsListPageProps> = ({
|
||||||
selected={selected}
|
selected={selected}
|
||||||
toggle={toggle}
|
toggle={toggle}
|
||||||
toggleAll={toggleAll}
|
toggleAll={toggleAll}
|
||||||
toolbar={toolbar}
|
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,9 +5,9 @@ import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
||||||
import { WindowTitle } from "../components/WindowTitle";
|
import { WindowTitle } from "../components/WindowTitle";
|
||||||
import i18n from "../i18n";
|
import i18n from "../i18n";
|
||||||
import {
|
import {
|
||||||
pluginsPath,
|
|
||||||
pluginsListPath,
|
pluginsListPath,
|
||||||
PluginsListUrlQueryParams
|
PluginsListUrlQueryParams,
|
||||||
|
pluginsPath
|
||||||
} from "./urls";
|
} from "./urls";
|
||||||
import PluginsDetailsComponent from "./views/PluginsDetails";
|
import PluginsDetailsComponent from "./views/PluginsDetails";
|
||||||
import PluginsListComponent from "./views/PluginsList";
|
import PluginsListComponent from "./views/PluginsList";
|
||||||
|
|
|
@ -3,13 +3,13 @@ import gql from "graphql-tag";
|
||||||
import { TypedMutation } from "../mutations";
|
import { TypedMutation } from "../mutations";
|
||||||
import { pluginsDetailsFragment } from "./queries";
|
import { pluginsDetailsFragment } from "./queries";
|
||||||
import {
|
import {
|
||||||
pluginConfigurationUpdate,
|
PluginConfigurationUpdate,
|
||||||
pluginConfigurationUpdateVariables
|
PluginConfigurationUpdateVariables
|
||||||
} from "./types/pluginConfigurationUpdate";
|
} from "./types/pluginConfigurationUpdate";
|
||||||
|
|
||||||
const pluginConfigurationUpdate = gql`
|
const pluginConfigurationUpdate = gql`
|
||||||
${pluginsDetailsFragment}
|
${pluginsDetailsFragment}
|
||||||
mutation pluginConfigurationUpdate(
|
mutation PluginConfigurationUpdate(
|
||||||
$id: ID!
|
$id: ID!
|
||||||
$input: PluginConfigurationUpdateInput!
|
$input: PluginConfigurationUpdateInput!
|
||||||
) {
|
) {
|
||||||
|
@ -25,6 +25,6 @@ const pluginConfigurationUpdate = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export const TypedPluginConfigurationUpdate = TypedMutation<
|
export const TypedPluginConfigurationUpdate = TypedMutation<
|
||||||
pluginConfigurationUpdate,
|
PluginConfigurationUpdate,
|
||||||
pluginConfigurationUpdateVariables
|
PluginConfigurationUpdateVariables
|
||||||
>(pluginConfigurationUpdate);
|
>(pluginConfigurationUpdate);
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
|
|
||||||
import { TypedQuery } from "../queries";
|
import { TypedQuery } from "../queries";
|
||||||
import { PluginDetails, PluginDetailsVariables } from "./types/PluginDetails";
|
import {
|
||||||
import { PluginsList, PluginsListVariables } from "./types/PluginsList";
|
PluginConfiguration,
|
||||||
|
PluginConfigurationVariables
|
||||||
|
} from "./types/pluginConfiguration";
|
||||||
|
import {
|
||||||
|
PluginConfigurations,
|
||||||
|
PluginConfigurationsVariables
|
||||||
|
} from "./types/pluginConfigurations";
|
||||||
|
|
||||||
export const pluginsFragment = gql`
|
export const pluginsFragment = gql`
|
||||||
fragment pluginFragment on PluginConfiguration {
|
fragment pluginFragment on PluginConfiguration {
|
||||||
|
@ -29,7 +35,7 @@ export const pluginsDetailsFragment = gql`
|
||||||
|
|
||||||
const pluginsList = gql`
|
const pluginsList = gql`
|
||||||
${pluginsFragment}
|
${pluginsFragment}
|
||||||
query pluginConfigurations(
|
query PluginConfigurations(
|
||||||
$first: Int
|
$first: Int
|
||||||
$after: String
|
$after: String
|
||||||
$last: Int
|
$last: Int
|
||||||
|
@ -46,23 +52,29 @@ const pluginsList = gql`
|
||||||
...pluginFragment
|
...pluginFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pageInfo {
|
||||||
|
hasPreviousPage
|
||||||
|
hasNextPage
|
||||||
|
startCursor
|
||||||
|
endCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export const TypedPluginsListQuery = TypedQuery<
|
export const TypedPluginsListQuery = TypedQuery<
|
||||||
PluginsList,
|
PluginConfigurations,
|
||||||
PluginsListVariables
|
PluginConfigurationsVariables
|
||||||
>(pluginsList);
|
>(pluginsList);
|
||||||
|
|
||||||
const pluginsDetails = gql`
|
const pluginsDetails = gql`
|
||||||
${pluginsDetailsFragment}
|
${pluginsDetailsFragment}
|
||||||
query pluginConfiguration($id: ID!) {
|
query PluginConfiguration($id: ID!) {
|
||||||
pluginConfiguration(id: $id) {
|
pluginConfiguration(id: $id) {
|
||||||
...pluginsDetailsFragment
|
...pluginsDetailsFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export const TypedPluginsDetailsQuery = TypedQuery<
|
export const TypedPluginsDetailsQuery = TypedQuery<
|
||||||
PluginDetails,
|
PluginConfiguration,
|
||||||
PluginDetailsVariables
|
PluginConfigurationVariables
|
||||||
>(pluginsDetails);
|
>(pluginsDetails);
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
import { ConfigurationTypeFieldEnum } from "./../../types/globalTypes";
|
import { ConfigurationTypeFieldEnum } from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: pluginConfiguration
|
// GraphQL query operation: PluginConfiguration
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface pluginConfiguration_pluginConfiguration_configuration {
|
export interface PluginConfiguration_pluginConfiguration_configuration {
|
||||||
__typename: "ConfigurationItem";
|
__typename: "ConfigurationItem";
|
||||||
name: string;
|
name: string;
|
||||||
type: ConfigurationTypeFieldEnum | null;
|
type: ConfigurationTypeFieldEnum | null;
|
||||||
|
@ -17,19 +17,19 @@ export interface pluginConfiguration_pluginConfiguration_configuration {
|
||||||
label: string | null;
|
label: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfiguration_pluginConfiguration {
|
export interface PluginConfiguration_pluginConfiguration {
|
||||||
__typename: "PluginConfiguration";
|
__typename: "PluginConfiguration";
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
configuration: (pluginConfiguration_pluginConfiguration_configuration | null)[] | null;
|
configuration: (PluginConfiguration_pluginConfiguration_configuration | null)[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfiguration {
|
export interface PluginConfiguration {
|
||||||
pluginConfiguration: pluginConfiguration_pluginConfiguration | null;
|
pluginConfiguration: PluginConfiguration_pluginConfiguration | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationVariables {
|
export interface PluginConfigurationVariables {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
import { PluginConfigurationUpdateInput, ConfigurationTypeFieldEnum } from "./../../types/globalTypes";
|
import { PluginConfigurationUpdateInput, ConfigurationTypeFieldEnum } from "./../../types/globalTypes";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL mutation operation: pluginConfigurationUpdate
|
// GraphQL mutation operation: PluginConfigurationUpdate
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface pluginConfigurationUpdate_pluginConfigurationUpdate_errors {
|
export interface PluginConfigurationUpdate_pluginConfigurationUpdate_errors {
|
||||||
__typename: "Error";
|
__typename: "Error";
|
||||||
field: string | null;
|
field: string | null;
|
||||||
message: string | null;
|
message: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration_configuration {
|
export interface PluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration_configuration {
|
||||||
__typename: "ConfigurationItem";
|
__typename: "ConfigurationItem";
|
||||||
name: string;
|
name: string;
|
||||||
type: ConfigurationTypeFieldEnum | null;
|
type: ConfigurationTypeFieldEnum | null;
|
||||||
|
@ -23,26 +23,26 @@ export interface pluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfi
|
||||||
label: string | null;
|
label: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration {
|
export interface PluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration {
|
||||||
__typename: "PluginConfiguration";
|
__typename: "PluginConfiguration";
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
configuration: (pluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration_configuration | null)[] | null;
|
configuration: (PluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration_configuration | null)[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationUpdate_pluginConfigurationUpdate {
|
export interface PluginConfigurationUpdate_pluginConfigurationUpdate {
|
||||||
__typename: "PluginConfigurationUpdate";
|
__typename: "PluginConfigurationUpdate";
|
||||||
errors: pluginConfigurationUpdate_pluginConfigurationUpdate_errors[] | null;
|
errors: PluginConfigurationUpdate_pluginConfigurationUpdate_errors[] | null;
|
||||||
pluginConfiguration: pluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration | null;
|
pluginConfiguration: PluginConfigurationUpdate_pluginConfigurationUpdate_pluginConfiguration | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationUpdate {
|
export interface PluginConfigurationUpdate {
|
||||||
pluginConfigurationUpdate: pluginConfigurationUpdate_pluginConfigurationUpdate | null;
|
pluginConfigurationUpdate: PluginConfigurationUpdate_pluginConfigurationUpdate | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationUpdateVariables {
|
export interface PluginConfigurationUpdateVariables {
|
||||||
id: string;
|
id: string;
|
||||||
input: PluginConfigurationUpdateInput;
|
input: PluginConfigurationUpdateInput;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: pluginConfigurations
|
// GraphQL query operation: PluginConfigurations
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface pluginConfigurations_pluginConfigurations_edges_node {
|
export interface PluginConfigurations_pluginConfigurations_edges_node {
|
||||||
__typename: "PluginConfiguration";
|
__typename: "PluginConfiguration";
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -14,21 +14,30 @@ export interface pluginConfigurations_pluginConfigurations_edges_node {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurations_pluginConfigurations_edges {
|
export interface PluginConfigurations_pluginConfigurations_edges {
|
||||||
__typename: "PluginConfigurationCountableEdge";
|
__typename: "PluginConfigurationCountableEdge";
|
||||||
node: pluginConfigurations_pluginConfigurations_edges_node;
|
node: PluginConfigurations_pluginConfigurations_edges_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurations_pluginConfigurations {
|
export interface PluginConfigurations_pluginConfigurations_pageInfo {
|
||||||
|
__typename: "PageInfo";
|
||||||
|
hasPreviousPage: boolean;
|
||||||
|
hasNextPage: boolean;
|
||||||
|
startCursor: string | null;
|
||||||
|
endCursor: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PluginConfigurations_pluginConfigurations {
|
||||||
__typename: "PluginConfigurationCountableConnection";
|
__typename: "PluginConfigurationCountableConnection";
|
||||||
edges: pluginConfigurations_pluginConfigurations_edges[];
|
edges: PluginConfigurations_pluginConfigurations_edges[];
|
||||||
|
pageInfo: PluginConfigurations_pluginConfigurations_pageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurations {
|
export interface PluginConfigurations {
|
||||||
pluginConfigurations: pluginConfigurations_pluginConfigurations | null;
|
pluginConfigurations: PluginConfigurations_pluginConfigurations | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface pluginConfigurationsVariables {
|
export interface PluginConfigurationsVariables {
|
||||||
first?: number | null;
|
first?: number | null;
|
||||||
after?: string | null;
|
after?: string | null;
|
||||||
last?: number | null;
|
last?: number | null;
|
||||||
|
|
|
@ -1,29 +1,22 @@
|
||||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
|
||||||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
import useNavigator from "@saleor/hooks/useNavigator";
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
import useNotifier from "@saleor/hooks/useNotifier";
|
|
||||||
import i18n from "../../i18n";
|
|
||||||
import { getMutationState, maybe } from "../../misc";
|
import { getMutationState, maybe } from "../../misc";
|
||||||
import { PluginConfigurationUpdateInput } from "../../types/globalTypes";
|
import PluginsDetailsPage from "../components/PluginsDetailsPage";
|
||||||
import PluginsDetailsPage, { FormData } from "../components/PluginsDetailsPage";
|
|
||||||
import { TypedPluginConfigurationUpdate } from "../mutations";
|
import { TypedPluginConfigurationUpdate } from "../mutations";
|
||||||
import { TypedPluginsDetailsQuery } from "../queries";
|
import { TypedPluginsDetailsQuery } from "../queries";
|
||||||
import { pluginsListUrl, pluginsUrl, PluginsUrlQueryParams } from "../urls";
|
import { pluginsListUrl, PluginsListUrlQueryParams } from "../urls";
|
||||||
|
|
||||||
export interface PluginsDetailsProps {
|
export interface PluginsDetailsProps {
|
||||||
id: string;
|
id: string;
|
||||||
params: PluginsUrlQueryParams;
|
params: PluginsListUrlQueryParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
||||||
id,
|
id
|
||||||
params
|
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigator();
|
const navigate = useNavigator();
|
||||||
const notify = useNotifier();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TypedPluginConfigurationUpdate>
|
<TypedPluginConfigurationUpdate>
|
||||||
|
@ -35,7 +28,8 @@ export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
||||||
pluginConfigurationUpdateOpts.loading,
|
pluginConfigurationUpdateOpts.loading,
|
||||||
maybe(
|
maybe(
|
||||||
() =>
|
() =>
|
||||||
pluginConfigurationUpdateOpts.data.pluginConfiguration.errors
|
pluginConfigurationUpdateOpts.data.pluginConfigurationUpdate
|
||||||
|
.errors
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -50,8 +44,8 @@ export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
||||||
disabled={PluginDetails.loading}
|
disabled={PluginDetails.loading}
|
||||||
errors={maybe(
|
errors={maybe(
|
||||||
() =>
|
() =>
|
||||||
pluginConfigurationUpdateOpts.data.pluginConfiguration
|
pluginConfigurationUpdateOpts.data
|
||||||
.errors,
|
.pluginConfigurationUpdate.errors,
|
||||||
[]
|
[]
|
||||||
)}
|
)}
|
||||||
saveButtonBarState={formTransitionState}
|
saveButtonBarState={formTransitionState}
|
||||||
|
@ -62,7 +56,7 @@ export const PluginsDetails: React.StatelessComponent<PluginsDetailsProps> = ({
|
||||||
formData.configuration.map(item => {
|
formData.configuration.map(item => {
|
||||||
configurationInput.push({
|
configurationInput.push({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
value: item.value
|
value: item.value.toString()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
pluginConfigurationUpdate({
|
pluginConfigurationUpdate({
|
||||||
|
|
|
@ -1,29 +1,16 @@
|
||||||
import Button from "@material-ui/core/Button";
|
|
||||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
|
||||||
import IconButton from "@material-ui/core/IconButton";
|
|
||||||
import DeleteIcon from "@material-ui/icons/Delete";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
|
||||||
import { configurationMenuUrl } from "@saleor/configuration";
|
import { configurationMenuUrl } from "@saleor/configuration";
|
||||||
import useBulkActions from "@saleor/hooks/useBulkActions";
|
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 useNotifier from "@saleor/hooks/useNotifier";
|
|
||||||
import usePaginator, {
|
import usePaginator, {
|
||||||
createPaginationState
|
createPaginationState
|
||||||
} from "@saleor/hooks/usePaginator";
|
} from "@saleor/hooks/usePaginator";
|
||||||
import i18n from "@saleor/i18n";
|
import { maybe } from "@saleor/misc";
|
||||||
import { getMutationState, maybe } from "@saleor/misc";
|
|
||||||
import { ListViews } from "@saleor/types";
|
import { ListViews } from "@saleor/types";
|
||||||
|
import React from "react";
|
||||||
import PluginsListPage from "../components/PluginsListPage/PluginsListPage";
|
import PluginsListPage from "../components/PluginsListPage/PluginsListPage";
|
||||||
import { TypedPluginsListQuery } from "../queries";
|
import { TypedPluginsListQuery } from "../queries";
|
||||||
import {
|
import { PluginsListUrlQueryParams, pluginsUrl } from "../urls";
|
||||||
pluginsListUrl,
|
|
||||||
PluginsListUrlDialog,
|
|
||||||
PluginsListUrlQueryParams,
|
|
||||||
pluginsUrl
|
|
||||||
} from "../urls";
|
|
||||||
|
|
||||||
interface PluginsListProps {
|
interface PluginsListProps {
|
||||||
params: PluginsListUrlQueryParams;
|
params: PluginsListUrlQueryParams;
|
||||||
|
@ -33,25 +20,23 @@ export const PluginsList: React.StatelessComponent<PluginsListProps> = ({
|
||||||
params
|
params
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigator();
|
const navigate = useNavigator();
|
||||||
const notify = useNotifier();
|
|
||||||
const paginate = usePaginator();
|
const paginate = usePaginator();
|
||||||
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
|
const { isSelected, listElements, toggle, toggleAll } = useBulkActions(
|
||||||
params.ids
|
params.ids
|
||||||
);
|
);
|
||||||
const { updateListSettings, settings } = useListSettings(
|
const { updateListSettings, settings } = useListSettings(
|
||||||
ListViews.PAGES_LIST
|
ListViews.PLUGINS_LIST
|
||||||
);
|
);
|
||||||
const paginationState = createPaginationState(settings.rowNumber, params);
|
const paginationState = createPaginationState(settings.rowNumber, params);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TypedPluginsListQuery displayLoader variables={paginationState}>
|
<TypedPluginsListQuery displayLoader variables={paginationState}>
|
||||||
{({ data, loading, refetch }) => {
|
{({ data, loading }) => {
|
||||||
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
|
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
|
||||||
maybe(() => data.pages.pageInfo),
|
maybe(() => data.pluginConfigurations.pageInfo),
|
||||||
paginationState,
|
paginationState,
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PluginsListPage
|
<PluginsListPage
|
||||||
|
@ -61,6 +46,7 @@ export const PluginsList: React.StatelessComponent<PluginsListProps> = ({
|
||||||
data.pluginConfigurations.edges.map(edge => edge.node)
|
data.pluginConfigurations.edges.map(edge => edge.node)
|
||||||
)}
|
)}
|
||||||
pageInfo={pageInfo}
|
pageInfo={pageInfo}
|
||||||
|
onAdd={() => navigate(configurationMenuUrl)}
|
||||||
onBack={() => navigate(configurationMenuUrl)}
|
onBack={() => navigate(configurationMenuUrl)}
|
||||||
onNextPage={loadNextPage}
|
onNextPage={loadNextPage}
|
||||||
onPreviousPage={loadPreviousPage}
|
onPreviousPage={loadPreviousPage}
|
||||||
|
|
|
@ -23,6 +23,7 @@ export enum ListViews {
|
||||||
NAVIGATION_LIST = "NAVIGATION_LIST",
|
NAVIGATION_LIST = "NAVIGATION_LIST",
|
||||||
ORDER_LIST = "ORDER_LIST",
|
ORDER_LIST = "ORDER_LIST",
|
||||||
PAGES_LIST = "PAGES_LIST",
|
PAGES_LIST = "PAGES_LIST",
|
||||||
|
PLUGINS_LIST = "PLUGIN_LIST",
|
||||||
PRODUCT_LIST = "PRODUCT_LIST",
|
PRODUCT_LIST = "PRODUCT_LIST",
|
||||||
SALES_LIST = "SALES_LIST",
|
SALES_LIST = "SALES_LIST",
|
||||||
SHIPPING_METHODS_LIST = "SHIPPING_METHODS_LIST",
|
SHIPPING_METHODS_LIST = "SHIPPING_METHODS_LIST",
|
||||||
|
|
Loading…
Reference in a new issue