@webiny/app-headless-cms 5.19.0-beta.1 → 5.19.0-beta.5
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/admin/plugins/install.js +7 -0
- package/admin/plugins/upgrades/5.19.0/UpgradeItemsInfo.d.ts +7 -0
- package/admin/plugins/upgrades/5.19.0/UpgradeItemsInfo.js +53 -0
- package/admin/plugins/upgrades/5.19.0/createCmsApolloClient.d.ts +7 -0
- package/admin/plugins/upgrades/5.19.0/createCmsApolloClient.js +49 -0
- package/admin/plugins/upgrades/5.19.0/createListEntriesQuery.d.ts +2 -0
- package/admin/plugins/upgrades/5.19.0/createListEntriesQuery.js +12 -0
- package/admin/plugins/upgrades/5.19.0/createListModelsQuery.d.ts +1 -0
- package/admin/plugins/upgrades/5.19.0/createListModelsQuery.js +8 -0
- package/admin/plugins/upgrades/5.19.0/createRepublishMutation.d.ts +1 -0
- package/admin/plugins/upgrades/5.19.0/createRepublishMutation.js +10 -0
- package/admin/plugins/upgrades/5.19.0/createUpgradeMutation.d.ts +1 -0
- package/admin/plugins/upgrades/5.19.0/createUpgradeMutation.js +8 -0
- package/admin/plugins/upgrades/5.19.0/fetchModelEntries.d.ts +7 -0
- package/admin/plugins/upgrades/5.19.0/fetchModelEntries.js +122 -0
- package/admin/plugins/upgrades/5.19.0/types.d.ts +47 -0
- package/admin/plugins/upgrades/5.19.0/types.js +1 -0
- package/admin/plugins/upgrades/v5.19.0.d.ts +5 -0
- package/admin/plugins/upgrades/v5.19.0.js +647 -0
- package/package.json +18 -17
package/admin/plugins/install.js
CHANGED
|
@@ -122,6 +122,13 @@ var plugin = {
|
|
|
122
122
|
return import("./upgrades/v5.8.0");
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
+
}, {
|
|
126
|
+
version: "5.19.0",
|
|
127
|
+
getComponent: function getComponent() {
|
|
128
|
+
return /*#__PURE__*/lazy(function () {
|
|
129
|
+
return import("./upgrades/v5.19.0");
|
|
130
|
+
});
|
|
131
|
+
}
|
|
125
132
|
}]
|
|
126
133
|
};
|
|
127
134
|
export default plugin;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Typography } from "@webiny/ui/Typography";
|
|
3
|
+
|
|
4
|
+
var findUpgradingModel = function findUpgradingModel(locales) {
|
|
5
|
+
for (var locale in locales) {
|
|
6
|
+
if (!locales[locale]) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var modelsData = Object.values(locales[locale]);
|
|
11
|
+
|
|
12
|
+
for (var modelId in modelsData) {
|
|
13
|
+
if (modelsData[modelId].upgrading !== true) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
locale: locale,
|
|
19
|
+
model: modelsData[modelId].model,
|
|
20
|
+
total: modelsData[modelId].entries.length,
|
|
21
|
+
current: modelsData[modelId].entries.filter(function (item) {
|
|
22
|
+
return item.done;
|
|
23
|
+
}).length
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export var UpgradeItemsInfo = function UpgradeItemsInfo(props) {
|
|
32
|
+
var upgradeItems = props.upgradeItems;
|
|
33
|
+
|
|
34
|
+
if (!upgradeItems || upgradeItems.loadedModels !== true || !upgradeItems.locales) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var locales = upgradeItems.locales;
|
|
39
|
+
var result = findUpgradingModel(locales);
|
|
40
|
+
|
|
41
|
+
if (!result) {
|
|
42
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var locale = result.locale,
|
|
46
|
+
model = result.model,
|
|
47
|
+
current = result.current,
|
|
48
|
+
total = result.total;
|
|
49
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
50
|
+
use: "body1",
|
|
51
|
+
tag: "div"
|
|
52
|
+
}, "Upgrading model ", /*#__PURE__*/React.createElement("strong", null, model.name), " in locale ", /*#__PURE__*/React.createElement("strong", null, locale), " (", current, " of ", total, " updated)");
|
|
53
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import ApolloClient from "apollo-client";
|
|
2
|
+
export interface Params {
|
|
3
|
+
locale: string;
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
endpoint: "manage" | "read";
|
|
6
|
+
}
|
|
7
|
+
export declare const createCmsApolloClient: ({ locale, apiUrl, endpoint }: Params) => ApolloClient<import("apollo-cache-inmemory").NormalizedCacheObject>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ApolloClient from "apollo-client";
|
|
2
|
+
import { ApolloLink } from "apollo-link";
|
|
3
|
+
import { ApolloDynamicLink } from "@webiny/app/plugins/ApolloDynamicLink";
|
|
4
|
+
import { InMemoryCache } from "@webiny/app/apollo-client/InMemoryCache";
|
|
5
|
+
import { plugins } from "@webiny/plugins";
|
|
6
|
+
import { ApolloCacheObjectIdPlugin } from "@webiny/app/plugins/ApolloCacheObjectIdPlugin";
|
|
7
|
+
import { BatchHttpLink } from "apollo-link-batch-http";
|
|
8
|
+
export var createCmsApolloClient = function createCmsApolloClient(_ref) {
|
|
9
|
+
var locale = _ref.locale,
|
|
10
|
+
apiUrl = _ref.apiUrl,
|
|
11
|
+
endpoint = _ref.endpoint;
|
|
12
|
+
return new ApolloClient({
|
|
13
|
+
link: ApolloLink.from([
|
|
14
|
+
/**
|
|
15
|
+
* This will process links from plugins on every request.
|
|
16
|
+
*/
|
|
17
|
+
new ApolloDynamicLink(),
|
|
18
|
+
/**
|
|
19
|
+
* This batches requests made to the API to pack multiple requests into a single HTTP request.
|
|
20
|
+
*/
|
|
21
|
+
new BatchHttpLink({
|
|
22
|
+
uri: "".concat(apiUrl, "/cms/").concat(endpoint, "/").concat(locale)
|
|
23
|
+
})]),
|
|
24
|
+
cache: new InMemoryCache({
|
|
25
|
+
addTypename: true,
|
|
26
|
+
dataIdFromObject: function dataIdFromObject(obj) {
|
|
27
|
+
/**
|
|
28
|
+
* Since every data type coming from API can have a different data structure,
|
|
29
|
+
* we cannot rely on having an `id` field.
|
|
30
|
+
*/
|
|
31
|
+
var getters = plugins.byType(ApolloCacheObjectIdPlugin.type);
|
|
32
|
+
|
|
33
|
+
for (var i = 0; i < getters.length; i++) {
|
|
34
|
+
var id = getters[i].getObjectId(obj);
|
|
35
|
+
|
|
36
|
+
if (typeof id !== "undefined") {
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* As a fallback, try getting object's `id`.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
return obj.id || null;
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import upperFirst from "lodash/upperFirst";
|
|
6
|
+
import pluralize from "pluralize";
|
|
7
|
+
import gql from "graphql-tag";
|
|
8
|
+
export var createListEntriesQuery = function createListEntriesQuery(model) {
|
|
9
|
+
var ucFirstPluralizedModelId = upperFirst(pluralize(model.modelId));
|
|
10
|
+
var ucFirstModelId = upperFirst(model.modelId);
|
|
11
|
+
return gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query CmsEntriesList", "($where: ", "ListWhereInput, $sort: [", "ListSorter], $limit: Int, $after: String) {\n content: list", "(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n ) {\n data {\n id\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n data\n }\n }\n }\n "])), ucFirstPluralizedModelId, ucFirstModelId, ucFirstModelId, ucFirstPluralizedModelId);
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createListModelsQuery: () => import("graphql").DocumentNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import gql from "graphql-tag";
|
|
6
|
+
export var createListModelsQuery = function createListModelsQuery() {
|
|
7
|
+
return gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query CmsListContentModels {\n listContentModels {\n data {\n modelId\n name\n fields {\n id\n type\n }\n }\n error {\n message\n code\n data\n }\n }\n }\n "])));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createRepublishMutation: (model: any) => import("graphql").DocumentNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import upperFirst from "lodash/upperFirst";
|
|
6
|
+
import gql from "graphql-tag";
|
|
7
|
+
export var createRepublishMutation = function createRepublishMutation(model) {
|
|
8
|
+
var ucFirstModelId = upperFirst(model.modelId);
|
|
9
|
+
return gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n mutation CmsRepublish", "($revision: ID!) {\n content: republish", "(revision: $revision) {\n data {\n id\n }\n error {\n message\n data\n code\n }\n }\n }"])), ucFirstModelId, ucFirstModelId);
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createUpgradeMutation: () => import("graphql").DocumentNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import gql from "graphql-tag";
|
|
6
|
+
export var createUpgradeMutation = function createUpgradeMutation() {
|
|
7
|
+
return gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n mutation UpgradeCMS($version: String!) {\n cms {\n upgrade(version: $version) {\n data\n error {\n code\n message\n data\n }\n }\n }\n }\n "])));
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CmsEditorContentModel } from "../../../../types";
|
|
2
|
+
import { ApolloClient } from "apollo-client";
|
|
3
|
+
export interface Params {
|
|
4
|
+
model: CmsEditorContentModel;
|
|
5
|
+
client: ApolloClient<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const fetchModelEntries: (params: Params) => Promise<string[]>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import { createListEntriesQuery } from "./createListEntriesQuery";
|
|
5
|
+
|
|
6
|
+
var fetchEntries = /*#__PURE__*/function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
|
|
8
|
+
var client, query, variables, response, _response$data$conten, items, error, meta;
|
|
9
|
+
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) {
|
|
12
|
+
switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
client = params.client, query = params.query, variables = params.variables;
|
|
15
|
+
_context.next = 3;
|
|
16
|
+
return client.query({
|
|
17
|
+
query: query,
|
|
18
|
+
variables: variables
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
case 3:
|
|
22
|
+
response = _context.sent;
|
|
23
|
+
_response$data$conten = response.data.content, items = _response$data$conten.data, error = _response$data$conten.error, meta = _response$data$conten.meta;
|
|
24
|
+
|
|
25
|
+
if (!error) {
|
|
26
|
+
_context.next = 8;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.error(error.message);
|
|
31
|
+
return _context.abrupt("return", null);
|
|
32
|
+
|
|
33
|
+
case 8:
|
|
34
|
+
return _context.abrupt("return", {
|
|
35
|
+
items: items || [],
|
|
36
|
+
hasMoreItems: meta.hasMoreItems,
|
|
37
|
+
cursor: meta.cursor,
|
|
38
|
+
totalCount: meta.totalCount
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
case 9:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
return function fetchEntries(_x) {
|
|
50
|
+
return _ref.apply(this, arguments);
|
|
51
|
+
};
|
|
52
|
+
}();
|
|
53
|
+
|
|
54
|
+
export var fetchModelEntries = /*#__PURE__*/function () {
|
|
55
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
|
|
56
|
+
var model, client, items, query, variables, result;
|
|
57
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58
|
+
while (1) {
|
|
59
|
+
switch (_context2.prev = _context2.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
model = params.model, client = params.client;
|
|
62
|
+
items = [];
|
|
63
|
+
query = createListEntriesQuery(model);
|
|
64
|
+
variables = {
|
|
65
|
+
limit: 100,
|
|
66
|
+
after: null,
|
|
67
|
+
where: {}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
case 4:
|
|
71
|
+
_context2.next = 6;
|
|
72
|
+
return fetchEntries({
|
|
73
|
+
client: client,
|
|
74
|
+
query: query,
|
|
75
|
+
variables: variables
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
case 6:
|
|
79
|
+
if (!(result = _context2.sent)) {
|
|
80
|
+
_context2.next = 15;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (result) {
|
|
85
|
+
_context2.next = 9;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return _context2.abrupt("return", items);
|
|
90
|
+
|
|
91
|
+
case 9:
|
|
92
|
+
items.push.apply(items, _toConsumableArray(result.items.map(function (item) {
|
|
93
|
+
return item.id;
|
|
94
|
+
})));
|
|
95
|
+
|
|
96
|
+
if (!(result.hasMoreItems === false)) {
|
|
97
|
+
_context2.next = 12;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return _context2.abrupt("return", items);
|
|
102
|
+
|
|
103
|
+
case 12:
|
|
104
|
+
variables.after = result.cursor;
|
|
105
|
+
_context2.next = 4;
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 15:
|
|
109
|
+
return _context2.abrupt("return", items);
|
|
110
|
+
|
|
111
|
+
case 16:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context2.stop();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, _callee2);
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
return function fetchModelEntries(_x2) {
|
|
120
|
+
return _ref2.apply(this, arguments);
|
|
121
|
+
};
|
|
122
|
+
}();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApolloClient } from "apollo-client";
|
|
2
|
+
import { CmsEditorContentModel } from "../../../../types";
|
|
3
|
+
export interface Clients {
|
|
4
|
+
read: ApolloClient<any>;
|
|
5
|
+
manage: ApolloClient<any>;
|
|
6
|
+
}
|
|
7
|
+
export interface CurrentlyUpgrading {
|
|
8
|
+
locale: string;
|
|
9
|
+
model: CmsEditorContentModel;
|
|
10
|
+
running: boolean;
|
|
11
|
+
fetchingEntries: boolean;
|
|
12
|
+
after: string;
|
|
13
|
+
entry: string | null;
|
|
14
|
+
totalCount: number | null;
|
|
15
|
+
currentEntry: number | null;
|
|
16
|
+
error?: {
|
|
17
|
+
message: string;
|
|
18
|
+
code: string;
|
|
19
|
+
data: any;
|
|
20
|
+
};
|
|
21
|
+
entries: {
|
|
22
|
+
id: string;
|
|
23
|
+
done: boolean;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
export interface UpgradeEntryItem {
|
|
27
|
+
id: string;
|
|
28
|
+
done: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface UpgradeModelItem {
|
|
31
|
+
model: CmsEditorContentModel;
|
|
32
|
+
entries: UpgradeEntryItem[];
|
|
33
|
+
done: boolean;
|
|
34
|
+
upgrading: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface UpgradeModelItems {
|
|
37
|
+
[modelId: string]: UpgradeModelItem;
|
|
38
|
+
}
|
|
39
|
+
export interface UpgradeItems {
|
|
40
|
+
loadedModels: boolean;
|
|
41
|
+
locales: Record<string, UpgradeModelItems>;
|
|
42
|
+
}
|
|
43
|
+
export interface ErrorValue {
|
|
44
|
+
code?: string;
|
|
45
|
+
data?: any;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
6
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
7
|
+
|
|
8
|
+
var _templateObject, _templateObject2;
|
|
9
|
+
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
12
|
+
import { i18n } from "@webiny/app/i18n";
|
|
13
|
+
import { SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader } from "@webiny/app-admin/components/SimpleForm";
|
|
14
|
+
import { useApolloClient } from "@apollo/react-hooks";
|
|
15
|
+
import { Alert } from "@webiny/ui/Alert";
|
|
16
|
+
import { CircularProgress } from "@webiny/ui/Progress";
|
|
17
|
+
import { Cell, Grid } from "@webiny/ui/Grid";
|
|
18
|
+
import { ButtonPrimary } from "@webiny/ui/Button";
|
|
19
|
+
import { Typography } from "@webiny/ui/Typography";
|
|
20
|
+
import { createCmsApolloClient } from "./5.19.0/createCmsApolloClient";
|
|
21
|
+
import { config as appConfig } from "@webiny/app/config";
|
|
22
|
+
import { LIST_LOCALES } from "@webiny/app-i18n/admin/views/locales/hooks/graphql";
|
|
23
|
+
import { UpgradeItemsInfo } from "./5.19.0/UpgradeItemsInfo";
|
|
24
|
+
import { fetchModelEntries } from "./5.19.0/fetchModelEntries";
|
|
25
|
+
import { createRepublishMutation } from "./5.19.0/createRepublishMutation";
|
|
26
|
+
import { createUpgradeMutation } from "./5.19.0/createUpgradeMutation";
|
|
27
|
+
import { createListModelsQuery } from "./5.19.0/createListModelsQuery";
|
|
28
|
+
var t = i18n.ns("app-headless-cms/admin/installation");
|
|
29
|
+
var clients = {};
|
|
30
|
+
|
|
31
|
+
var getClient = function getClient(locale) {
|
|
32
|
+
if (!clients[locale]) {
|
|
33
|
+
throw new Error("There are no clients for locale \"".concat(locale, "\"."));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return clients[locale];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var getManageClient = function getManageClient(locale) {
|
|
40
|
+
return getClient(locale).manage;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var getReadClient = function getReadClient(locale) {
|
|
44
|
+
return getClient(locale).read;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var createUpgradeItems = function createUpgradeItems(params) {
|
|
48
|
+
var locales = params.locales;
|
|
49
|
+
var items = {
|
|
50
|
+
loadedModels: false,
|
|
51
|
+
locales: {}
|
|
52
|
+
};
|
|
53
|
+
var apiUrl = appConfig.getKey("API_URL", process.env.REACT_APP_API_URL);
|
|
54
|
+
|
|
55
|
+
var _iterator = _createForOfIteratorHelper(locales),
|
|
56
|
+
_step;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
60
|
+
var locale = _step.value;
|
|
61
|
+
items.locales[locale.code] = null;
|
|
62
|
+
clients[locale.code] = {
|
|
63
|
+
read: createCmsApolloClient({
|
|
64
|
+
locale: locale.code,
|
|
65
|
+
apiUrl: apiUrl,
|
|
66
|
+
endpoint: "read"
|
|
67
|
+
}),
|
|
68
|
+
manage: createCmsApolloClient({
|
|
69
|
+
locale: locale.code,
|
|
70
|
+
apiUrl: apiUrl,
|
|
71
|
+
endpoint: "manage"
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_iterator.e(err);
|
|
77
|
+
} finally {
|
|
78
|
+
_iterator.f();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return items;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var updateUpgradeItems = function updateUpgradeItems(params) {
|
|
85
|
+
var previous = params.previous,
|
|
86
|
+
models = params.models;
|
|
87
|
+
var locales = {};
|
|
88
|
+
|
|
89
|
+
for (var locale in previous.locales) {
|
|
90
|
+
locales[locale] = (models[locale] || []).reduce(function (collection, model) {
|
|
91
|
+
collection[model.modelId] = {
|
|
92
|
+
model: model,
|
|
93
|
+
done: false,
|
|
94
|
+
entries: [],
|
|
95
|
+
upgrading: false
|
|
96
|
+
};
|
|
97
|
+
return collection;
|
|
98
|
+
}, {});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
loadedModels: true,
|
|
103
|
+
locales: locales
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var Upgrade = function Upgrade(_ref) {
|
|
108
|
+
var onInstalled = _ref.onInstalled;
|
|
109
|
+
var client = useApolloClient();
|
|
110
|
+
|
|
111
|
+
var _useState = useState(null),
|
|
112
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
113
|
+
error = _useState2[0],
|
|
114
|
+
setError = _useState2[1];
|
|
115
|
+
|
|
116
|
+
var _useState3 = useState(false),
|
|
117
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
118
|
+
loading = _useState4[0],
|
|
119
|
+
setLoading = _useState4[1];
|
|
120
|
+
|
|
121
|
+
var _useState5 = useState(false),
|
|
122
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
123
|
+
upgrade = _useState6[0],
|
|
124
|
+
setUpgrade = _useState6[1];
|
|
125
|
+
|
|
126
|
+
var _useState7 = useState("pending"),
|
|
127
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
128
|
+
status = _useState8[0],
|
|
129
|
+
setStatus = _useState8[1];
|
|
130
|
+
|
|
131
|
+
var _useState9 = useState(null),
|
|
132
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
133
|
+
upgradeItems = _useState10[0],
|
|
134
|
+
setUpgradeItems = _useState10[1];
|
|
135
|
+
|
|
136
|
+
useEffect(function () {
|
|
137
|
+
/**
|
|
138
|
+
* Never do this if we have upgrade items.
|
|
139
|
+
*/
|
|
140
|
+
if (upgradeItems || loading === true) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setLoading(true);
|
|
145
|
+
|
|
146
|
+
var fetchLocales = /*#__PURE__*/function () {
|
|
147
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
148
|
+
var response;
|
|
149
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
150
|
+
while (1) {
|
|
151
|
+
switch (_context.prev = _context.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
_context.next = 2;
|
|
154
|
+
return client.query({
|
|
155
|
+
query: LIST_LOCALES
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
case 2:
|
|
159
|
+
response = _context.sent;
|
|
160
|
+
|
|
161
|
+
if (!(!response || !response.data || !response.data.i18n || !response.data.i18n.listI18NLocales)) {
|
|
162
|
+
_context.next = 8;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.error("Missing response when fetching locales.");
|
|
167
|
+
return _context.abrupt("return");
|
|
168
|
+
|
|
169
|
+
case 8:
|
|
170
|
+
if (!response.data.i18n.listI18NLocales.error) {
|
|
171
|
+
_context.next = 12;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
console.error(response.data.i18n.listI18NLocales.error.message);
|
|
176
|
+
setError(error);
|
|
177
|
+
return _context.abrupt("return");
|
|
178
|
+
|
|
179
|
+
case 12:
|
|
180
|
+
/**
|
|
181
|
+
* New state for the upgrade items.
|
|
182
|
+
*/
|
|
183
|
+
setUpgradeItems(function () {
|
|
184
|
+
return createUpgradeItems({
|
|
185
|
+
locales: response.data.i18n.listI18NLocales.data
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
/**
|
|
189
|
+
* And stop the spinner.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
setLoading(false);
|
|
193
|
+
|
|
194
|
+
case 14:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context.stop();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, _callee);
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
return function fetchLocales() {
|
|
203
|
+
return _ref2.apply(this, arguments);
|
|
204
|
+
};
|
|
205
|
+
}();
|
|
206
|
+
|
|
207
|
+
fetchLocales();
|
|
208
|
+
}, []);
|
|
209
|
+
useEffect(function () {
|
|
210
|
+
if (!upgradeItems || !upgradeItems.locales || upgradeItems.loadedModels === true || loading === true) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
setLoading(true);
|
|
215
|
+
|
|
216
|
+
var fetchModels = /*#__PURE__*/function () {
|
|
217
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
218
|
+
var models, locales, query, locale, response, _ref4, listContentModels, data, _error;
|
|
219
|
+
|
|
220
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
221
|
+
while (1) {
|
|
222
|
+
switch (_context2.prev = _context2.next) {
|
|
223
|
+
case 0:
|
|
224
|
+
models = {};
|
|
225
|
+
/**
|
|
226
|
+
* Load all models from locales, one by one so we dont nuke API too much.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
locales = upgradeItems.locales;
|
|
230
|
+
/**
|
|
231
|
+
* Query does not care about locale so we can create it before the loop.
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
query = createListModelsQuery();
|
|
235
|
+
/**
|
|
236
|
+
*
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
_context2.t0 = _regeneratorRuntime.keys(locales);
|
|
240
|
+
|
|
241
|
+
case 4:
|
|
242
|
+
if ((_context2.t1 = _context2.t0()).done) {
|
|
243
|
+
_context2.next = 26;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
locale = _context2.t1.value;
|
|
248
|
+
_context2.next = 8;
|
|
249
|
+
return getManageClient(locale).query({
|
|
250
|
+
query: query
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
case 8:
|
|
254
|
+
response = _context2.sent;
|
|
255
|
+
_ref4 = response.data || {}, listContentModels = _ref4.listContentModels;
|
|
256
|
+
data = listContentModels.data, _error = listContentModels.error;
|
|
257
|
+
|
|
258
|
+
if (!_error) {
|
|
259
|
+
_context2.next = 16;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
setError(_error);
|
|
264
|
+
return _context2.abrupt("return");
|
|
265
|
+
|
|
266
|
+
case 16:
|
|
267
|
+
if (data) {
|
|
268
|
+
_context2.next = 21;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
setError({
|
|
273
|
+
message: "No data received when loading all models in locale \"".concat(locale, "\".")
|
|
274
|
+
});
|
|
275
|
+
return _context2.abrupt("return");
|
|
276
|
+
|
|
277
|
+
case 21:
|
|
278
|
+
if (!(data.length === 0)) {
|
|
279
|
+
_context2.next = 23;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return _context2.abrupt("continue", 4);
|
|
284
|
+
|
|
285
|
+
case 23:
|
|
286
|
+
/**
|
|
287
|
+
* We only need models that have at least one ref field or an object field that MIGHT contain ref fields.
|
|
288
|
+
*/
|
|
289
|
+
models[locale] = data.filter(function (model) {
|
|
290
|
+
return model.fields.some(function (field) {
|
|
291
|
+
return field.type === "object" || field.type === "ref";
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
_context2.next = 4;
|
|
295
|
+
break;
|
|
296
|
+
|
|
297
|
+
case 26:
|
|
298
|
+
/**
|
|
299
|
+
* We add models only once to skip unnecessary state changes.
|
|
300
|
+
*/
|
|
301
|
+
setUpgradeItems(function (previous) {
|
|
302
|
+
return updateUpgradeItems({
|
|
303
|
+
previous: previous,
|
|
304
|
+
models: models
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
setLoading(false);
|
|
308
|
+
|
|
309
|
+
case 28:
|
|
310
|
+
case "end":
|
|
311
|
+
return _context2.stop();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}, _callee2);
|
|
315
|
+
}));
|
|
316
|
+
|
|
317
|
+
return function fetchModels() {
|
|
318
|
+
return _ref3.apply(this, arguments);
|
|
319
|
+
};
|
|
320
|
+
}();
|
|
321
|
+
|
|
322
|
+
fetchModels();
|
|
323
|
+
}, [upgradeItems, loading]);
|
|
324
|
+
var startUpgrade = useCallback(function () {
|
|
325
|
+
if (!upgradeItems || upgradeItems.loadedModels !== true || upgrade === true) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
setUpgrade(true);
|
|
330
|
+
}, [upgradeItems]);
|
|
331
|
+
useEffect(function () {
|
|
332
|
+
if (!upgrade || !upgradeItems || !upgradeItems.locales || upgradeItems.loadedModels === false || status !== "pending") {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var locales = upgradeItems.locales;
|
|
337
|
+
setStatus("upgrading");
|
|
338
|
+
|
|
339
|
+
var republish = /*#__PURE__*/function () {
|
|
340
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
341
|
+
var _loop, locale, _ret, response, error;
|
|
342
|
+
|
|
343
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context6) {
|
|
344
|
+
while (1) {
|
|
345
|
+
switch (_context6.prev = _context6.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop(locale) {
|
|
348
|
+
var localeData, manageClient, readClient, _loop2, modelId, _ret2;
|
|
349
|
+
|
|
350
|
+
return _regeneratorRuntime.wrap(function _loop$(_context5) {
|
|
351
|
+
while (1) {
|
|
352
|
+
switch (_context5.prev = _context5.next) {
|
|
353
|
+
case 0:
|
|
354
|
+
localeData = locales[locale];
|
|
355
|
+
manageClient = getManageClient(locale);
|
|
356
|
+
readClient = getReadClient(locale);
|
|
357
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2(modelId) {
|
|
358
|
+
var modelData, entries, mutation, _iterator2, _step2, _loop3, _ret3;
|
|
359
|
+
|
|
360
|
+
return _regeneratorRuntime.wrap(function _loop2$(_context4) {
|
|
361
|
+
while (1) {
|
|
362
|
+
switch (_context4.prev = _context4.next) {
|
|
363
|
+
case 0:
|
|
364
|
+
modelData = localeData[modelId];
|
|
365
|
+
/**
|
|
366
|
+
* This should never be true but let's check just in case of some missed loop breaks.
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
if (!(modelData.done || modelData.upgrading)) {
|
|
370
|
+
_context4.next = 3;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return _context4.abrupt("return", "continue");
|
|
375
|
+
|
|
376
|
+
case 3:
|
|
377
|
+
_context4.next = 5;
|
|
378
|
+
return fetchModelEntries({
|
|
379
|
+
model: modelData.model,
|
|
380
|
+
client: readClient
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
case 5:
|
|
384
|
+
entries = _context4.sent;
|
|
385
|
+
setUpgradeItems(function (previous) {
|
|
386
|
+
return _objectSpread(_objectSpread({}, previous), {}, {
|
|
387
|
+
locales: _objectSpread(_objectSpread({}, previous.locales), {}, _defineProperty({}, locale, _objectSpread(_objectSpread({}, previous.locales[locale]), {}, _defineProperty({}, modelId, {
|
|
388
|
+
model: modelData.model,
|
|
389
|
+
done: false,
|
|
390
|
+
upgrading: true,
|
|
391
|
+
entries: entries.map(function (id) {
|
|
392
|
+
return {
|
|
393
|
+
id: id,
|
|
394
|
+
done: false
|
|
395
|
+
};
|
|
396
|
+
})
|
|
397
|
+
}))))
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
mutation = createRepublishMutation(modelData.model);
|
|
401
|
+
_iterator2 = _createForOfIteratorHelper(entries);
|
|
402
|
+
_context4.prev = 9;
|
|
403
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3() {
|
|
404
|
+
var id, republishResponse, error;
|
|
405
|
+
return _regeneratorRuntime.wrap(function _loop3$(_context3) {
|
|
406
|
+
while (1) {
|
|
407
|
+
switch (_context3.prev = _context3.next) {
|
|
408
|
+
case 0:
|
|
409
|
+
id = _step2.value;
|
|
410
|
+
_context3.next = 3;
|
|
411
|
+
return manageClient.mutate({
|
|
412
|
+
mutation: mutation,
|
|
413
|
+
variables: {
|
|
414
|
+
revision: id
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
case 3:
|
|
419
|
+
republishResponse = _context3.sent;
|
|
420
|
+
error = republishResponse.data.content.error;
|
|
421
|
+
|
|
422
|
+
if (!error) {
|
|
423
|
+
_context3.next = 8;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
setError(error);
|
|
428
|
+
return _context3.abrupt("return", {
|
|
429
|
+
v: {
|
|
430
|
+
v: {
|
|
431
|
+
v: void 0
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
case 8:
|
|
437
|
+
setUpgradeItems(function (previous) {
|
|
438
|
+
return _objectSpread(_objectSpread({}, previous), {}, {
|
|
439
|
+
locales: _objectSpread(_objectSpread({}, previous.locales), {}, _defineProperty({}, locale, _objectSpread(_objectSpread({}, previous.locales[locale]), {}, _defineProperty({}, modelId, {
|
|
440
|
+
model: previous.locales[locale][modelId].model,
|
|
441
|
+
entries: previous.locales[locale][modelId].entries.map(function (info) {
|
|
442
|
+
return {
|
|
443
|
+
id: info.id,
|
|
444
|
+
done: info.done === true || id === info.id
|
|
445
|
+
};
|
|
446
|
+
}),
|
|
447
|
+
done: false,
|
|
448
|
+
upgrading: true
|
|
449
|
+
}))))
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
case 9:
|
|
454
|
+
case "end":
|
|
455
|
+
return _context3.stop();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}, _loop3);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
_iterator2.s();
|
|
462
|
+
|
|
463
|
+
case 12:
|
|
464
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
465
|
+
_context4.next = 19;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return _context4.delegateYield(_loop3(), "t0", 14);
|
|
470
|
+
|
|
471
|
+
case 14:
|
|
472
|
+
_ret3 = _context4.t0;
|
|
473
|
+
|
|
474
|
+
if (!(typeof _ret3 === "object")) {
|
|
475
|
+
_context4.next = 17;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return _context4.abrupt("return", _ret3.v);
|
|
480
|
+
|
|
481
|
+
case 17:
|
|
482
|
+
_context4.next = 12;
|
|
483
|
+
break;
|
|
484
|
+
|
|
485
|
+
case 19:
|
|
486
|
+
_context4.next = 24;
|
|
487
|
+
break;
|
|
488
|
+
|
|
489
|
+
case 21:
|
|
490
|
+
_context4.prev = 21;
|
|
491
|
+
_context4.t1 = _context4["catch"](9);
|
|
492
|
+
|
|
493
|
+
_iterator2.e(_context4.t1);
|
|
494
|
+
|
|
495
|
+
case 24:
|
|
496
|
+
_context4.prev = 24;
|
|
497
|
+
|
|
498
|
+
_iterator2.f();
|
|
499
|
+
|
|
500
|
+
return _context4.finish(24);
|
|
501
|
+
|
|
502
|
+
case 27:
|
|
503
|
+
setUpgradeItems(function (previous) {
|
|
504
|
+
return _objectSpread(_objectSpread({}, previous), {}, {
|
|
505
|
+
locales: _objectSpread(_objectSpread({}, previous.locales), {}, _defineProperty({}, locale, _objectSpread(_objectSpread({}, previous.locales[locale]), {}, _defineProperty({}, modelId, {
|
|
506
|
+
model: modelData.model,
|
|
507
|
+
entries: [],
|
|
508
|
+
done: true,
|
|
509
|
+
upgrading: false
|
|
510
|
+
}))))
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
case 28:
|
|
515
|
+
case "end":
|
|
516
|
+
return _context4.stop();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}, _loop2, null, [[9, 21, 24, 27]]);
|
|
520
|
+
});
|
|
521
|
+
_context5.t0 = _regeneratorRuntime.keys(localeData);
|
|
522
|
+
|
|
523
|
+
case 5:
|
|
524
|
+
if ((_context5.t1 = _context5.t0()).done) {
|
|
525
|
+
_context5.next = 15;
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
modelId = _context5.t1.value;
|
|
530
|
+
return _context5.delegateYield(_loop2(modelId), "t2", 8);
|
|
531
|
+
|
|
532
|
+
case 8:
|
|
533
|
+
_ret2 = _context5.t2;
|
|
534
|
+
|
|
535
|
+
if (!(_ret2 === "continue")) {
|
|
536
|
+
_context5.next = 11;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return _context5.abrupt("continue", 5);
|
|
541
|
+
|
|
542
|
+
case 11:
|
|
543
|
+
if (!(typeof _ret2 === "object")) {
|
|
544
|
+
_context5.next = 13;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return _context5.abrupt("return", _ret2.v);
|
|
549
|
+
|
|
550
|
+
case 13:
|
|
551
|
+
_context5.next = 5;
|
|
552
|
+
break;
|
|
553
|
+
|
|
554
|
+
case 15:
|
|
555
|
+
case "end":
|
|
556
|
+
return _context5.stop();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}, _loop);
|
|
560
|
+
});
|
|
561
|
+
_context6.t0 = _regeneratorRuntime.keys(locales);
|
|
562
|
+
|
|
563
|
+
case 2:
|
|
564
|
+
if ((_context6.t1 = _context6.t0()).done) {
|
|
565
|
+
_context6.next = 10;
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
locale = _context6.t1.value;
|
|
570
|
+
return _context6.delegateYield(_loop(locale), "t2", 5);
|
|
571
|
+
|
|
572
|
+
case 5:
|
|
573
|
+
_ret = _context6.t2;
|
|
574
|
+
|
|
575
|
+
if (!(typeof _ret === "object")) {
|
|
576
|
+
_context6.next = 8;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return _context6.abrupt("return", _ret.v);
|
|
581
|
+
|
|
582
|
+
case 8:
|
|
583
|
+
_context6.next = 2;
|
|
584
|
+
break;
|
|
585
|
+
|
|
586
|
+
case 10:
|
|
587
|
+
_context6.next = 12;
|
|
588
|
+
return client.mutate({
|
|
589
|
+
mutation: createUpgradeMutation(),
|
|
590
|
+
variables: {
|
|
591
|
+
version: "5.19.0"
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
case 12:
|
|
596
|
+
response = _context6.sent;
|
|
597
|
+
error = response.data.cms.upgrade.error;
|
|
598
|
+
setStatus("completed");
|
|
599
|
+
|
|
600
|
+
if (!error) {
|
|
601
|
+
_context6.next = 18;
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
setError(error);
|
|
606
|
+
return _context6.abrupt("return");
|
|
607
|
+
|
|
608
|
+
case 18:
|
|
609
|
+
onInstalled();
|
|
610
|
+
|
|
611
|
+
case 19:
|
|
612
|
+
case "end":
|
|
613
|
+
return _context6.stop();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}, _callee3);
|
|
617
|
+
}));
|
|
618
|
+
|
|
619
|
+
return function republish() {
|
|
620
|
+
return _ref5.apply(this, arguments);
|
|
621
|
+
};
|
|
622
|
+
}();
|
|
623
|
+
|
|
624
|
+
republish();
|
|
625
|
+
}, [upgrade, upgradeItems, status]);
|
|
626
|
+
var label = error ? /*#__PURE__*/React.createElement(Alert, {
|
|
627
|
+
title: t(_templateObject || (_templateObject = _taggedTemplateLiteral(["Something went wrong"]))),
|
|
628
|
+
type: "danger"
|
|
629
|
+
}, error.message) : upgrade ? t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Upgrading Headless CMS..."]))) : "Loading Headless CMS information";
|
|
630
|
+
return /*#__PURE__*/React.createElement(SimpleForm, null, (loading || error) && /*#__PURE__*/React.createElement(CircularProgress, {
|
|
631
|
+
label: label
|
|
632
|
+
}), /*#__PURE__*/React.createElement(SimpleFormHeader, {
|
|
633
|
+
title: "Upgrade Headless CMS"
|
|
634
|
+
}), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
635
|
+
span: 12
|
|
636
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
637
|
+
use: "body1",
|
|
638
|
+
tag: "div"
|
|
639
|
+
}, "This upgrade will do the following:", /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, "update entries")), /*#__PURE__*/React.createElement(UpgradeItemsInfo, {
|
|
640
|
+
upgradeItems: upgradeItems
|
|
641
|
+
}))))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, /*#__PURE__*/React.createElement(ButtonPrimary, {
|
|
642
|
+
disabled: loading || upgrade,
|
|
643
|
+
onClick: startUpgrade
|
|
644
|
+
}, "Upgrade")));
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
export default Upgrade;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms",
|
|
3
|
-
"version": "5.19.0-beta.
|
|
3
|
+
"version": "5.19.0-beta.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,22 +24,23 @@
|
|
|
24
24
|
"@fortawesome/react-fontawesome": "0.1.16",
|
|
25
25
|
"@svgr/webpack": "4.3.3",
|
|
26
26
|
"@types/react": "16.14.2",
|
|
27
|
-
"@webiny/app": "5.19.0-beta.
|
|
28
|
-
"@webiny/app-admin": "5.19.0-beta.
|
|
29
|
-
"@webiny/app-graphql-playground": "5.19.0-beta.
|
|
30
|
-
"@webiny/app-i18n": "5.19.0-beta.
|
|
31
|
-
"@webiny/app-plugin-admin-welcome-screen": "5.19.0-beta.
|
|
32
|
-
"@webiny/app-security": "5.19.0-beta.
|
|
33
|
-
"@webiny/error": "5.19.0-beta.
|
|
34
|
-
"@webiny/form": "5.19.0-beta.
|
|
35
|
-
"@webiny/plugins": "5.19.0-beta.
|
|
36
|
-
"@webiny/react-router": "5.19.0-beta.
|
|
37
|
-
"@webiny/ui": "5.19.0-beta.
|
|
38
|
-
"@webiny/utils": "5.19.0-beta.
|
|
39
|
-
"@webiny/validation": "5.19.0-beta.
|
|
27
|
+
"@webiny/app": "5.19.0-beta.5",
|
|
28
|
+
"@webiny/app-admin": "5.19.0-beta.5",
|
|
29
|
+
"@webiny/app-graphql-playground": "5.19.0-beta.5",
|
|
30
|
+
"@webiny/app-i18n": "5.19.0-beta.5",
|
|
31
|
+
"@webiny/app-plugin-admin-welcome-screen": "5.19.0-beta.5",
|
|
32
|
+
"@webiny/app-security": "5.19.0-beta.5",
|
|
33
|
+
"@webiny/error": "5.19.0-beta.5",
|
|
34
|
+
"@webiny/form": "5.19.0-beta.5",
|
|
35
|
+
"@webiny/plugins": "5.19.0-beta.5",
|
|
36
|
+
"@webiny/react-router": "5.19.0-beta.5",
|
|
37
|
+
"@webiny/ui": "5.19.0-beta.5",
|
|
38
|
+
"@webiny/utils": "5.19.0-beta.5",
|
|
39
|
+
"@webiny/validation": "5.19.0-beta.5",
|
|
40
40
|
"apollo-cache": "1.3.5",
|
|
41
41
|
"apollo-client": "2.6.10",
|
|
42
42
|
"apollo-link": "1.2.14",
|
|
43
|
+
"apollo-link-batch-http": "1.2.14",
|
|
43
44
|
"apollo-utilities": "1.3.4",
|
|
44
45
|
"classnames": "2.3.1",
|
|
45
46
|
"dot-prop-immutable": "2.1.1",
|
|
@@ -67,8 +68,8 @@
|
|
|
67
68
|
"@babel/preset-env": "^7.5.5",
|
|
68
69
|
"@babel/preset-react": "^7.0.0",
|
|
69
70
|
"@babel/preset-typescript": "^7.8.3",
|
|
70
|
-
"@webiny/cli": "^5.19.0-beta.
|
|
71
|
-
"@webiny/project-utils": "^5.19.0-beta.
|
|
71
|
+
"@webiny/cli": "^5.19.0-beta.5",
|
|
72
|
+
"@webiny/project-utils": "^5.19.0-beta.5",
|
|
72
73
|
"babel-plugin-emotion": "^9.2.8",
|
|
73
74
|
"babel-plugin-lodash": "^3.3.4",
|
|
74
75
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
@@ -106,5 +107,5 @@
|
|
|
106
107
|
]
|
|
107
108
|
}
|
|
108
109
|
},
|
|
109
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "839188911bbaee4a596724c729c0a78f681fa614"
|
|
110
111
|
}
|