@sanity/dashboard 2.26.0 → 2.26.1-purple-unicorn.677
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 +1 -1
- package/lib/{DashboardTool.js → cjs/DashboardTool.js} +3 -3
- package/lib/{components → cjs/components}/DashboardLayout.js +0 -0
- package/lib/{components → cjs/components}/NotFoundWidget.js +5 -3
- package/lib/{components → cjs/components}/WidgetGroup.js +14 -10
- package/lib/{components → cjs/components}/dashboardWidget.js +14 -10
- package/lib/{containers → cjs/containers}/Dashboard.js +1 -1
- package/lib/cjs/containers/WidgetContainer.js +52 -0
- package/lib/{dashboardConfig.js → cjs/dashboardConfig.js} +0 -0
- package/lib/{legacyParts.js → cjs/legacyParts.js} +6 -6
- package/lib/{versionedClient.js → cjs/versionedClient.js} +1 -1
- package/lib/{widget.css → cjs/widget.css} +0 -0
- package/lib/{widgets → cjs/widgets}/projectInfo/ProjectInfo.js +20 -16
- package/lib/{widgets → cjs/widgets}/projectInfo/index.js +0 -0
- package/lib/{widgets → cjs/widgets}/projectUsers/ProjectUsers.js +25 -19
- package/lib/{widgets → cjs/widgets}/projectUsers/index.js +0 -0
- package/lib/{widgets → cjs/widgets}/sanityTutorials/SanityTutorials.js +16 -9
- package/lib/{widgets → cjs/widgets}/sanityTutorials/Tutorial.js +15 -12
- package/lib/{widgets → cjs/widgets}/sanityTutorials/dataAdapter.js +2 -2
- package/lib/{widgets → cjs/widgets}/sanityTutorials/index.js +0 -0
- package/lib/esm/DashboardTool.js +33 -0
- package/lib/esm/components/DashboardLayout.js +23 -0
- package/lib/esm/components/NotFoundWidget.js +39 -0
- package/lib/esm/components/WidgetGroup.js +54 -0
- package/lib/esm/components/dashboardWidget.js +38 -0
- package/lib/esm/containers/Dashboard.js +19 -0
- package/lib/esm/containers/WidgetContainer.js +39 -0
- package/lib/esm/dashboardConfig.js +9 -0
- package/lib/esm/legacyParts.js +9 -0
- package/lib/esm/versionedClient.js +11 -0
- package/lib/esm/widget.css +62 -0
- package/lib/esm/widgets/projectInfo/ProjectInfo.js +254 -0
- package/lib/esm/widgets/projectInfo/index.js +8 -0
- package/lib/esm/widgets/projectUsers/ProjectUsers.js +174 -0
- package/lib/esm/widgets/projectUsers/index.js +5 -0
- package/lib/esm/widgets/sanityTutorials/SanityTutorials.js +108 -0
- package/lib/esm/widgets/sanityTutorials/Tutorial.js +98 -0
- package/lib/esm/widgets/sanityTutorials/dataAdapter.js +16 -0
- package/lib/esm/widgets/sanityTutorials/index.js +8 -0
- package/package.json +15 -11
- package/src/DashboardTool.js +32 -0
- package/src/components/DashboardLayout.js +22 -0
- package/src/components/NotFoundWidget.js +41 -0
- package/src/components/WidgetGroup.js +97 -0
- package/src/components/dashboardWidget.tsx +70 -0
- package/src/containers/Dashboard.js +20 -0
- package/src/containers/WidgetContainer.js +52 -0
- package/src/dashboardConfig.js +3 -0
- package/src/legacyParts.ts +11 -0
- package/src/versionedClient.js +9 -0
- package/src/widget.css +62 -0
- package/src/widgets/projectInfo/ProjectInfo.js +232 -0
- package/src/widgets/projectInfo/index.js +7 -0
- package/src/widgets/projectUsers/ProjectUsers.js +179 -0
- package/src/widgets/projectUsers/index.js +6 -0
- package/src/widgets/sanityTutorials/SanityTutorials.js +91 -0
- package/src/widgets/sanityTutorials/Tutorial.js +120 -0
- package/src/widgets/sanityTutorials/dataAdapter.js +17 -0
- package/src/widgets/sanityTutorials/index.js +7 -0
- package/.babelrc +0 -4
- package/lib/containers/WidgetContainer.js +0 -56
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
|
+
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Card, Stack, Heading, Box } from '@sanity/ui';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
const Root = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: stretch;\n height: 100%;\n"])));
|
|
10
|
+
|
|
11
|
+
function NotFoundWidget(props) {
|
|
12
|
+
const {
|
|
13
|
+
title,
|
|
14
|
+
children
|
|
15
|
+
} = props;
|
|
16
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
17
|
+
radius: 3,
|
|
18
|
+
paddingX: 3,
|
|
19
|
+
paddingY: 4,
|
|
20
|
+
tone: "critical"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
22
|
+
space: 2
|
|
23
|
+
}, title && /*#__PURE__*/React.createElement(Heading, {
|
|
24
|
+
size: 1,
|
|
25
|
+
as: "h2"
|
|
26
|
+
}, title), children && /*#__PURE__*/React.createElement(Box, null, children)));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
NotFoundWidget.propTypes = {
|
|
30
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
31
|
+
children: PropTypes.any,
|
|
32
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
33
|
+
title: PropTypes.any
|
|
34
|
+
};
|
|
35
|
+
NotFoundWidget.defaultProps = {
|
|
36
|
+
children: null,
|
|
37
|
+
title: null
|
|
38
|
+
};
|
|
39
|
+
export default NotFoundWidget;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
|
+
|
|
5
|
+
/* eslint-disable react/prop-types */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { Grid } from '@sanity/ui';
|
|
9
|
+
import { WidgetContainer } from '../legacyParts';
|
|
10
|
+
const media = {
|
|
11
|
+
small: function () {
|
|
12
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media (min-width: ", "px) {\n ", "\n }\n "])), _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref;
|
|
16
|
+
return theme.sanity.media[0];
|
|
17
|
+
}, css(...arguments));
|
|
18
|
+
},
|
|
19
|
+
medium: function () {
|
|
20
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (min-width: ", "px) {\n ", "\n }\n "])), _ref2 => {
|
|
21
|
+
let {
|
|
22
|
+
theme
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return theme.sanity.media[2];
|
|
25
|
+
}, css(...arguments));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const Root = styled(Grid)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));\n\n & > div {\n overflow: hidden;\n }\n\n & > div[data-width='medium'] {\n ", "\n }\n\n & > div[data-width='large'] {\n ", "\n\n ", "\n }\n\n & > div[data-width='full'] {\n ", "\n }\n\n & > div[data-height='medium'] {\n ", "\n }\n\n & > div[data-height='large'] {\n ", "\n\n ", "\n }\n\n & > div[data-height='full'] {\n ", "\n }\n"])), media.small(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n grid-column: span 2;\n "]))), media.small(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n grid-column: span 2;\n "]))), media.medium(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n grid-column: span 3;\n "]))), media.small(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n grid-column: 1 / -1;\n "]))), media.small(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n grid-row: span 2;\n "]))), media.small(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n grid-row: span 2;\n "]))), media.medium(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n grid-row: span 3;\n "]))), media.medium(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n grid-row: 1 / -1;\n "]))));
|
|
29
|
+
|
|
30
|
+
function WidgetGroup(props) {
|
|
31
|
+
const config = props.config || {};
|
|
32
|
+
const widgets = config.widgets || [];
|
|
33
|
+
const layout = config.layout || {};
|
|
34
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
35
|
+
autoFlow: "dense",
|
|
36
|
+
"data-width": layout.width || 'auto',
|
|
37
|
+
"data-height": layout.height || 'auto',
|
|
38
|
+
gap: 4
|
|
39
|
+
}, widgets.map((widgetConfig, index) => {
|
|
40
|
+
if (widgetConfig.type === '__experimental_group') {
|
|
41
|
+
return /*#__PURE__*/React.createElement(WidgetGroup, {
|
|
42
|
+
key: String(index),
|
|
43
|
+
config: widgetConfig
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(WidgetContainer, {
|
|
48
|
+
key: String(index),
|
|
49
|
+
config: widgetConfig
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default WidgetGroup;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
|
+
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
import { Card, Box, Heading } from '@sanity/ui';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
const Root = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: stretch;\n height: 100%;\n box-sizing: border-box;\n position: relative;\n"])));
|
|
9
|
+
const Header = styled(Card)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n z-index: 2;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n"])));
|
|
10
|
+
const Footer = styled(Card)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: sticky;\n overflow: hidden;\n bottom: 0;\n z-index: 2;\n border-bottom-right-radius: inherit;\n border-bottom-left-radius: inherit;\n margin-top: auto;\n"])));
|
|
11
|
+
const Content = styled(Box)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 1;\n height: stretch;\n min-height: 21.5em;\n\n @media (min-width: ", "px) {\n overflow-y: auto;\n outline: none;\n }\n"])), _ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
15
|
+
return theme.sanity.media[0];
|
|
16
|
+
});
|
|
17
|
+
export const DashboardWidget = /*#__PURE__*/forwardRef((props, ref) => {
|
|
18
|
+
const {
|
|
19
|
+
header,
|
|
20
|
+
children,
|
|
21
|
+
footer
|
|
22
|
+
} = props;
|
|
23
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
24
|
+
radius: 3,
|
|
25
|
+
display: "flex",
|
|
26
|
+
ref: ref
|
|
27
|
+
}, header && /*#__PURE__*/React.createElement(Header, {
|
|
28
|
+
borderBottom: true,
|
|
29
|
+
paddingX: 3,
|
|
30
|
+
paddingY: 4
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
32
|
+
size: 1,
|
|
33
|
+
textOverflow: "ellipsis"
|
|
34
|
+
}, header)), children && /*#__PURE__*/React.createElement(Content, null, children), footer && /*#__PURE__*/React.createElement(Footer, {
|
|
35
|
+
borderTop: true
|
|
36
|
+
}, footer));
|
|
37
|
+
});
|
|
38
|
+
DashboardWidget.displayName = 'DashboardWidget';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import DashboardLayout from '../components/DashboardLayout';
|
|
3
|
+
import WidgetGroup from '../components/WidgetGroup';
|
|
4
|
+
import { dashboardConfig } from '../legacyParts';
|
|
5
|
+
|
|
6
|
+
function Dashboard() {
|
|
7
|
+
if (!dashboardConfig) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const widgetConfigs = dashboardConfig.widgets || [];
|
|
12
|
+
return /*#__PURE__*/React.createElement(DashboardLayout, null, /*#__PURE__*/React.createElement(WidgetGroup, {
|
|
13
|
+
config: {
|
|
14
|
+
widgets: widgetConfigs
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default Dashboard;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import NotFoundWidget from '../components/NotFoundWidget';
|
|
4
|
+
import { definitions } from '../legacyParts';
|
|
5
|
+
|
|
6
|
+
function WidgetContainer(props) {
|
|
7
|
+
const config = props.config || {};
|
|
8
|
+
const definition = Array.isArray(definitions) ? definitions.find(wid => wid.name === config.name) : null;
|
|
9
|
+
|
|
10
|
+
if (definition) {
|
|
11
|
+
const options = { ...(definition.options || {}),
|
|
12
|
+
...(config.options || {})
|
|
13
|
+
};
|
|
14
|
+
const layout = { ...(definition.layout || {}),
|
|
15
|
+
...(config.layout || {})
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
"data-width": layout.width,
|
|
19
|
+
"data-height": layout.height
|
|
20
|
+
}, /*#__PURE__*/React.createElement(definition.component, options));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const layout = config.layout || {};
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
"data-width": layout.width,
|
|
26
|
+
"data-height": layout.height
|
|
27
|
+
}, /*#__PURE__*/React.createElement(NotFoundWidget, {
|
|
28
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, "Not found: \"", config.name, "\"")
|
|
29
|
+
}, /*#__PURE__*/React.createElement("p", null, "Make sure your ", /*#__PURE__*/React.createElement("code", null, "sanity.json"), " file mentions such a widget and that it\u2019s an implementation of ", /*#__PURE__*/React.createElement("code", null, "part:@sanity/dashboard/widget"), ".")));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
WidgetContainer.propTypes = {
|
|
33
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
34
|
+
config: PropTypes.any
|
|
35
|
+
};
|
|
36
|
+
WidgetContainer.defaultProps = {
|
|
37
|
+
config: null
|
|
38
|
+
};
|
|
39
|
+
export default WidgetContainer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @todo: remove the following line when part imports has been removed from this file
|
|
2
|
+
///<reference types="@sanity/types/parts" />
|
|
3
|
+
import WidgetContainer from 'part:@sanity/dashboard/widget-container';
|
|
4
|
+
import dashboardConfig from 'part:@sanity/dashboard/config?';
|
|
5
|
+
import sanityClient from 'part:@sanity/base/client';
|
|
6
|
+
import definitions from 'all:part:@sanity/dashboard/widget?';
|
|
7
|
+
import DefaultPreview from 'part:@sanity/components/previews/default';
|
|
8
|
+
import userStore from 'part:@sanity/base/user';
|
|
9
|
+
export { WidgetContainer, dashboardConfig, sanityClient, definitions, DefaultPreview, userStore };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@import 'part:@sanity/base/theme/variables-style';
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: stretch;
|
|
7
|
+
height: 100%;
|
|
8
|
+
border-radius: var(--border-radius-base);
|
|
9
|
+
background-color: var(--component-bg);
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.containerWithPadding {
|
|
15
|
+
composes: container;
|
|
16
|
+
padding: var(--medium-padding);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.header {
|
|
20
|
+
padding: var(--small-padding) 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.title {
|
|
24
|
+
composes: heading4 from 'part:@sanity/base/theme/typography/headings-style';
|
|
25
|
+
margin: var(--small-padding) var(--medium-padding);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.content {
|
|
29
|
+
display: block;
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
min-height: 21.5em;
|
|
33
|
+
|
|
34
|
+
@media (--screen-medium) {
|
|
35
|
+
height: stretch;
|
|
36
|
+
overflow-y: auto;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.footer {
|
|
41
|
+
display: flex;
|
|
42
|
+
text-align: center;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
min-height: 4em;
|
|
45
|
+
height: 4em;
|
|
46
|
+
margin-top: auto;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
|
|
49
|
+
@nest & > * {
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* TODO: remove after changing document list plugin */
|
|
55
|
+
.listContainer {
|
|
56
|
+
composes: content;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* TODO: remove after changing document list plugin */
|
|
60
|
+
.bottomButtonContainer {
|
|
61
|
+
composes: footer;
|
|
62
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import _isPlainObject from "lodash/isPlainObject";
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
/* eslint-disable react/forbid-prop-types, no-console */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { Box, Card, Stack, Heading, Grid, Label, Text, Code, Button } from '@sanity/ui';
|
|
9
|
+
import { versionedClient } from '../../versionedClient';
|
|
10
|
+
import { DashboardWidget } from '../../DashboardTool';
|
|
11
|
+
import { WidgetContainer } from '../../legacyParts';
|
|
12
|
+
const {
|
|
13
|
+
projectId,
|
|
14
|
+
dataset
|
|
15
|
+
} = versionedClient.config();
|
|
16
|
+
|
|
17
|
+
function isUrl(url) {
|
|
18
|
+
return /^https?:\/\//.test("".concat(url));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getGraphQlUrl() {
|
|
22
|
+
return "https://".concat(projectId, ".api.sanity.io/v1/graphql/").concat(dataset, "/default");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getGroqUrl() {
|
|
26
|
+
return "https://".concat(projectId, ".api.sanity.io/v1/groq/").concat(dataset);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getManageUrl() {
|
|
30
|
+
return "https://manage.sanity.io/projects/".concat(projectId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class ProjectInfo extends React.PureComponent {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "state", {
|
|
38
|
+
studioHost: null,
|
|
39
|
+
graphqlApi: null
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
componentDidMount() {
|
|
44
|
+
// fetch project data
|
|
45
|
+
this.subscriptions = [];
|
|
46
|
+
this.subscriptions.push(versionedClient.observable.request({
|
|
47
|
+
uri: "/projects/".concat(projectId)
|
|
48
|
+
}).subscribe({
|
|
49
|
+
next: result => {
|
|
50
|
+
const {
|
|
51
|
+
studioHost
|
|
52
|
+
} = result;
|
|
53
|
+
this.setState({
|
|
54
|
+
studioHost: studioHost ? "https://".concat(studioHost, ".sanity.studio") : null
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
error: error => {
|
|
58
|
+
console.log('Error while looking for studioHost', error);
|
|
59
|
+
this.setState({
|
|
60
|
+
studioHost: {
|
|
61
|
+
error: 'Something went wrong while looking up studioHost. See console.'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
})); // ping assumed graphql endpoint
|
|
66
|
+
|
|
67
|
+
this.subscriptions.push(versionedClient.observable.request({
|
|
68
|
+
method: 'HEAD',
|
|
69
|
+
uri: "/graphql/".concat(dataset, "/default")
|
|
70
|
+
}).subscribe({
|
|
71
|
+
next: () => this.setState({
|
|
72
|
+
graphqlApi: getGraphQlUrl()
|
|
73
|
+
}),
|
|
74
|
+
error: error => {
|
|
75
|
+
if (error.statusCode === 404) {
|
|
76
|
+
this.setState({
|
|
77
|
+
graphqlApi: null
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
console.log('Error while looking for graphqlApi', error);
|
|
81
|
+
this.setState({
|
|
82
|
+
graphqlApi: {
|
|
83
|
+
error: 'Something went wrong while looking up graphqlApi. See console.'
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
componentWillUnmount() {
|
|
92
|
+
this.subscriptions.forEach(sub => sub.unsubscribe());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
assembleTableRows() {
|
|
96
|
+
const {
|
|
97
|
+
graphqlApi,
|
|
98
|
+
studioHost
|
|
99
|
+
} = this.state;
|
|
100
|
+
const propsData = this.props.data;
|
|
101
|
+
let result = [{
|
|
102
|
+
title: 'Sanity project',
|
|
103
|
+
rows: [{
|
|
104
|
+
title: 'Project ID',
|
|
105
|
+
value: projectId
|
|
106
|
+
}, {
|
|
107
|
+
title: 'Dataset',
|
|
108
|
+
value: dataset
|
|
109
|
+
}]
|
|
110
|
+
}]; // Handle any apps
|
|
111
|
+
|
|
112
|
+
const apps = [studioHost ? {
|
|
113
|
+
title: 'Studio',
|
|
114
|
+
value: studioHost
|
|
115
|
+
} : null].concat(propsData.filter(item => item.category === 'apps')).filter(Boolean);
|
|
116
|
+
|
|
117
|
+
if (apps.length > 0) {
|
|
118
|
+
result = result.concat([{
|
|
119
|
+
title: 'Apps',
|
|
120
|
+
rows: apps
|
|
121
|
+
}]);
|
|
122
|
+
} // Handle APIs
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
result = result.concat([{
|
|
126
|
+
title: 'APIs',
|
|
127
|
+
rows: [{
|
|
128
|
+
title: 'GROQ',
|
|
129
|
+
value: getGroqUrl()
|
|
130
|
+
}, {
|
|
131
|
+
title: 'GraphQL',
|
|
132
|
+
value: graphqlApi || 'Not deployed'
|
|
133
|
+
}]
|
|
134
|
+
}], propsData.filter(item => item.category === 'apis')); // Handle whatever else there might be
|
|
135
|
+
|
|
136
|
+
const otherStuff = {};
|
|
137
|
+
propsData.forEach(item => {
|
|
138
|
+
if (item.category !== 'apps' && item.category !== 'apis') {
|
|
139
|
+
if (!otherStuff[item.category]) {
|
|
140
|
+
otherStuff[item.category] = [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
otherStuff[item.category].push(item);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.keys(otherStuff).forEach(category => {
|
|
147
|
+
result.push({
|
|
148
|
+
title: category,
|
|
149
|
+
rows: otherStuff[category]
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
render() {
|
|
156
|
+
var _this$props$__experim;
|
|
157
|
+
|
|
158
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.__experimental_before && this.props.__experimental_before.map((widgetConfig, idx) => /*#__PURE__*/React.createElement(WidgetContainer, {
|
|
159
|
+
key: String(idx),
|
|
160
|
+
config: widgetConfig
|
|
161
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
162
|
+
height: "fill",
|
|
163
|
+
marginTop: ((_this$props$__experim = this.props.__experimental_before) === null || _this$props$__experim === void 0 ? void 0 : _this$props$__experim.length) > 0 ? 4 : 0
|
|
164
|
+
}, /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
165
|
+
footer: /*#__PURE__*/React.createElement(Button, {
|
|
166
|
+
style: {
|
|
167
|
+
width: '100%'
|
|
168
|
+
},
|
|
169
|
+
paddingX: 2,
|
|
170
|
+
paddingY: 4,
|
|
171
|
+
mode: "bleed",
|
|
172
|
+
tone: "primary",
|
|
173
|
+
text: "Manage project",
|
|
174
|
+
as: "a",
|
|
175
|
+
href: getManageUrl()
|
|
176
|
+
})
|
|
177
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
178
|
+
paddingY: 4,
|
|
179
|
+
radius: 2,
|
|
180
|
+
role: "table",
|
|
181
|
+
"aria-label": "Project info",
|
|
182
|
+
"aria-describedby": "project_info_table"
|
|
183
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
184
|
+
space: 4
|
|
185
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
186
|
+
paddingX: 3,
|
|
187
|
+
as: "header"
|
|
188
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
189
|
+
size: 1,
|
|
190
|
+
as: "h2",
|
|
191
|
+
id: "project_info_table"
|
|
192
|
+
}, "Project info")), this.assembleTableRows().map(item => {
|
|
193
|
+
if (!item || !item.rows) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return /*#__PURE__*/React.createElement(Stack, {
|
|
198
|
+
key: item.title,
|
|
199
|
+
space: 3
|
|
200
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
201
|
+
borderBottom: true,
|
|
202
|
+
padding: 3
|
|
203
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
204
|
+
size: 0,
|
|
205
|
+
muted: true,
|
|
206
|
+
role: "columnheader"
|
|
207
|
+
}, item.title)), /*#__PURE__*/React.createElement(Stack, {
|
|
208
|
+
space: 4,
|
|
209
|
+
paddingX: 3,
|
|
210
|
+
role: "rowgroup"
|
|
211
|
+
}, item.rows.map(row => {
|
|
212
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
213
|
+
key: row.title,
|
|
214
|
+
columns: 2,
|
|
215
|
+
role: "row"
|
|
216
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
217
|
+
weight: "medium",
|
|
218
|
+
role: "rowheader"
|
|
219
|
+
}, row.title), _isPlainObject(row.value) && /*#__PURE__*/React.createElement(Text, {
|
|
220
|
+
size: 1
|
|
221
|
+
}, row.value.error), !_isPlainObject(row.value) && /*#__PURE__*/React.createElement(React.Fragment, null, isUrl(row.value) ? /*#__PURE__*/React.createElement(Text, {
|
|
222
|
+
size: 1,
|
|
223
|
+
role: "cell",
|
|
224
|
+
style: {
|
|
225
|
+
wordBreak: 'break-word'
|
|
226
|
+
}
|
|
227
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
228
|
+
href: row.value
|
|
229
|
+
}, row.value)) : /*#__PURE__*/React.createElement(Code, {
|
|
230
|
+
size: 1,
|
|
231
|
+
role: "cell",
|
|
232
|
+
style: {
|
|
233
|
+
wordBreak: 'break-word'
|
|
234
|
+
}
|
|
235
|
+
}, row.value)));
|
|
236
|
+
})));
|
|
237
|
+
}))))));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
_defineProperty(ProjectInfo, "propTypes", {
|
|
243
|
+
// eslint-disable-next-line camelcase
|
|
244
|
+
__experimental_before: PropTypes.array,
|
|
245
|
+
data: PropTypes.array
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
_defineProperty(ProjectInfo, "defaultProps", {
|
|
249
|
+
// eslint-disable-next-line camelcase
|
|
250
|
+
__experimental_before: [],
|
|
251
|
+
data: []
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export default ProjectInfo;
|