Update components
This commit is contained in:
parent
6b66893745
commit
2fd01ec3c5
17 changed files with 591 additions and 122 deletions
|
@ -48,8 +48,8 @@ import SiteSettingsSection from "./siteSettings";
|
||||||
import StaffSection from "./staff";
|
import StaffSection from "./staff";
|
||||||
import TaxesSection from "./taxes";
|
import TaxesSection from "./taxes";
|
||||||
import TranslationsSection from "./translations";
|
import TranslationsSection from "./translations";
|
||||||
import WebhooksSection from "./webhooks";
|
|
||||||
import { PermissionEnum } from "./types/globalTypes";
|
import { PermissionEnum } from "./types/globalTypes";
|
||||||
|
import WebhooksSection from "./webhooks";
|
||||||
|
|
||||||
interface ResponseError extends ErrorResponse {
|
interface ResponseError extends ErrorResponse {
|
||||||
networkError?: Error & {
|
networkError?: Error & {
|
||||||
|
|
116
src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx
Normal file
116
src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
|
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
||||||
|
import Container from "@saleor/components/Container";
|
||||||
|
import Form from "@saleor/components/Form";
|
||||||
|
import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
|
import Grid from "@saleor/components/Grid";
|
||||||
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
|
import SaveButtonBar from "@saleor/components/SaveButtonBar";
|
||||||
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
import { maybe } from "@saleor/misc";
|
||||||
|
import { UserError } from "@saleor/types";
|
||||||
|
import React from "react";
|
||||||
|
import { useIntl } from "react-intl";
|
||||||
|
import { ServiceList_serviceAccounts_edges_node } from "../../types/ServiceList";
|
||||||
|
import { Webhook_webhook, Webhook_webhook_events } from "../../types/Webhook";
|
||||||
|
import WebhookEvents from "../WebhookEvents";
|
||||||
|
import WebhookInfo from "../WebhookInfo";
|
||||||
|
import WebhookStatus from "../WebhookStatus";
|
||||||
|
|
||||||
|
export interface FormData {
|
||||||
|
id: string;
|
||||||
|
events: Webhook_webhook_events[];
|
||||||
|
isActive: boolean;
|
||||||
|
name: string;
|
||||||
|
secretKey: string | null;
|
||||||
|
targetUrl: string;
|
||||||
|
serviceAccount: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebhookCreatePageProps {
|
||||||
|
disabled: boolean;
|
||||||
|
errors: UserError[];
|
||||||
|
webhook: Webhook_webhook;
|
||||||
|
services: ServiceList_serviceAccounts_edges_node[];
|
||||||
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
|
onBack: () => void;
|
||||||
|
onSubmit: (data: FormData) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const WebhookCreatePage: React.StatelessComponent<WebhookCreatePageProps> = ({
|
||||||
|
disabled,
|
||||||
|
errors,
|
||||||
|
webhook,
|
||||||
|
saveButtonBarState,
|
||||||
|
services,
|
||||||
|
onBack,
|
||||||
|
onSubmit
|
||||||
|
}) => {
|
||||||
|
const intl = useIntl();
|
||||||
|
const initialForm: FormData = {
|
||||||
|
events: maybe(() => webhook.events, []),
|
||||||
|
id: maybe(() => webhook.id, null),
|
||||||
|
isActive: maybe(() => webhook.isActive, false),
|
||||||
|
name: maybe(() => webhook.name, null),
|
||||||
|
secretKey: maybe(() => webhook.secretKey, ""),
|
||||||
|
serviceAccount: maybe(() => webhook.serviceAccount, ""),
|
||||||
|
targetUrl: maybe(() => webhook.targetUrl, "")
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
||||||
|
{({ data, errors, hasChanged, submit, change }) => {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<AppHeader onBack={onBack}>
|
||||||
|
{intl.formatMessage(sectionNames.plugins)}
|
||||||
|
</AppHeader>
|
||||||
|
<PageHeader
|
||||||
|
title={intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage: "Create Webhook",
|
||||||
|
description: "header"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pluginName: maybe(() => webhook.name, "...")
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Grid>
|
||||||
|
<div>
|
||||||
|
<WebhookInfo
|
||||||
|
data={data}
|
||||||
|
disabled={disabled}
|
||||||
|
services={maybe(() => services, [])}
|
||||||
|
errors={errors}
|
||||||
|
onChange={change}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<WebhookEvents
|
||||||
|
data={data}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={change}
|
||||||
|
/>
|
||||||
|
<FormSpacer />
|
||||||
|
<WebhookStatus
|
||||||
|
data={data}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={change}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Grid>
|
||||||
|
<SaveButtonBar
|
||||||
|
disabled={disabled || !hasChanged}
|
||||||
|
state={saveButtonBarState}
|
||||||
|
onCancel={onBack}
|
||||||
|
onSave={submit}
|
||||||
|
/>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
WebhookCreatePage.displayName = "WebhookCreatePage";
|
||||||
|
export default WebhookCreatePage;
|
2
src/webhooks/components/WebhookCreatePage/index.ts
Normal file
2
src/webhooks/components/WebhookCreatePage/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export { default } from "./WebhookCreatePage";
|
||||||
|
export * from "./WebhookCreatePage";
|
|
@ -1,28 +1,18 @@
|
||||||
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 TextField from "@material-ui/core/TextField";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import makeStyles from "@material-ui/styles/makeStyles";
|
import makeStyles from "@material-ui/styles/makeStyles";
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
||||||
import { FormErrors } from "@saleor/types";
|
|
||||||
import { ConfigurationTypeFieldEnum } from "@saleor/types/globalTypes";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
import { WebhookEventTypeEnum } from "../../../types/globalTypes";
|
||||||
import { FormData } from "../WebhookDetailsPage";
|
import { FormData } from "../WebhooksDetailsPage";
|
||||||
|
|
||||||
interface WebhookEventsProps {
|
interface WebhookEventsProps {
|
||||||
data: FormData;
|
data: FormData;
|
||||||
errors: FormErrors<"name" | "configuration">;
|
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
fields: Array<{
|
|
||||||
name: string;
|
|
||||||
type: ConfigurationTypeFieldEnum | null;
|
|
||||||
value: string;
|
|
||||||
helpText: string | null;
|
|
||||||
label: string | null;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
|
@ -35,12 +25,29 @@ const useStyles = makeStyles(() => ({
|
||||||
const WebhookEvents: React.StatelessComponent<WebhookEventsProps> = ({
|
const WebhookEvents: React.StatelessComponent<WebhookEventsProps> = ({
|
||||||
data,
|
data,
|
||||||
disabled,
|
disabled,
|
||||||
errors,
|
onChange
|
||||||
onChange,
|
|
||||||
fields
|
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles({});
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const [events, setEvents] = React.useState();
|
||||||
|
|
||||||
|
const eventsEnum = Object.values(WebhookEventTypeEnum);
|
||||||
|
|
||||||
|
const addOrRemove = (array, value) => {
|
||||||
|
const index = array.indexOf(value);
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
array.push(value);
|
||||||
|
} else {
|
||||||
|
array.splice(index, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const eventsOnChange = event => {
|
||||||
|
const newData = [events];
|
||||||
|
addOrRemove(newData, event.name);
|
||||||
|
setEvents(newData);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
|
@ -49,7 +56,26 @@ const WebhookEvents: React.StatelessComponent<WebhookEventsProps> = ({
|
||||||
description: "section header"
|
description: "section header"
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<CardContent></CardContent>
|
<CardContent>
|
||||||
|
<Typography>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"Expand or restrict webhooks permissions to register certain events in Saleor system.",
|
||||||
|
description: "webhook events"
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
{eventsEnum.map((event, index) => (
|
||||||
|
<div key={index}>
|
||||||
|
<ControlledCheckbox
|
||||||
|
name={event}
|
||||||
|
label={event}
|
||||||
|
checked={data.events[event]}
|
||||||
|
onChange={eventsOnChange}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
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 TextField from "@material-ui/core/TextField";
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import makeStyles from "@material-ui/styles/makeStyles";
|
import makeStyles from "@material-ui/styles/makeStyles";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
|
||||||
import FormSpacer from "@saleor/components/FormSpacer";
|
import FormSpacer from "@saleor/components/FormSpacer";
|
||||||
import Hr from "@saleor/components/Hr";
|
import Hr from "@saleor/components/Hr";
|
||||||
import { commonMessages } from "@saleor/intl";
|
import SingleSelectField from "@saleor/components/SingleSelectField";
|
||||||
|
import { FormErrors } from "@saleor/types";
|
||||||
import { FormData } from "../WebhooksDetailsPage";
|
import { FormData } from "../WebhooksDetailsPage";
|
||||||
|
|
||||||
|
import { ServiceList_serviceAccounts_edges_node } from "../../types/ServiceList";
|
||||||
|
|
||||||
interface WebhookInfoProps {
|
interface WebhookInfoProps {
|
||||||
data: FormData;
|
data: FormData;
|
||||||
description: string;
|
disabled: boolean;
|
||||||
name: string;
|
services: ServiceList_serviceAccounts_edges_node[];
|
||||||
|
errors: FormErrors<"name" | "targetUrl" | "secretKey">;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,28 +28,107 @@ const useStyles = makeStyles(() => ({
|
||||||
paddingTop: 20
|
paddingTop: 20
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
fontSize: 14,
|
fontSize: 16,
|
||||||
paddingTop: 10
|
lineHeight: 1.9,
|
||||||
|
paddingBottom: 10
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const WebhookInfo: React.StatelessComponent<WebhookInfoProps> = ({
|
const WebhookInfo: React.StatelessComponent<WebhookInfoProps> = ({
|
||||||
data,
|
data,
|
||||||
description,
|
disabled,
|
||||||
name,
|
services,
|
||||||
|
errors,
|
||||||
onChange
|
onChange
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles({});
|
const classes = useStyles({});
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
title={intl.formatMessage({
|
title={intl.formatMessage({
|
||||||
defaultMessage: "Plugin Information and Status",
|
defaultMessage: "Webhook Information",
|
||||||
description: "section header"
|
description: "section header"
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<CardContent></CardContent>
|
<CardContent>
|
||||||
|
<Typography className={classes.title}>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage: "General Information",
|
||||||
|
description: "webhook general information"
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
<TextField
|
||||||
|
disabled={disabled}
|
||||||
|
error={!!errors.name}
|
||||||
|
helperText={errors.name}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Webhook Name",
|
||||||
|
description: "webhook"
|
||||||
|
})}
|
||||||
|
fullWidth
|
||||||
|
name="name"
|
||||||
|
value={data.name}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
<FormSpacer />
|
||||||
|
<Hr />
|
||||||
|
<FormSpacer />
|
||||||
|
<Typography className={classes.title}>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage: "Webhook specific information",
|
||||||
|
description: "webhook specific information"
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
<SingleSelectField
|
||||||
|
choices={services.map(service => ({
|
||||||
|
label: service.name,
|
||||||
|
value: service.id
|
||||||
|
}))}
|
||||||
|
name="serviceAccount"
|
||||||
|
value={data.serviceAccount}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Assign to Service Account"
|
||||||
|
})}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
<FormSpacer />
|
||||||
|
<TextField
|
||||||
|
disabled={disabled}
|
||||||
|
error={!!errors.targetUrl}
|
||||||
|
helperText={intl.formatMessage({
|
||||||
|
defaultMessage: "This URL will recieve webhook POST requests",
|
||||||
|
description: "webhook target url help text"
|
||||||
|
})}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Target URL",
|
||||||
|
description: "webhook"
|
||||||
|
})}
|
||||||
|
fullWidth
|
||||||
|
name="targetUrl"
|
||||||
|
value={data.targetUrl}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
<FormSpacer />
|
||||||
|
<TextField
|
||||||
|
disabled={disabled}
|
||||||
|
error={!!errors.secretKey}
|
||||||
|
helperText={intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"secret key is used to create a hash signature with each payload. *optional field",
|
||||||
|
description: "webhook secret key help text"
|
||||||
|
})}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Secrect Key",
|
||||||
|
description: "webhook"
|
||||||
|
})}
|
||||||
|
fullWidth
|
||||||
|
name="secretKey"
|
||||||
|
value={data.secretKey}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
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 TextField from "@material-ui/core/TextField";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import makeStyles from "@material-ui/styles/makeStyles";
|
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
||||||
import { FormErrors } from "@saleor/types";
|
import { FormErrors } from "@saleor/types";
|
||||||
import { ConfigurationTypeFieldEnum } from "@saleor/types/globalTypes";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -13,33 +11,15 @@ import { FormData } from "../WebhooksDetailsPage";
|
||||||
|
|
||||||
interface WebhookStatusProps {
|
interface WebhookStatusProps {
|
||||||
data: FormData;
|
data: FormData;
|
||||||
errors: FormErrors<"name" | "configuration">;
|
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
fields: Array<{
|
|
||||||
name: string;
|
|
||||||
type: ConfigurationTypeFieldEnum | null;
|
|
||||||
value: string;
|
|
||||||
helpText: string | null;
|
|
||||||
label: string | null;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
|
||||||
item: {
|
|
||||||
paddingBottom: 10,
|
|
||||||
paddingTop: 10
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
const WebhookStatus: React.StatelessComponent<WebhookStatusProps> = ({
|
const WebhookStatus: React.StatelessComponent<WebhookStatusProps> = ({
|
||||||
data,
|
data,
|
||||||
disabled,
|
disabled,
|
||||||
errors,
|
onChange
|
||||||
onChange,
|
|
||||||
fields
|
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles({});
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
@ -49,7 +29,25 @@ const WebhookStatus: React.StatelessComponent<WebhookStatusProps> = ({
|
||||||
description: "section header"
|
description: "section header"
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<CardContent></CardContent>
|
<CardContent>
|
||||||
|
<Typography>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"If you want to disable this webhook please uncheck the box below.",
|
||||||
|
description: "webhook active"
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
<ControlledCheckbox
|
||||||
|
name={"isActive" as keyof FormData}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Webhook is active",
|
||||||
|
description: "webhooks active"
|
||||||
|
})}
|
||||||
|
checked={data.isActive}
|
||||||
|
onChange={onChange}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,40 +1,38 @@
|
||||||
import Typography from "@material-ui/core/Typography";
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
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 FormSpacer from "@saleor/components/FormSpacer";
|
||||||
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 { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { maybe } from "@saleor/misc";
|
import { maybe } from "@saleor/misc";
|
||||||
import { UserError } from "@saleor/types";
|
import { UserError } from "@saleor/types";
|
||||||
import { ConfigurationItemInput } from "@saleor/types/globalTypes";
|
import { WebhookEventTypeEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
import { ServiceList_serviceAccounts_edges_node } from "../../types/ServiceList";
|
||||||
import {
|
import { Webhook_webhook, Webhook_webhook_events } from "../../types/Webhook";
|
||||||
Webhook_webhook,
|
|
||||||
Webhook_webhook_events,
|
|
||||||
Webhook_webhook_serviceAccount
|
|
||||||
} from "../../types/Webhook";
|
|
||||||
import WebhookEvents from "../WebhookEvents";
|
import WebhookEvents from "../WebhookEvents";
|
||||||
import WebhookInfo from "../WebhookInfo";
|
import WebhookInfo from "../WebhookInfo";
|
||||||
import WebhookStatus from "../WebhookStatus";
|
import WebhookStatus from "../WebhookStatus";
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
id: string;
|
id: string;
|
||||||
events: Webhook_webhook_events;
|
events: Webhook_webhook_events[];
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
name: string;
|
||||||
secretKey: string | null;
|
secretKey: string | null;
|
||||||
targetUrl: string;
|
targetUrl: string;
|
||||||
serviceAccount: Webhook_webhook_serviceAccount;
|
serviceAccount: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhooksDetailsPageProps {
|
export interface WebhooksDetailsPageProps {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: UserError[];
|
||||||
webhook: Webhook_webhook;
|
webhook: Webhook_webhook;
|
||||||
|
services: ServiceList_serviceAccounts_edges_node[];
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onSubmit: (data: FormData) => void;
|
onSubmit: (data: FormData) => void;
|
||||||
|
@ -42,17 +40,25 @@ export interface WebhooksDetailsPageProps {
|
||||||
|
|
||||||
const WebhooksDetailsPage: React.StatelessComponent<
|
const WebhooksDetailsPage: React.StatelessComponent<
|
||||||
WebhooksDetailsPageProps
|
WebhooksDetailsPageProps
|
||||||
> = ({ disabled, errors, webhook, saveButtonBarState, onBack, onSubmit }) => {
|
> = ({
|
||||||
|
disabled,
|
||||||
|
errors,
|
||||||
|
webhook,
|
||||||
|
saveButtonBarState,
|
||||||
|
services,
|
||||||
|
onBack,
|
||||||
|
onSubmit
|
||||||
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const initialForm: FormData = {
|
const initialForm: FormData = {
|
||||||
events: maybe(() => webhook.events, []),
|
events: maybe(() => webhook.events, []),
|
||||||
id: maybe(() => webhook.id, null),
|
id: maybe(() => webhook.id, null),
|
||||||
isActive: maybe(() => webhook.isActive, false),
|
isActive: maybe(() => webhook.isActive, false),
|
||||||
|
name: maybe(() => webhook.name, ""),
|
||||||
secretKey: maybe(() => webhook.secretKey, ""),
|
secretKey: maybe(() => webhook.secretKey, ""),
|
||||||
serviceAccount: maybe(() => webhook.serviceAccount, []),
|
serviceAccount: maybe(() => webhook.serviceAccount.id, ""),
|
||||||
targetUrl: maybe(() => webhook.targetUrl, "")
|
targetUrl: maybe(() => webhook.targetUrl, "")
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
|
||||||
{({ data, errors, hasChanged, submit, change }) => {
|
{({ data, errors, hasChanged, submit, change }) => {
|
||||||
|
@ -68,15 +74,16 @@ const WebhooksDetailsPage: React.StatelessComponent<
|
||||||
description: "header"
|
description: "header"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pluginName: maybe(() => plugin.name, "...")
|
pluginName: maybe(() => webhook.name, "...")
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Grid variant="inverted">
|
<Grid>
|
||||||
<div>
|
<div>
|
||||||
<WebhookInfo
|
<WebhookInfo
|
||||||
data={data}
|
data={data}
|
||||||
description={maybe(() => plugin.description, "")}
|
disabled={disabled}
|
||||||
|
services={maybe(() => services, [])}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
|
@ -84,14 +91,13 @@ const WebhooksDetailsPage: React.StatelessComponent<
|
||||||
<div>
|
<div>
|
||||||
<WebhookEvents
|
<WebhookEvents
|
||||||
data={data}
|
data={data}
|
||||||
errors={errors}
|
disabled={disabled}
|
||||||
name={maybe(() => plugin.name, "")}
|
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
|
<FormSpacer />
|
||||||
<WebhookStatus
|
<WebhookStatus
|
||||||
data={data}
|
data={data}
|
||||||
errors={errors}
|
disabled={disabled}
|
||||||
name={maybe(() => plugin.name, "")}
|
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,9 +16,7 @@ import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
import StatusLabel from "@saleor/components/StatusLabel";
|
|
||||||
import TablePagination from "@saleor/components/TablePagination";
|
import TablePagination from "@saleor/components/TablePagination";
|
||||||
import { translateBoolean } from "@saleor/intl";
|
|
||||||
import { maybe, renderCollection } from "@saleor/misc";
|
import { maybe, renderCollection } from "@saleor/misc";
|
||||||
import { ListProps } from "@saleor/types";
|
import { ListProps } from "@saleor/types";
|
||||||
import { Webhooks_webhooks_edges_node } from "../../types/Webhooks";
|
import { Webhooks_webhooks_edges_node } from "../../types/Webhooks";
|
||||||
|
@ -107,14 +105,36 @@ const WebhooksList = withStyles(styles, { name: "PluginList" })(
|
||||||
webhooks,
|
webhooks,
|
||||||
webhook => {
|
webhook => {
|
||||||
return (
|
return (
|
||||||
<div></div>
|
<TableRow
|
||||||
|
hover={!!webhook}
|
||||||
|
className={!!webhook ? classes.link : undefined}
|
||||||
|
onClick={webhook ? onRowClick(webhook.id) : undefined}
|
||||||
|
key={webhook ? webhook.id : "skeleton"}
|
||||||
|
>
|
||||||
|
<TableCell className={classes.colName}>
|
||||||
|
{maybe<React.ReactNode>(() => webhook.name, <Skeleton />)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.colActive}>
|
||||||
|
{maybe<React.ReactNode>(
|
||||||
|
() => webhook.serviceAccount.name,
|
||||||
|
<Skeleton />
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.colAction}>
|
||||||
|
<div
|
||||||
|
onClick={webhook ? onRowClick(webhook.id) : undefined}
|
||||||
|
>
|
||||||
|
<EditIcon />
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
() => (
|
() => (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={numberOfColumns}>
|
<TableCell colSpan={numberOfColumns}>
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
defaultMessage: "No plugins found"
|
defaultMessage: "No webhooks found"
|
||||||
})}
|
})}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
|
@ -17,6 +18,7 @@ export interface WebhooksListPageProps extends PageListProps {
|
||||||
const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
||||||
disabled,
|
disabled,
|
||||||
settings,
|
settings,
|
||||||
|
onAdd,
|
||||||
onBack,
|
onBack,
|
||||||
onNextPage,
|
onNextPage,
|
||||||
onPreviousPage,
|
onPreviousPage,
|
||||||
|
@ -31,7 +33,14 @@ const WebhooksListPage: React.StatelessComponent<WebhooksListPageProps> = ({
|
||||||
<AppHeader onBack={onBack}>
|
<AppHeader onBack={onBack}>
|
||||||
{intl.formatMessage(sectionNames.configuration)}
|
{intl.formatMessage(sectionNames.configuration)}
|
||||||
</AppHeader>
|
</AppHeader>
|
||||||
<PageHeader title={intl.formatMessage(sectionNames.webhooks)} />
|
<PageHeader title={intl.formatMessage(sectionNames.webhooks)}>
|
||||||
|
<Button onClick={onAdd} variant="contained" color="primary">
|
||||||
|
<FormattedMessage
|
||||||
|
defaultMessage="Create webhook"
|
||||||
|
description="button"
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
</PageHeader>
|
||||||
<WebhooksList
|
<WebhooksList
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
|
|
|
@ -6,10 +6,12 @@ import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { WindowTitle } from "../components/WindowTitle";
|
import { WindowTitle } from "../components/WindowTitle";
|
||||||
import {
|
import {
|
||||||
|
webhooksAddUrl,
|
||||||
webhooksListPath,
|
webhooksListPath,
|
||||||
WebhooksListUrlQueryParams,
|
WebhooksListUrlQueryParams,
|
||||||
webhooksPath
|
webhooksPath
|
||||||
} from "./urls";
|
} from "./urls";
|
||||||
|
import WebhookCreate from "./views/WebhooksCreate";
|
||||||
import WebhooksDetails from "./views/WebhooksDetails";
|
import WebhooksDetails from "./views/WebhooksDetails";
|
||||||
import WebhooksList from "./views/WebhooksList";
|
import WebhooksList from "./views/WebhooksList";
|
||||||
|
|
||||||
|
@ -21,17 +23,14 @@ const WebhookList: React.StatelessComponent<RouteComponentProps<any>> = ({
|
||||||
return <WebhooksList params={params} />;
|
return <WebhooksList params={params} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const PageDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
|
const WebhookDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
|
||||||
match
|
match
|
||||||
}) => {
|
}) => {
|
||||||
const qs = parseQs(location.search.substr(1));
|
const qs = parseQs(location.search.substr(1));
|
||||||
const params: WebhooksListUrlQueryParams = qs;
|
const params: WebhooksListUrlQueryParams = qs;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WebhooksDetails
|
<WebhooksDetails id={decodeURIComponent(match.params.id)} params={params} />
|
||||||
id={decodeURIComponent(match.params.id)}
|
|
||||||
params={params}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,7 +41,8 @@ const Component = () => {
|
||||||
<WindowTitle title={intl.formatMessage(sectionNames.plugins)} />
|
<WindowTitle title={intl.formatMessage(sectionNames.plugins)} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path={webhooksListPath} component={WebhookList} />
|
<Route exact path={webhooksListPath} component={WebhookList} />
|
||||||
<Route path={webhooksPath(":id")} component={WebhooksDetails} />
|
<Route exact path={webhooksAddUrl} component={WebhookCreate} />
|
||||||
|
<Route path={webhooksPath(":id")} component={WebhookDetails} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
|
|
||||||
import { TypedQuery } from "../queries";
|
import { TypedQuery } from "../queries";
|
||||||
|
import { ServiceList, ServiceListVariables } from "./types/ServiceList";
|
||||||
import { Webhook, WebhookVariables } from "./types/Webhook";
|
import { Webhook, WebhookVariables } from "./types/Webhook";
|
||||||
import { Webhooks, WebhooksVariables } from "./types/Webhooks";
|
import { Webhooks, WebhooksVariables } from "./types/Webhooks";
|
||||||
|
|
||||||
|
export const serviceFragment = gql`
|
||||||
|
fragment ServiceFragment on ServiceAccount {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
isActive
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const webhooksFragment = gql`
|
export const webhooksFragment = gql`
|
||||||
fragment WebhookFragment on Webhook {
|
fragment WebhookFragment on Webhook {
|
||||||
id
|
id
|
||||||
|
@ -50,6 +59,34 @@ export const TypedWebhooksListQuery = TypedQuery<Webhooks, WebhooksVariables>(
|
||||||
webhooksList
|
webhooksList
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const serviceList = gql`
|
||||||
|
${serviceFragment}
|
||||||
|
query ServiceList($first: Int, $after: String, $last: Int, $before: String) {
|
||||||
|
serviceAccounts(
|
||||||
|
first: $first
|
||||||
|
after: $after
|
||||||
|
before: $before
|
||||||
|
last: $last
|
||||||
|
) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
...ServiceFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageInfo {
|
||||||
|
hasPreviousPage
|
||||||
|
hasNextPage
|
||||||
|
startCursor
|
||||||
|
endCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
export const TypedServiceListQuery = TypedQuery<
|
||||||
|
ServiceList,
|
||||||
|
ServiceListVariables
|
||||||
|
>(serviceList);
|
||||||
|
|
||||||
const webhooksDetails = gql`
|
const webhooksDetails = gql`
|
||||||
${webhooksFragment}
|
${webhooksFragment}
|
||||||
query Webhook($id: ID!) {
|
query Webhook($id: ID!) {
|
||||||
|
|
14
src/webhooks/types/ServiceFragment.ts
Normal file
14
src/webhooks/types/ServiceFragment.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
// ====================================================
|
||||||
|
// GraphQL fragment: ServiceFragment
|
||||||
|
// ====================================================
|
||||||
|
|
||||||
|
export interface ServiceFragment {
|
||||||
|
__typename: "ServiceAccount";
|
||||||
|
id: string;
|
||||||
|
name: string | null;
|
||||||
|
isActive: boolean | null;
|
||||||
|
}
|
47
src/webhooks/types/ServiceList.ts
Normal file
47
src/webhooks/types/ServiceList.ts
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
import { ServiceAccountFilterInput } from "./../../types/globalTypes";
|
||||||
|
|
||||||
|
// ====================================================
|
||||||
|
// GraphQL query operation: ServiceList
|
||||||
|
// ====================================================
|
||||||
|
|
||||||
|
export interface ServiceList_serviceAccounts_edges_node {
|
||||||
|
__typename: "ServiceAccount";
|
||||||
|
id: string;
|
||||||
|
name: string | null;
|
||||||
|
isActive: boolean | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceList_serviceAccounts_edges {
|
||||||
|
__typename: "ServiceAccountCountableEdge";
|
||||||
|
node: ServiceList_serviceAccounts_edges_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceList_serviceAccounts_pageInfo {
|
||||||
|
__typename: "PageInfo";
|
||||||
|
hasPreviousPage: boolean;
|
||||||
|
hasNextPage: boolean;
|
||||||
|
startCursor: string | null;
|
||||||
|
endCursor: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceList_serviceAccounts {
|
||||||
|
__typename: "ServiceAccountCountableConnection";
|
||||||
|
edges: ServiceList_serviceAccounts_edges[];
|
||||||
|
pageInfo: ServiceList_serviceAccounts_pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceList {
|
||||||
|
serviceAccounts: ServiceList_serviceAccounts | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceListVariables {
|
||||||
|
first?: number | null;
|
||||||
|
after?: string | null;
|
||||||
|
last?: number | null;
|
||||||
|
before?: string | null;
|
||||||
|
filter?: ServiceAccountFilterInput | null;
|
||||||
|
}
|
|
@ -8,9 +8,12 @@ export const webhooksSection = "/webhooks/";
|
||||||
export const webhooksListPath = webhooksSection;
|
export const webhooksListPath = webhooksSection;
|
||||||
export type WebhooksListUrlQueryParams = Pagination & SingleAction;
|
export type WebhooksListUrlQueryParams = Pagination & SingleAction;
|
||||||
export const webhooksListUrl = (params?: WebhooksListUrlQueryParams) =>
|
export const webhooksListUrl = (params?: WebhooksListUrlQueryParams) =>
|
||||||
webhooksListPath + "?" + stringifyQs(params);
|
webhooksListPath + "?" + stringifyQs(params);
|
||||||
|
|
||||||
export const webhooksPath = (id: string) => urlJoin(webhooksSection, id);
|
export const webhooksPath = (id: string) => urlJoin(webhooksSection, id);
|
||||||
export type WebhooksUrlQueryParams = SingleAction;
|
export type WebhooksUrlQueryParams = SingleAction;
|
||||||
export const webhooksUrl = (id: string, params?: WebhooksUrlQueryParams) =>
|
export const webhooksUrl = (id: string, params?: WebhooksUrlQueryParams) =>
|
||||||
webhooksPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
webhooksPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
||||||
|
|
||||||
|
export const webhooksAddPath = urlJoin(webhooksSection, "add");
|
||||||
|
export const webhooksAddUrl = webhooksAddPath;
|
||||||
|
|
103
src/webhooks/views/WebhooksCreate.tsx
Normal file
103
src/webhooks/views/WebhooksCreate.tsx
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
|
import useNotifier from "@saleor/hooks/useNotifier";
|
||||||
|
import useShop from "@saleor/hooks/useShop";
|
||||||
|
import { commonMessages } from "@saleor/intl";
|
||||||
|
import { WebhookCreate as WebhookCreateData } from "@saleor/webhooks/types/WebhookCreate";
|
||||||
|
import React from "react";
|
||||||
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
import { getMutationState, maybe } from "../../misc";
|
||||||
|
import WebhookCreatePage, { FormData } from "../components/WebhookCreatePage";
|
||||||
|
import { TypedWebhookCreate } from "../mutations";
|
||||||
|
import { TypedServiceListQuery } from "../queries";
|
||||||
|
import {
|
||||||
|
webhooksListUrl,
|
||||||
|
WebhooksListUrlQueryParams,
|
||||||
|
webhooksUrl
|
||||||
|
} from "../urls";
|
||||||
|
|
||||||
|
export interface WebhooksCreateProps {
|
||||||
|
id: string;
|
||||||
|
params: WebhooksListUrlQueryParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WebhooksCreate: React.StatelessComponent<
|
||||||
|
WebhooksCreateProps
|
||||||
|
> = () => {
|
||||||
|
const navigate = useNavigator();
|
||||||
|
const notify = useNotifier();
|
||||||
|
const intl = useIntl();
|
||||||
|
const shop = useShop();
|
||||||
|
|
||||||
|
const onSubmit = (data: WebhookCreateData) => {
|
||||||
|
if (data.webhookCreate.errors.length === 0) {
|
||||||
|
notify({
|
||||||
|
text: intl.formatMessage(commonMessages.savedChanges)
|
||||||
|
});
|
||||||
|
navigate(webhooksUrl(data.webhookCreate.webhook.id));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBack = () => navigate(webhooksListUrl());
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TypedWebhookCreate onCompleted={onSubmit}>
|
||||||
|
{(WebhookCreate, webhookCreateOpts) => {
|
||||||
|
const handleSubmit = (data: FormData) =>
|
||||||
|
WebhookCreate({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
events: data.events,
|
||||||
|
isActive: data.isActive,
|
||||||
|
name: data.name,
|
||||||
|
secretKey: data.secretKey,
|
||||||
|
serviceAccount: data.serviceAccount,
|
||||||
|
targetUrl: data.targetUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const formTransitionState = getMutationState(
|
||||||
|
webhookCreateOpts.called,
|
||||||
|
webhookCreateOpts.loading,
|
||||||
|
maybe(() => webhookCreateOpts.data.webhookCreate.errors)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TypedServiceListQuery displayLoader variables={{ first: 99 }}>
|
||||||
|
{({ data, loading }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<WindowTitle
|
||||||
|
title={intl.formatMessage({
|
||||||
|
defaultMessage: "Create Webhook",
|
||||||
|
description: "window title"
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<WebhookCreatePage
|
||||||
|
disabled={false}
|
||||||
|
errors={maybe(
|
||||||
|
() => webhookCreateOpts.data.webhookCreate.errors,
|
||||||
|
[]
|
||||||
|
)}
|
||||||
|
services={maybe(() =>
|
||||||
|
data.serviceAccounts.edges.map(edge => edge.node)
|
||||||
|
)}
|
||||||
|
loading={loading}
|
||||||
|
onBack={handleBack}
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
permissions={maybe(() => shop.permissions)}
|
||||||
|
saveButtonBarState={formTransitionState}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</TypedServiceListQuery>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</TypedWebhookCreate>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
WebhooksCreate.displayName = "WebhooksCreate";
|
||||||
|
export default WebhooksCreate;
|
|
@ -7,7 +7,7 @@ import { useIntl } from "react-intl";
|
||||||
import { getMutationState, maybe } from "../../misc";
|
import { getMutationState, maybe } from "../../misc";
|
||||||
import WebhooksDetailsPage from "../components/WebhooksDetailsPage";
|
import WebhooksDetailsPage from "../components/WebhooksDetailsPage";
|
||||||
import { TypedWebhookUpdate } from "../mutations";
|
import { TypedWebhookUpdate } from "../mutations";
|
||||||
import { TypedWebhooksDetailsQuery } from "../queries";
|
import { TypedServiceListQuery, TypedWebhooksDetailsQuery } from "../queries";
|
||||||
import { webhooksListUrl, WebhooksListUrlQueryParams } from "../urls";
|
import { webhooksListUrl, WebhooksListUrlQueryParams } from "../urls";
|
||||||
|
|
||||||
export interface WebhooksDetailsProps {
|
export interface WebhooksDetailsProps {
|
||||||
|
@ -56,39 +56,40 @@ export const WebhooksDetails: React.StatelessComponent<
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<TypedServiceListQuery variables={{ first: 99 }}>
|
||||||
<WindowTitle
|
{({ data }) => (
|
||||||
title={maybe(() => WebhookDetails.data.webhook.name)}
|
<>
|
||||||
/>
|
<WindowTitle
|
||||||
<WebhooksDetailsPage
|
title={maybe(() => WebhookDetails.data.webhook.name)}
|
||||||
disabled={WebhookDetails.loading}
|
/>
|
||||||
errors={formErrors}
|
<WebhooksDetailsPage
|
||||||
saveButtonBarState={formTransitionState}
|
disabled={WebhookDetails.loading}
|
||||||
webhook={maybe(() => WebhookDetails.data.webook)}
|
errors={formErrors}
|
||||||
onBack={() => navigate(webhooksListUrl())}
|
saveButtonBarState={formTransitionState}
|
||||||
onSubmit={formData => {
|
webhook={maybe(() => WebhookDetails.data.webhook)}
|
||||||
const configurationInput =
|
services={maybe(() =>
|
||||||
formData.configuration &&
|
data.serviceAccounts.edges.map(edge => edge.node)
|
||||||
formData.configuration.map(item => {
|
)}
|
||||||
return {
|
onBack={() => navigate(webhooksListUrl())}
|
||||||
name: item.name,
|
onSubmit={data => {
|
||||||
value: item.value.toString()
|
webhookUpdate({
|
||||||
};
|
variables: {
|
||||||
});
|
id,
|
||||||
webhookUpdate({
|
input: {
|
||||||
variables: {
|
events: data.events,
|
||||||
id,
|
isActive: data.isActive,
|
||||||
input: {
|
name: data.name,
|
||||||
active: formData.active,
|
secretKey: data.secretKey,
|
||||||
configuration: configurationInput
|
serviceAccount: data.serviceAccount,
|
||||||
? configurationInput
|
targetUrl: data.targetUrl
|
||||||
: null
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</>
|
||||||
</>
|
)}
|
||||||
|
</TypedServiceListQuery>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</TypedWebhooksDetailsQuery>
|
</TypedWebhooksDetailsQuery>
|
||||||
|
|
|
@ -10,7 +10,11 @@ import React from "react";
|
||||||
|
|
||||||
import WebhooksListPage from "../components/WebhooksListPage/WebhooksListPage";
|
import WebhooksListPage from "../components/WebhooksListPage/WebhooksListPage";
|
||||||
import { TypedWebhooksListQuery } from "../queries";
|
import { TypedWebhooksListQuery } from "../queries";
|
||||||
import { WebhooksListUrlQueryParams, webhooksUrl } from "../urls";
|
import {
|
||||||
|
webhooksAddUrl,
|
||||||
|
WebhooksListUrlQueryParams,
|
||||||
|
webhooksUrl
|
||||||
|
} from "../urls";
|
||||||
|
|
||||||
interface WebhooksListProps {
|
interface WebhooksListProps {
|
||||||
params: WebhooksListUrlQueryParams;
|
params: WebhooksListUrlQueryParams;
|
||||||
|
@ -41,7 +45,7 @@ export const WebhooksList: React.StatelessComponent<WebhooksListProps> = ({
|
||||||
settings={settings}
|
settings={settings}
|
||||||
webhooks={maybe(() => data.webhooks.edges.map(edge => edge.node))}
|
webhooks={maybe(() => data.webhooks.edges.map(edge => edge.node))}
|
||||||
pageInfo={pageInfo}
|
pageInfo={pageInfo}
|
||||||
onAdd={() => navigate(configurationMenuUrl)}
|
onAdd={() => navigate(webhooksAddUrl)}
|
||||||
onBack={() => navigate(configurationMenuUrl)}
|
onBack={() => navigate(configurationMenuUrl)}
|
||||||
onNextPage={loadNextPage}
|
onNextPage={loadNextPage}
|
||||||
onPreviousPage={loadPreviousPage}
|
onPreviousPage={loadPreviousPage}
|
||||||
|
|
Loading…
Reference in a new issue