-
Notifications
You must be signed in to change notification settings - Fork 590
/
index.js
94 lines (90 loc) · 2.77 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// @flow
import React from "react";
import styled from "@emotion/styled";
import { Tab } from "@webiny/ui/Tabs";
import { Route } from "react-router-dom";
import Helmet from "react-helmet";
import { AdminLayout } from "@webiny/app-admin/components/AdminLayout";
import MailchimpSettings from "./components/MailchimpSettings";
import MailchimpElementAdvancedSettings from "./components/MailchimpElementAdvancedSettings";
import MailchimpElement from "./components/MailchimpElement";
import { hasRoles } from "@webiny/app-security";
import { SecureRoute } from "@webiny/app-security/components";
import { ReactComponent as MailchimpLogo } from "./mailchimp-logo.svg";
import render from "./../render";
const PreviewBox = styled("div")({
textAlign: "center",
height: 80,
svg: {
height: 80,
width: "auto"
}
});
const roles = ["pb-settings"];
export default [
...render,
{
name: "pb-page-element-mailchimp",
type: "pb-page-element",
elementType: "mailchimp",
toolbar: {
title: "Mailchimp",
group: "pb-editor-element-group-form",
preview() {
return (
<PreviewBox>
<MailchimpLogo />
</PreviewBox>
);
}
},
settings: ["pb-page-element-settings-delete", "", "pb-page-element-settings-height"],
target: ["column", "row", "list-item"],
onCreate: "open-settings",
render({ element }: Object) {
return <MailchimpElement element={element} />;
},
create() {
return {
type: "mailchimp",
elements: [],
data: {},
settings: {}
};
}
},
{
name: "pb-element-advanced-settings-mailchimp",
type: "pb-page-element-advanced-settings",
elementType: "mailchimp",
render(props: Object) {
return (
<Tab label="Mailchimp">
<MailchimpElementAdvancedSettings {...props} />
</Tab>
);
}
},
{
type: "settings",
name: "settings-mailchimp",
settings: {
show: () => hasRoles(roles),
type: "integration",
name: "Mailchimp",
route: (
<Route
path="/mailchimp"
render={() => (
<AdminLayout>
<Helmet title={"Mailchimp"} />
<SecureRoute roles={roles}>
<MailchimpSettings />
</SecureRoute>
</AdminLayout>
)}
/>
)
}
}
];