@webiny/app-file-manager 0.0.0-mt-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @webiny/file-manager
2
+ [![](https://img.shields.io/npm/dw/@webiny/app-file-manager.svg)](https://www.npmjs.com/package/@webiny/app-file-manager)
3
+ [![](https://img.shields.io/npm/v/@webiny/app-file-manager.svg)](https://www.npmjs.com/package/@webiny/app-file-manager)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ UI Components for File Manager configurations
8
+
9
+ ## Install
10
+ ```
11
+ npm install --save @webiny/app-file-manager
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+ ```
16
+ yarn add @webiny/app-file-manager
17
+ ```
18
+
19
+ ## Setup
20
+ To setup, you must register a set of plugins. For more information on
21
+ plugins, please visit [Webiny documentation](https://docs.webiny.com/docs/developer-tutorials/plugins-crash-course).
22
+
23
+ #### Admin
24
+ ```
25
+ import { plugins } from "@webiny/plugins";
26
+ import appFileManagerPlugin from "@webiny/app-file-manager/admin"
27
+
28
+ plugins.register(appFileManagerPlugin);
29
+ ```
30
+
31
+ Enables the file manager settings components which can be accessed via Settings
32
+ section in the main menu.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black" width="24px" height="24px"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M20 6h-8l-1.41-1.41C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-1 12H5c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1z"/></svg>
@@ -0,0 +1,5 @@
1
+ declare const graphql: {
2
+ GET_SETTINGS: import("graphql").DocumentNode;
3
+ UPDATE_SETTINGS: import("graphql").DocumentNode;
4
+ };
5
+ export default graphql;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2;
4
+
5
+ import gql from "graphql-tag";
6
+ var fields =
7
+ /* GraphQL */
8
+ "\n {\n data {\n uploadMinFileSize\n uploadMaxFileSize\n }\n }\n";
9
+ var graphql = {
10
+ GET_SETTINGS: gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query getSettings {\n fileManager {\n getSettings", "\n }\n }\n "])), fields),
11
+ UPDATE_SETTINGS: gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n mutation updateSettings($data: FileManagerSettingsInput) {\n fileManager {\n updateSettings(data: $data) ", "\n }\n }\n "])), fields)
12
+ };
13
+ export default graphql;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (() => (import("@webiny/app-admin/types").AdminInstallationPlugin | import("@webiny/app-admin/types").AdminAppPermissionRendererPlugin | (import("@webiny/app/plugins/RoutePlugin").RoutePlugin | import("@webiny/ui-composer/UIView").UIViewPlugin<import("@webiny/app-admin/ui/views/NavigationView").NavigationView>)[])[])[];
2
+ export default _default;
package/admin/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import plugins from "./plugins";
2
+ export default (function () {
3
+ return [plugins];
4
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (import("@webiny/app-admin/types").AdminInstallationPlugin | import("@webiny/app-admin/types").AdminAppPermissionRendererPlugin | (import("@webiny/app/plugins/RoutePlugin").RoutePlugin | import("@webiny/ui-composer/UIView").UIViewPlugin<import("@webiny/app-admin/ui/views/NavigationView").NavigationView>)[])[];
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import installation from "./installation";
2
+ import menus from "./menus";
3
+ import permissionRenderer from "./permissionRenderer";
4
+ export default (function () {
5
+ return [installation, menus, permissionRenderer];
6
+ });
@@ -0,0 +1,3 @@
1
+ import { AdminInstallationPlugin } from "@webiny/app-admin/types";
2
+ declare const plugin: AdminInstallationPlugin;
3
+ export default plugin;
@@ -0,0 +1,112 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
6
+
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import React, { useState, useEffect, lazy } from "react";
9
+ import gql from "graphql-tag";
10
+ import { useApolloClient } from "@apollo/react-hooks";
11
+ import { i18n } from "@webiny/app/i18n";
12
+ import { Alert } from "@webiny/ui/Alert";
13
+ import { CircularProgress } from "@webiny/ui/Progress";
14
+ import { SimpleForm, SimpleFormContent } from "@webiny/app-admin/components/SimpleForm";
15
+ import styled from "@emotion/styled";
16
+ var SimpleFormPlaceholder = /*#__PURE__*/styled("div", {
17
+ target: "eratgeh0",
18
+ label: "SimpleFormPlaceholder"
19
+ })({
20
+ minHeight: 300,
21
+ minWidth: 400
22
+ });
23
+ var t = i18n.ns("app-file-manager/admin/installation");
24
+ var IS_INSTALLED = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query IsFileManagerInstalled {\n fileManager {\n version\n }\n }\n"])));
25
+ var INSTALL = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n mutation InstallFileManager($srcPrefix: String) {\n fileManager {\n install(srcPrefix: $srcPrefix) {\n data\n error {\n code\n message\n }\n }\n }\n }\n"])));
26
+
27
+ var FMInstaller = function FMInstaller(_ref) {
28
+ var onInstalled = _ref.onInstalled;
29
+ var client = useApolloClient();
30
+
31
+ var _useState = useState(null),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ error = _useState2[0],
34
+ setError = _useState2[1];
35
+
36
+ useEffect(function () {
37
+ client.mutate({
38
+ mutation: INSTALL,
39
+ variables: {
40
+ srcPrefix: process.env.REACT_APP_API_URL + "/files"
41
+ }
42
+ }).then(function (_ref2) {
43
+ var data = _ref2.data;
44
+ var error = data.fileManager.install.error;
45
+
46
+ if (error) {
47
+ setError(error.message);
48
+ return;
49
+ } // Just so the user sees the actual message.
50
+
51
+
52
+ setTimeout(onInstalled, 3000);
53
+ });
54
+ }, []);
55
+ var label = error ? /*#__PURE__*/React.createElement(Alert, {
56
+ title: t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Something went wrong"]))),
57
+ type: "danger"
58
+ }, error) : t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Installing File Manager..."])));
59
+ return /*#__PURE__*/React.createElement(SimpleForm, null, /*#__PURE__*/React.createElement(CircularProgress, {
60
+ label: label
61
+ }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(SimpleFormPlaceholder, null)));
62
+ };
63
+
64
+ var plugin = {
65
+ name: "admin-installation-fm",
66
+ type: "admin-installation",
67
+ title: t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["File Manager"]))),
68
+ dependencies: ["admin-installation-security", "admin-installation-i18n"],
69
+ secure: true,
70
+ getInstalledVersion: function getInstalledVersion(_ref3) {
71
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
72
+ var client, _yield$client$query, data;
73
+
74
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
75
+ while (1) {
76
+ switch (_context.prev = _context.next) {
77
+ case 0:
78
+ client = _ref3.client;
79
+ _context.next = 3;
80
+ return client.query({
81
+ query: IS_INSTALLED
82
+ });
83
+
84
+ case 3:
85
+ _yield$client$query = _context.sent;
86
+ data = _yield$client$query.data;
87
+ return _context.abrupt("return", data.fileManager.version);
88
+
89
+ case 6:
90
+ case "end":
91
+ return _context.stop();
92
+ }
93
+ }
94
+ }, _callee);
95
+ }))();
96
+ },
97
+ render: function render(_ref4) {
98
+ var onInstalled = _ref4.onInstalled;
99
+ return /*#__PURE__*/React.createElement(FMInstaller, {
100
+ onInstalled: onInstalled
101
+ });
102
+ },
103
+ upgrades: [{
104
+ version: "5.0.0",
105
+ getComponent: function getComponent() {
106
+ return /*#__PURE__*/lazy(function () {
107
+ return import("./upgrades/v5.0.0");
108
+ });
109
+ }
110
+ }]
111
+ };
112
+ export default plugin;
@@ -0,0 +1,5 @@
1
+ import { NavigationView } from "@webiny/app-admin/ui/views/NavigationView";
2
+ import { RoutePlugin } from "@webiny/app/plugins/RoutePlugin";
3
+ import { UIViewPlugin } from "@webiny/app-admin/ui/UIView";
4
+ declare const _default: (RoutePlugin | UIViewPlugin<NavigationView>)[];
5
+ export default _default;
@@ -0,0 +1,101 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/createSuper";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ import * as React from "react";
7
+ import { Route } from "@webiny/react-router";
8
+ import { AdminLayout } from "@webiny/app-admin/components/AdminLayout";
9
+ import { SecureRoute } from "@webiny/app-security/components";
10
+ import { NavigationMenuElement } from "@webiny/app-admin/ui/elements/NavigationMenuElement";
11
+ import { NavigationView } from "@webiny/app-admin/ui/views/NavigationView";
12
+ import { RoutePlugin } from "@webiny/app/plugins/RoutePlugin";
13
+ import { UIViewPlugin } from "@webiny/app-admin/ui/UIView";
14
+ import FileManagerSettings from "../views/FileManagerSettings";
15
+ var PERMISSION_FM_SETTINGS = "fm.settings";
16
+
17
+ /**
18
+ * !EXAMPLE!
19
+ * This demonstrates how you can create your sub-classes to expose a nicer public API.
20
+ */
21
+ var ProtectedMenuElement = /*#__PURE__*/function (_NavigationMenuElemen) {
22
+ _inherits(ProtectedMenuElement, _NavigationMenuElemen);
23
+
24
+ var _super = _createSuper(ProtectedMenuElement);
25
+
26
+ function ProtectedMenuElement(id, config) {
27
+ var _this;
28
+
29
+ _classCallCheck(this, ProtectedMenuElement);
30
+
31
+ if (config.permission) {
32
+ config.shouldRender = function () {
33
+ var _this$getView$getSecu = _this.getView().getSecurityHook(),
34
+ identity = _this$getView$getSecu.identity;
35
+
36
+ return identity.getPermission(PERMISSION_FM_SETTINGS) !== undefined;
37
+ };
38
+ }
39
+
40
+ return _this = _super.call(this, id, config);
41
+ }
42
+
43
+ return ProtectedMenuElement;
44
+ }(NavigationMenuElement);
45
+
46
+ export default [new RoutePlugin({
47
+ route: /*#__PURE__*/React.createElement(Route, {
48
+ path: "/settings/file-manager/general",
49
+ render: function render() {
50
+ return /*#__PURE__*/React.createElement(SecureRoute, {
51
+ permission: PERMISSION_FM_SETTINGS
52
+ }, /*#__PURE__*/React.createElement(AdminLayout, {
53
+ title: "File Manager Settings - General"
54
+ }, /*#__PURE__*/React.createElement(FileManagerSettings, null)));
55
+ }
56
+ })
57
+ }), new UIViewPlugin(NavigationView, /*#__PURE__*/function () {
58
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(view) {
59
+ var _view$getSecurityHook, identity, hasPermissions, fileManagerSettings;
60
+
61
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
62
+ while (1) {
63
+ switch (_context.prev = _context.next) {
64
+ case 0:
65
+ _context.next = 2;
66
+ return view.isRendered();
67
+
68
+ case 2:
69
+ _view$getSecurityHook = view.getSecurityHook(), identity = _view$getSecurityHook.identity;
70
+ hasPermissions = identity.getPermission(PERMISSION_FM_SETTINGS) !== undefined;
71
+
72
+ if (hasPermissions) {
73
+ _context.next = 6;
74
+ break;
75
+ }
76
+
77
+ return _context.abrupt("return");
78
+
79
+ case 6:
80
+ fileManagerSettings = new ProtectedMenuElement("menu.settings.fileManager", {
81
+ label: "File Manager",
82
+ permission: PERMISSION_FM_SETTINGS
83
+ });
84
+ fileManagerSettings.addElement(new NavigationMenuElement("menu.settings.fileManager.general", {
85
+ label: "General",
86
+ path: "/settings/file-manager/general"
87
+ }));
88
+ view.addSettingsMenuElement(fileManagerSettings);
89
+
90
+ case 9:
91
+ case "end":
92
+ return _context.stop();
93
+ }
94
+ }
95
+ }, _callee);
96
+ }));
97
+
98
+ return function (_x) {
99
+ return _ref.apply(this, arguments);
100
+ };
101
+ }())];
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const FileManagerPermissions: ({ value, onChange }: {
3
+ value: any;
4
+ onChange: any;
5
+ }) => JSX.Element;
@@ -0,0 +1,226 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
4
+
5
+ import React, { Fragment, useCallback, useMemo } from "react";
6
+ import { Grid, Cell } from "@webiny/ui/Grid";
7
+ import { Select } from "@webiny/ui/Select";
8
+ import { i18n } from "@webiny/app/i18n";
9
+ import { PermissionInfo, gridNoPaddingClass } from "@webiny/app-admin/components/Permissions";
10
+ import { Form } from "@webiny/form";
11
+ import { Elevation } from "@webiny/ui/Elevation";
12
+ import { Typography } from "@webiny/ui/Typography";
13
+ var t = i18n.ns("app-file-manager/admin/plugins/permissionRenderer");
14
+ var FILE_MANAGER = "fm";
15
+ var FILE_MANAGER_FULL_ACCESS = "".concat(FILE_MANAGER, ".*");
16
+ var FILE_MANAGER_ACCESS_FILE = "".concat(FILE_MANAGER, ".file");
17
+ var FILE_MANAGER_ACCESS_SETTINGS = "".concat(FILE_MANAGER, ".settings");
18
+ var FULL_ACCESS = "full";
19
+ var NO_ACCESS = "no";
20
+ var CUSTOM_ACCESS = "custom";
21
+ export var FileManagerPermissions = function FileManagerPermissions(_ref) {
22
+ var value = _ref.value,
23
+ onChange = _ref.onChange;
24
+ var onFormChange = useCallback(function (data) {
25
+ var newValue = [];
26
+
27
+ if (Array.isArray(value)) {
28
+ // Let's just filter out the `file-manager*` permission objects, it's easier to build new ones from scratch.
29
+ newValue = value.filter(function (item) {
30
+ return !item.name.startsWith(FILE_MANAGER);
31
+ });
32
+ }
33
+
34
+ if (data.accessLevel === NO_ACCESS) {
35
+ onChange(newValue);
36
+ return;
37
+ }
38
+
39
+ if (data.accessLevel === FULL_ACCESS) {
40
+ newValue.push({
41
+ name: FILE_MANAGER_FULL_ACCESS
42
+ });
43
+ onChange(newValue);
44
+ return;
45
+ } // Handling custom access level.
46
+ // Files first.
47
+
48
+
49
+ if (data.filesAccessScope && data.filesAccessScope !== NO_ACCESS) {
50
+ var permission = {
51
+ name: FILE_MANAGER_ACCESS_FILE,
52
+ own: false,
53
+ rwd: undefined
54
+ };
55
+
56
+ if (data.filesAccessScope === "own") {
57
+ permission.own = true;
58
+ permission.rwd = "rwd";
59
+ } else {
60
+ permission.rwd = data.filesRWD || "r";
61
+ }
62
+
63
+ newValue.push(permission);
64
+ } // Settings second.
65
+
66
+
67
+ if (data.settingsAccessScope === FULL_ACCESS) {
68
+ newValue.push({
69
+ name: FILE_MANAGER_ACCESS_SETTINGS
70
+ });
71
+ }
72
+
73
+ onChange(newValue);
74
+ }, [value]);
75
+ var formData = useMemo(function () {
76
+ if (!Array.isArray(value)) {
77
+ return {
78
+ accessLevel: NO_ACCESS
79
+ };
80
+ }
81
+
82
+ var hasFullAccess = value.find(function (item) {
83
+ return item.name === FILE_MANAGER_FULL_ACCESS || item.name === "*";
84
+ });
85
+
86
+ if (hasFullAccess) {
87
+ return {
88
+ accessLevel: FULL_ACCESS
89
+ };
90
+ }
91
+
92
+ var permissions = value.filter(function (item) {
93
+ return item.name.startsWith(FILE_MANAGER);
94
+ });
95
+
96
+ if (!permissions.length) {
97
+ return {
98
+ accessLevel: NO_ACCESS
99
+ };
100
+ }
101
+
102
+ var data = {
103
+ accessLevel: CUSTOM_ACCESS,
104
+ filesAccessScope: NO_ACCESS,
105
+ settingsAccessScope: NO_ACCESS,
106
+ filesRWD: "r"
107
+ };
108
+ var filesPermission = permissions.find(function (item) {
109
+ return item.name === FILE_MANAGER_ACCESS_FILE;
110
+ });
111
+
112
+ if (filesPermission) {
113
+ data.filesAccessScope = filesPermission.own ? "own" : FULL_ACCESS;
114
+
115
+ if (data.filesAccessScope === FULL_ACCESS) {
116
+ data.filesRWD = filesPermission.rwd;
117
+ } else {
118
+ data.filesRWD = "rwd";
119
+ }
120
+ }
121
+
122
+ var hasSettingsAccess = permissions.find(function (item) {
123
+ return item.name === FILE_MANAGER_ACCESS_SETTINGS;
124
+ });
125
+
126
+ if (hasSettingsAccess) {
127
+ data.settingsAccessScope = FULL_ACCESS;
128
+ }
129
+
130
+ return data;
131
+ }, []);
132
+ return /*#__PURE__*/React.createElement(Form, {
133
+ data: formData,
134
+ onChange: onFormChange
135
+ }, function (_ref2) {
136
+ var data = _ref2.data,
137
+ Bind = _ref2.Bind,
138
+ setValue = _ref2.setValue;
139
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, {
140
+ className: gridNoPaddingClass
141
+ }, /*#__PURE__*/React.createElement(Cell, {
142
+ span: 6
143
+ }, /*#__PURE__*/React.createElement(PermissionInfo, {
144
+ title: t(_templateObject || (_templateObject = _taggedTemplateLiteral(["Access Level"])))
145
+ })), /*#__PURE__*/React.createElement(Cell, {
146
+ span: 6
147
+ }, /*#__PURE__*/React.createElement(Bind, {
148
+ name: "accessLevel"
149
+ }, /*#__PURE__*/React.createElement(Select, {
150
+ label: t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Access Level"])))
151
+ }, /*#__PURE__*/React.createElement("option", {
152
+ value: NO_ACCESS
153
+ }, t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["No access"])))), /*#__PURE__*/React.createElement("option", {
154
+ value: FULL_ACCESS
155
+ }, t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Full access"])))), /*#__PURE__*/React.createElement("option", {
156
+ value: CUSTOM_ACCESS
157
+ }, t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Custom access"])))))))), data.accessLevel === "custom" && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Elevation, {
158
+ z: 1,
159
+ style: {
160
+ marginTop: 10
161
+ }
162
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
163
+ span: 12
164
+ }, /*#__PURE__*/React.createElement(Typography, {
165
+ use: "overline"
166
+ }, t(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Files"]))))), /*#__PURE__*/React.createElement(Cell, {
167
+ span: 12
168
+ }, /*#__PURE__*/React.createElement(Grid, {
169
+ style: {
170
+ padding: 0,
171
+ paddingBottom: 24
172
+ }
173
+ }, /*#__PURE__*/React.createElement(Cell, {
174
+ span: 12
175
+ }, /*#__PURE__*/React.createElement(Bind, {
176
+ name: "filesAccessScope",
177
+ beforeChange: function beforeChange(value, cb) {
178
+ if (value === "own") {
179
+ setValue("filesRWD", "rwd");
180
+ }
181
+
182
+ cb(value);
183
+ }
184
+ }, /*#__PURE__*/React.createElement(Select, {
185
+ label: t(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Access Scope"])))
186
+ }, /*#__PURE__*/React.createElement("option", {
187
+ value: NO_ACCESS
188
+ }, t(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["No access"])))), /*#__PURE__*/React.createElement("option", {
189
+ value: FULL_ACCESS
190
+ }, t(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["All files"])))), /*#__PURE__*/React.createElement("option", {
191
+ value: "own"
192
+ }, t(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Only files created by the user"]))))))), /*#__PURE__*/React.createElement(Cell, {
193
+ span: 12
194
+ }, /*#__PURE__*/React.createElement(Bind, {
195
+ name: "filesRWD"
196
+ }, /*#__PURE__*/React.createElement(Select, {
197
+ label: t(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Primary Actions"]))),
198
+ disabled: data.filesAccessScope !== "full"
199
+ }, /*#__PURE__*/React.createElement("option", {
200
+ value: "r"
201
+ }, t(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Read"])))), /*#__PURE__*/React.createElement("option", {
202
+ value: "rw"
203
+ }, t(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Read, write"])))), /*#__PURE__*/React.createElement("option", {
204
+ value: "rwd"
205
+ }, t(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Read, write, delete"]))))))))))), /*#__PURE__*/React.createElement(Elevation, {
206
+ z: 1,
207
+ style: {
208
+ marginTop: 10
209
+ }
210
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
211
+ span: 12
212
+ }, /*#__PURE__*/React.createElement(Typography, {
213
+ use: "overline"
214
+ }, t(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Settings"]))))), /*#__PURE__*/React.createElement(Cell, {
215
+ span: 12
216
+ }, /*#__PURE__*/React.createElement(Bind, {
217
+ name: "settingsAccessScope"
218
+ }, /*#__PURE__*/React.createElement(Select, {
219
+ label: t(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["Access Scope"])))
220
+ }, /*#__PURE__*/React.createElement("option", {
221
+ value: NO_ACCESS
222
+ }, t(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["No access"])))), /*#__PURE__*/React.createElement("option", {
223
+ value: FULL_ACCESS
224
+ }, t(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["Full access"])))))))))));
225
+ });
226
+ };
@@ -0,0 +1,3 @@
1
+ import { AdminAppPermissionRendererPlugin } from "@webiny/app-admin/types";
2
+ declare const _default: AdminAppPermissionRendererPlugin;
3
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2;
4
+
5
+ import React from "react";
6
+ import { AccordionItem } from "@webiny/ui/Accordion";
7
+ import { ReactComponent as FileManagerIcon } from "@svgr/webpack!../../assets/icons/folder-open.svg";
8
+ import { FileManagerPermissions } from "./FileManagerPermissions";
9
+ import { i18n } from "@webiny/app/i18n";
10
+ var t = i18n.ns("app-file-manager/admin/plugins/permissionRenderer");
11
+ export default {
12
+ type: "admin-app-permissions-renderer",
13
+ name: "admin-app-permissions-renderer-file-manager",
14
+ render: function render(props) {
15
+ return /*#__PURE__*/React.createElement(AccordionItem, {
16
+ icon: /*#__PURE__*/React.createElement(FileManagerIcon, null),
17
+ title: t(_templateObject || (_templateObject = _taggedTemplateLiteral(["File Manager"]))),
18
+ description: t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Manage File manager app access permissions."]))),
19
+ "data-testid": "permission.fm"
20
+ }, /*#__PURE__*/React.createElement(FileManagerPermissions, props));
21
+ }
22
+ };
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const Upgrade: ({ onInstalled }: {
3
+ onInstalled: any;
4
+ }) => JSX.Element;
5
+ export default Upgrade;
@@ -0,0 +1,85 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+
5
+ var _templateObject, _templateObject2, _templateObject3;
6
+
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import React, { useCallback, useState } from "react";
9
+ import gql from "graphql-tag";
10
+ import { i18n } from "@webiny/app/i18n";
11
+ import { SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader } from "@webiny/app-admin/components/SimpleForm";
12
+ import { useApolloClient } from "@apollo/react-hooks";
13
+ import { Alert } from "@webiny/ui/Alert";
14
+ import { CircularProgress } from "@webiny/ui/Progress";
15
+ import { Cell, Grid } from "@webiny/ui/Grid";
16
+ import { ButtonPrimary } from "@webiny/ui/Button";
17
+ import { Typography } from "@webiny/ui/Typography";
18
+ var t = i18n.ns("app-headless-cms/admin/installation");
19
+ var UPGRADE = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n mutation UpgradeFileManager($version: String!) {\n fileManager {\n upgrade(version: $version) {\n data\n error {\n code\n message\n data\n }\n }\n }\n }\n"])));
20
+
21
+ var Upgrade = function Upgrade(_ref) {
22
+ var onInstalled = _ref.onInstalled;
23
+ var client = useApolloClient();
24
+
25
+ var _useState = useState(null),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ error = _useState2[0],
28
+ setError = _useState2[1];
29
+
30
+ var _useState3 = useState(false),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ loading = _useState4[0],
33
+ setLoading = _useState4[1];
34
+
35
+ var startUpgrade = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
36
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
37
+ while (1) {
38
+ switch (_context.prev = _context.next) {
39
+ case 0:
40
+ setLoading(true);
41
+ _context.next = 3;
42
+ return client.mutate({
43
+ mutation: UPGRADE,
44
+ variables: {
45
+ version: "5.0.0"
46
+ }
47
+ }).then(function (_ref3) {
48
+ var data = _ref3.data;
49
+ setLoading(false);
50
+ var error = data.fileManager.upgrade.error;
51
+
52
+ if (error) {
53
+ setError(error.message);
54
+ return;
55
+ }
56
+
57
+ onInstalled();
58
+ });
59
+
60
+ case 3:
61
+ case "end":
62
+ return _context.stop();
63
+ }
64
+ }
65
+ }, _callee);
66
+ })), []);
67
+ var label = error ? /*#__PURE__*/React.createElement(Alert, {
68
+ title: t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Something went wrong"]))),
69
+ type: "danger"
70
+ }, error) : t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Upgrading File Manager..."])));
71
+ return /*#__PURE__*/React.createElement(SimpleForm, null, loading && /*#__PURE__*/React.createElement(CircularProgress, {
72
+ label: label
73
+ }), /*#__PURE__*/React.createElement(SimpleFormHeader, {
74
+ title: "Upgrade File Manager"
75
+ }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
76
+ span: 12
77
+ }, /*#__PURE__*/React.createElement(Typography, {
78
+ use: "body1",
79
+ tag: "div"
80
+ }, "This upgrade will do the following:", /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, "insert Elasticsearch records into a dedicated DynamoDB table")))))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, /*#__PURE__*/React.createElement(ButtonPrimary, {
81
+ onClick: startUpgrade
82
+ }, "Upgrade")));
83
+ };
84
+
85
+ export default Upgrade;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const FileManagerSettings: () => JSX.Element;
3
+ export default FileManagerSettings;
@@ -0,0 +1,95 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import * as React from "react";
4
+ import { Form } from "@webiny/form";
5
+ import { Grid, Cell } from "@webiny/ui/Grid";
6
+ import { ButtonPrimary } from "@webiny/ui/Button";
7
+ import { Query, Mutation } from "@apollo/react-components";
8
+ import { useSnackbar } from "@webiny/app-admin/hooks/useSnackbar";
9
+ import { Input } from "@webiny/ui/Input";
10
+ import graphql from "../graphql";
11
+ import { CircularProgress } from "@webiny/ui/Progress";
12
+ import get from "lodash.get";
13
+ import { SimpleForm, SimpleFormFooter, SimpleFormContent, SimpleFormHeader } from "@webiny/app-admin/components/SimpleForm";
14
+
15
+ var FileManagerSettings = function FileManagerSettings() {
16
+ var _useSnackbar = useSnackbar(),
17
+ showSnackbar = _useSnackbar.showSnackbar;
18
+
19
+ return /*#__PURE__*/React.createElement(Query, {
20
+ query: graphql.GET_SETTINGS
21
+ }, function (_ref) {
22
+ var data = _ref.data,
23
+ queryInProgress = _ref.loading;
24
+ return /*#__PURE__*/React.createElement(Mutation, {
25
+ mutation: graphql.UPDATE_SETTINGS
26
+ }, function (update, _ref2) {
27
+ var mutationInProgress = _ref2.loading;
28
+ var settings = get(data, "fileManager.getSettings.data") || {};
29
+ return /*#__PURE__*/React.createElement(Form, {
30
+ data: settings,
31
+ onSubmit: /*#__PURE__*/function () {
32
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
33
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
34
+ while (1) {
35
+ switch (_context.prev = _context.next) {
36
+ case 0:
37
+ _context.next = 2;
38
+ return update({
39
+ variables: {
40
+ data: {
41
+ uploadMinFileSize: parseFloat(data.uploadMinFileSize),
42
+ uploadMaxFileSize: parseFloat(data.uploadMaxFileSize)
43
+ }
44
+ }
45
+ });
46
+
47
+ case 2:
48
+ showSnackbar("Settings updated successfully.");
49
+
50
+ case 3:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }
55
+ }, _callee);
56
+ }));
57
+
58
+ return function (_x) {
59
+ return _ref3.apply(this, arguments);
60
+ };
61
+ }()
62
+ }, function (_ref4) {
63
+ var Bind = _ref4.Bind,
64
+ form = _ref4.form;
65
+ return /*#__PURE__*/React.createElement(SimpleForm, null, (queryInProgress || mutationInProgress) && /*#__PURE__*/React.createElement(CircularProgress, null), /*#__PURE__*/React.createElement(SimpleFormHeader, {
66
+ title: "General File Manager Settings"
67
+ }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
68
+ span: 12
69
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
70
+ span: 6
71
+ }, /*#__PURE__*/React.createElement(Bind, {
72
+ name: "uploadMinFileSize"
73
+ }, /*#__PURE__*/React.createElement(Input, {
74
+ type: "number",
75
+ label: "Minimum file upload size",
76
+ description: "In bytes"
77
+ }))))), /*#__PURE__*/React.createElement(Cell, {
78
+ span: 12
79
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
80
+ span: 6
81
+ }, /*#__PURE__*/React.createElement(Bind, {
82
+ name: "uploadMaxFileSize"
83
+ }, /*#__PURE__*/React.createElement(Input, {
84
+ type: "number",
85
+ label: "Maximum file upload size",
86
+ description: "In bytes"
87
+ }))))))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, /*#__PURE__*/React.createElement(ButtonPrimary, {
88
+ onClick: form.submit
89
+ }, "Save")));
90
+ });
91
+ });
92
+ });
93
+ };
94
+
95
+ export default FileManagerSettings;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@webiny/app-file-manager",
3
+ "version": "0.0.0-mt-1",
4
+ "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/webiny/webiny-js.git"
8
+ },
9
+ "author": "Jon Rapp ",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "@apollo/react-components": "3.1.5",
13
+ "@apollo/react-hooks": "3.1.5",
14
+ "@babel/runtime": "7.15.4",
15
+ "@emotion/core": "10.1.1",
16
+ "@emotion/styled": "10.0.27",
17
+ "@types/react": "16.14.2",
18
+ "@webiny/app": "0.0.0-mt-1",
19
+ "@webiny/app-admin": "0.0.0-mt-1",
20
+ "@webiny/app-security": "0.0.0-mt-1",
21
+ "@webiny/form": "0.0.0-mt-1",
22
+ "@webiny/plugins": "0.0.0-mt-1",
23
+ "@webiny/react-router": "0.0.0-mt-1",
24
+ "@webiny/ui": "0.0.0-mt-1",
25
+ "apollo-cache": "1.3.5",
26
+ "apollo-client": "2.6.10",
27
+ "apollo-link": "1.2.14",
28
+ "apollo-utilities": "1.3.4",
29
+ "graphql": "14.7.0",
30
+ "graphql-tag": "2.12.5",
31
+ "lodash.get": "4.4.2",
32
+ "prop-types": "15.7.2",
33
+ "react": "16.14.0",
34
+ "react-dom": "16.14.0"
35
+ },
36
+ "devDependencies": {
37
+ "@babel/cli": "^7.5.5",
38
+ "@babel/core": "^7.5.5",
39
+ "@babel/preset-env": "^7.5.5",
40
+ "@babel/preset-react": "^7.0.0",
41
+ "@babel/preset-typescript": "^7.8.3",
42
+ "@svgr/webpack": "^4.3.2",
43
+ "@webiny/cli": "^0.0.0-mt-1",
44
+ "@webiny/project-utils": "^0.0.0-mt-1",
45
+ "babel-plugin-named-asset-import": "^1.0.0-next.3e165448",
46
+ "rimraf": "^3.0.2",
47
+ "typescript": "^4.1.3"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public",
51
+ "directory": "dist"
52
+ },
53
+ "scripts": {
54
+ "build": "yarn webiny run build",
55
+ "watch": "yarn webiny run watch"
56
+ },
57
+ "gitHead": "37736d8456a6ecb342a6c3645060bd9a3f2d4bb0"
58
+ }
package/types.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import { Plugin } from "@webiny/plugins/types";
3
+ import { SecurityPermission } from "@webiny/app-security/types";
4
+ export declare type PermissionRendererPluginRenderFunctionType = (props: {
5
+ value: SecurityPermission;
6
+ setValue: (newValue: SecurityPermission) => void;
7
+ }) => React.ReactElement<any>;
8
+ export declare type PermissionRendererFileManager = Plugin & {
9
+ type: "permission-renderer-file-manager";
10
+ key: string;
11
+ label: string;
12
+ render: PermissionRendererPluginRenderFunctionType;
13
+ };
package/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};