@sanity/dashboard 2.21.11-reference-updates.62 → 2.21.12-purple-unicorn.1300
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/lib/{DashboardTool.js → cjs/DashboardTool.js} +0 -0
- package/lib/{components → cjs/components}/DashboardLayout.js +0 -0
- package/lib/{components → cjs/components}/NotFoundWidget.js +0 -0
- package/lib/{components → cjs/components}/WidgetGroup.js +0 -0
- package/lib/{components → cjs/components}/dashboardWidget.js +0 -0
- package/lib/{containers → cjs/containers}/Dashboard.js +0 -0
- package/lib/{containers → cjs/containers}/WidgetContainer.js +2 -2
- package/lib/{dashboardConfig.js → cjs/dashboardConfig.js} +0 -0
- package/lib/{legacyParts.js → cjs/legacyParts.js} +8 -8
- package/lib/{versionedClient.js → cjs/versionedClient.js} +0 -0
- package/lib/{widget.css → cjs/widget.css} +0 -0
- package/lib/{widgets → cjs/widgets}/projectInfo/ProjectInfo.js +0 -0
- package/lib/{widgets → cjs/widgets}/projectInfo/index.js +0 -0
- package/lib/{widgets → cjs/widgets}/projectUsers/ProjectUsers.js +0 -0
- package/lib/{widgets → cjs/widgets}/projectUsers/index.js +0 -0
- package/lib/{widgets → cjs/widgets}/sanityTutorials/SanityTutorials.js +0 -0
- package/lib/{widgets → cjs/widgets}/sanityTutorials/Tutorial.js +0 -0
- package/lib/{widgets → cjs/widgets}/sanityTutorials/dataAdapter.js +0 -0
- 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 +37 -0
- package/lib/esm/components/WidgetGroup.js +50 -0
- package/lib/esm/components/dashboardWidget.js +34 -0
- package/lib/esm/containers/Dashboard.js +19 -0
- package/lib/esm/containers/WidgetContainer.js +43 -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 +251 -0
- package/lib/esm/widgets/projectInfo/index.js +8 -0
- package/lib/esm/widgets/projectUsers/ProjectUsers.js +169 -0
- package/lib/esm/widgets/projectUsers/index.js +5 -0
- package/lib/esm/widgets/sanityTutorials/SanityTutorials.js +101 -0
- package/lib/esm/widgets/sanityTutorials/Tutorial.js +95 -0
- package/lib/esm/widgets/sanityTutorials/dataAdapter.js +16 -0
- package/lib/esm/widgets/sanityTutorials/index.js +8 -0
- package/package.json +15 -10
- package/tsconfig.json +18 -16
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -15,9 +15,9 @@ var _legacyParts = require("../legacyParts");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
21
|
|
|
22
22
|
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; }
|
|
23
23
|
|
|
File without changes
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "DefaultPreview", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _default.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "WidgetContainer", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function get() {
|
|
15
|
-
return
|
|
15
|
+
return _widgetContainer.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "dashboardConfig", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return
|
|
21
|
+
return _config.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "definitions", {
|
|
@@ -27,10 +27,10 @@ Object.defineProperty(exports, "definitions", {
|
|
|
27
27
|
return _widget.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "sanityClient", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function get() {
|
|
33
|
-
return
|
|
33
|
+
return _client.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "userStore", {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Dashboard from './containers/Dashboard';
|
|
3
|
+
var strokeStyle = {
|
|
4
|
+
stroke: 'currentColor',
|
|
5
|
+
strokeWidth: 1.2
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
var DashboardIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
9
|
+
"data-sanity-icon": true,
|
|
10
|
+
viewBox: "0 0 25 25",
|
|
11
|
+
fill: "none",
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
preserveAspectRatio: "xMidYMid",
|
|
14
|
+
width: "1em",
|
|
15
|
+
height: "1em"
|
|
16
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
17
|
+
d: "M19.5 19.5H5.5V5.5H19.5V19.5Z",
|
|
18
|
+
style: strokeStyle
|
|
19
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
d: "M5.5 12.5H19.5",
|
|
21
|
+
style: strokeStyle
|
|
22
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
23
|
+
d: "M14.5 19.5V12.5M10.5 12.5V5.5",
|
|
24
|
+
style: strokeStyle
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
export * from './components/dashboardWidget';
|
|
28
|
+
export default {
|
|
29
|
+
title: 'Dashboard',
|
|
30
|
+
name: 'dashboard',
|
|
31
|
+
icon: DashboardIcon,
|
|
32
|
+
component: Dashboard
|
|
33
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Container } from '@sanity/ui';
|
|
4
|
+
|
|
5
|
+
function DashboardLayout(props) {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
7
|
+
width: 4,
|
|
8
|
+
padding: 4,
|
|
9
|
+
sizing: "border",
|
|
10
|
+
style: {
|
|
11
|
+
minHeight: '100%'
|
|
12
|
+
}
|
|
13
|
+
}, props.children);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
DashboardLayout.propTypes = {
|
|
17
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
18
|
+
children: PropTypes.any
|
|
19
|
+
};
|
|
20
|
+
DashboardLayout.defaultProps = {
|
|
21
|
+
children: 'Dummy'
|
|
22
|
+
};
|
|
23
|
+
export default DashboardLayout;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var 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
|
+
var title = props.title,
|
|
13
|
+
children = props.children;
|
|
14
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
15
|
+
radius: 3,
|
|
16
|
+
paddingX: 3,
|
|
17
|
+
paddingY: 4,
|
|
18
|
+
tone: "critical"
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
20
|
+
space: 2
|
|
21
|
+
}, title && /*#__PURE__*/React.createElement(Heading, {
|
|
22
|
+
size: 1,
|
|
23
|
+
as: "h2"
|
|
24
|
+
}, title), children && /*#__PURE__*/React.createElement(Box, null, children)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NotFoundWidget.propTypes = {
|
|
28
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
29
|
+
children: PropTypes.any,
|
|
30
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
31
|
+
title: PropTypes.any
|
|
32
|
+
};
|
|
33
|
+
NotFoundWidget.defaultProps = {
|
|
34
|
+
children: null,
|
|
35
|
+
title: null
|
|
36
|
+
};
|
|
37
|
+
export default NotFoundWidget;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
var media = {
|
|
11
|
+
small: function small() {
|
|
12
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media (min-width: ", "px) {\n ", "\n }\n "])), _ref => {
|
|
13
|
+
var theme = _ref.theme;
|
|
14
|
+
return theme.sanity.media[0];
|
|
15
|
+
}, css(...arguments));
|
|
16
|
+
},
|
|
17
|
+
medium: function medium() {
|
|
18
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (min-width: ", "px) {\n ", "\n }\n "])), _ref2 => {
|
|
19
|
+
var theme = _ref2.theme;
|
|
20
|
+
return theme.sanity.media[2];
|
|
21
|
+
}, css(...arguments));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var 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 "]))));
|
|
25
|
+
|
|
26
|
+
function WidgetGroup(props) {
|
|
27
|
+
var config = props.config || {};
|
|
28
|
+
var widgets = config.widgets || [];
|
|
29
|
+
var layout = config.layout || {};
|
|
30
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
31
|
+
autoFlow: "dense",
|
|
32
|
+
"data-width": layout.width || 'auto',
|
|
33
|
+
"data-height": layout.height || 'auto',
|
|
34
|
+
gap: 4
|
|
35
|
+
}, widgets.map((widgetConfig, index) => {
|
|
36
|
+
if (widgetConfig.type === '__experimental_group') {
|
|
37
|
+
return /*#__PURE__*/React.createElement(WidgetGroup, {
|
|
38
|
+
key: String(index),
|
|
39
|
+
config: widgetConfig
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(WidgetContainer, {
|
|
44
|
+
key: String(index),
|
|
45
|
+
config: widgetConfig
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default WidgetGroup;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
var 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
|
+
var 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
|
+
var 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
|
+
var 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
|
+
var theme = _ref.theme;
|
|
13
|
+
return theme.sanity.media[0];
|
|
14
|
+
});
|
|
15
|
+
export var DashboardWidget = /*#__PURE__*/forwardRef((props, ref) => {
|
|
16
|
+
var header = props.header,
|
|
17
|
+
children = props.children,
|
|
18
|
+
footer = props.footer;
|
|
19
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
20
|
+
radius: 3,
|
|
21
|
+
display: "flex",
|
|
22
|
+
ref: ref
|
|
23
|
+
}, header && /*#__PURE__*/React.createElement(Header, {
|
|
24
|
+
borderBottom: true,
|
|
25
|
+
paddingX: 3,
|
|
26
|
+
paddingY: 4
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
28
|
+
size: 1,
|
|
29
|
+
textOverflow: "ellipsis"
|
|
30
|
+
}, header)), children && /*#__PURE__*/React.createElement(Content, null, children), footer && /*#__PURE__*/React.createElement(Footer, {
|
|
31
|
+
borderTop: true
|
|
32
|
+
}, footer));
|
|
33
|
+
});
|
|
34
|
+
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
|
+
var 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,43 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import NotFoundWidget from '../components/NotFoundWidget';
|
|
10
|
+
import { definitions } from '../legacyParts';
|
|
11
|
+
|
|
12
|
+
function WidgetContainer(props) {
|
|
13
|
+
var config = props.config || {};
|
|
14
|
+
var definition = Array.isArray(definitions) ? definitions.find(wid => wid.name === config.name) : null;
|
|
15
|
+
|
|
16
|
+
if (definition) {
|
|
17
|
+
var options = _objectSpread(_objectSpread({}, definition.options || {}), config.options || {});
|
|
18
|
+
|
|
19
|
+
var _layout = _objectSpread(_objectSpread({}, definition.layout || {}), config.layout || {});
|
|
20
|
+
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
"data-width": _layout.width,
|
|
23
|
+
"data-height": _layout.height
|
|
24
|
+
}, /*#__PURE__*/React.createElement(definition.component, options));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var layout = config.layout || {};
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
"data-width": layout.width,
|
|
30
|
+
"data-height": layout.height
|
|
31
|
+
}, /*#__PURE__*/React.createElement(NotFoundWidget, {
|
|
32
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, "Not found: \"", config.name, "\"")
|
|
33
|
+
}, /*#__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"), ".")));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
WidgetContainer.propTypes = {
|
|
37
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
38
|
+
config: PropTypes.any
|
|
39
|
+
};
|
|
40
|
+
WidgetContainer.defaultProps = {
|
|
41
|
+
config: null
|
|
42
|
+
};
|
|
43
|
+
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,251 @@
|
|
|
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
|
+
|
|
13
|
+
var _versionedClient$conf = versionedClient.config(),
|
|
14
|
+
projectId = _versionedClient$conf.projectId,
|
|
15
|
+
dataset = _versionedClient$conf.dataset;
|
|
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
|
+
var studioHost = result.studioHost;
|
|
51
|
+
this.setState({
|
|
52
|
+
studioHost: studioHost ? "https://".concat(studioHost, ".sanity.studio") : null
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
error: _error => {
|
|
56
|
+
console.log('Error while looking for studioHost', _error);
|
|
57
|
+
this.setState({
|
|
58
|
+
studioHost: {
|
|
59
|
+
error: 'Something went wrong while looking up studioHost. See console.'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
})); // ping assumed graphql endpoint
|
|
64
|
+
|
|
65
|
+
this.subscriptions.push(versionedClient.observable.request({
|
|
66
|
+
method: 'HEAD',
|
|
67
|
+
uri: "/graphql/".concat(dataset, "/default")
|
|
68
|
+
}).subscribe({
|
|
69
|
+
next: () => this.setState({
|
|
70
|
+
graphqlApi: getGraphQlUrl()
|
|
71
|
+
}),
|
|
72
|
+
error: _error2 => {
|
|
73
|
+
if (_error2.statusCode === 404) {
|
|
74
|
+
this.setState({
|
|
75
|
+
graphqlApi: null
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
console.log('Error while looking for graphqlApi', _error2);
|
|
79
|
+
this.setState({
|
|
80
|
+
graphqlApi: {
|
|
81
|
+
error: 'Something went wrong while looking up graphqlApi. See console.'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
componentWillUnmount() {
|
|
90
|
+
this.subscriptions.forEach(sub => sub.unsubscribe());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
assembleTableRows() {
|
|
94
|
+
var _this$state = this.state,
|
|
95
|
+
graphqlApi = _this$state.graphqlApi,
|
|
96
|
+
studioHost = _this$state.studioHost;
|
|
97
|
+
var propsData = this.props.data;
|
|
98
|
+
var result = [{
|
|
99
|
+
title: 'Sanity project',
|
|
100
|
+
rows: [{
|
|
101
|
+
title: 'Project ID',
|
|
102
|
+
value: projectId
|
|
103
|
+
}, {
|
|
104
|
+
title: 'Dataset',
|
|
105
|
+
value: dataset
|
|
106
|
+
}]
|
|
107
|
+
}]; // Handle any apps
|
|
108
|
+
|
|
109
|
+
var apps = [studioHost ? {
|
|
110
|
+
title: 'Studio',
|
|
111
|
+
value: studioHost
|
|
112
|
+
} : null].concat(propsData.filter(item => item.category === 'apps')).filter(Boolean);
|
|
113
|
+
|
|
114
|
+
if (apps.length > 0) {
|
|
115
|
+
result = result.concat([{
|
|
116
|
+
title: 'Apps',
|
|
117
|
+
rows: apps
|
|
118
|
+
}]);
|
|
119
|
+
} // Handle APIs
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
result = result.concat([{
|
|
123
|
+
title: 'APIs',
|
|
124
|
+
rows: [{
|
|
125
|
+
title: 'GROQ',
|
|
126
|
+
value: getGroqUrl()
|
|
127
|
+
}, {
|
|
128
|
+
title: 'GraphQL',
|
|
129
|
+
value: graphqlApi || 'Not deployed'
|
|
130
|
+
}]
|
|
131
|
+
}], propsData.filter(item => item.category === 'apis')); // Handle whatever else there might be
|
|
132
|
+
|
|
133
|
+
var otherStuff = {};
|
|
134
|
+
propsData.forEach(item => {
|
|
135
|
+
if (item.category !== 'apps' && item.category !== 'apis') {
|
|
136
|
+
if (!otherStuff[item.category]) {
|
|
137
|
+
otherStuff[item.category] = [];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
otherStuff[item.category].push(item);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.keys(otherStuff).forEach(category => {
|
|
144
|
+
result.push({
|
|
145
|
+
title: category,
|
|
146
|
+
rows: otherStuff[category]
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
render() {
|
|
153
|
+
var _this$props$__experim;
|
|
154
|
+
|
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.__experimental_before && this.props.__experimental_before.map((widgetConfig, idx) => /*#__PURE__*/React.createElement(WidgetContainer, {
|
|
156
|
+
key: String(idx),
|
|
157
|
+
config: widgetConfig
|
|
158
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
159
|
+
height: "fill",
|
|
160
|
+
marginTop: ((_this$props$__experim = this.props.__experimental_before) === null || _this$props$__experim === void 0 ? void 0 : _this$props$__experim.length) > 0 ? 4 : 0
|
|
161
|
+
}, /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
162
|
+
footer: /*#__PURE__*/React.createElement(Button, {
|
|
163
|
+
style: {
|
|
164
|
+
width: '100%'
|
|
165
|
+
},
|
|
166
|
+
paddingX: 2,
|
|
167
|
+
paddingY: 4,
|
|
168
|
+
mode: "bleed",
|
|
169
|
+
tone: "primary",
|
|
170
|
+
text: "Manage project",
|
|
171
|
+
as: "a",
|
|
172
|
+
href: getManageUrl()
|
|
173
|
+
})
|
|
174
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
175
|
+
paddingY: 4,
|
|
176
|
+
radius: 2,
|
|
177
|
+
role: "table",
|
|
178
|
+
"aria-label": "Project info",
|
|
179
|
+
"aria-describedby": "project_info_table"
|
|
180
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
181
|
+
space: 4
|
|
182
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
183
|
+
paddingX: 3,
|
|
184
|
+
as: "header"
|
|
185
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
186
|
+
size: 1,
|
|
187
|
+
as: "h2",
|
|
188
|
+
id: "project_info_table"
|
|
189
|
+
}, "Project info")), this.assembleTableRows().map(item => {
|
|
190
|
+
if (!item || !item.rows) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return /*#__PURE__*/React.createElement(Stack, {
|
|
195
|
+
key: item.title,
|
|
196
|
+
space: 3
|
|
197
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
198
|
+
borderBottom: true,
|
|
199
|
+
padding: 3
|
|
200
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
201
|
+
size: 0,
|
|
202
|
+
muted: true,
|
|
203
|
+
role: "columnheader"
|
|
204
|
+
}, item.title)), /*#__PURE__*/React.createElement(Stack, {
|
|
205
|
+
space: 4,
|
|
206
|
+
paddingX: 3,
|
|
207
|
+
role: "rowgroup"
|
|
208
|
+
}, item.rows.map(row => {
|
|
209
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
210
|
+
key: row.title,
|
|
211
|
+
columns: 2,
|
|
212
|
+
role: "row"
|
|
213
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
214
|
+
weight: "medium",
|
|
215
|
+
role: "rowheader"
|
|
216
|
+
}, row.title), _isPlainObject(row.value) && /*#__PURE__*/React.createElement(Text, {
|
|
217
|
+
size: 1
|
|
218
|
+
}, row.value.error), !_isPlainObject(row.value) && /*#__PURE__*/React.createElement(React.Fragment, null, isUrl(row.value) ? /*#__PURE__*/React.createElement(Text, {
|
|
219
|
+
size: 1,
|
|
220
|
+
role: "cell",
|
|
221
|
+
style: {
|
|
222
|
+
wordBreak: 'break-word'
|
|
223
|
+
}
|
|
224
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
225
|
+
href: row.value
|
|
226
|
+
}, row.value)) : /*#__PURE__*/React.createElement(Code, {
|
|
227
|
+
size: 1,
|
|
228
|
+
role: "cell",
|
|
229
|
+
style: {
|
|
230
|
+
wordBreak: 'break-word'
|
|
231
|
+
}
|
|
232
|
+
}, row.value)));
|
|
233
|
+
})));
|
|
234
|
+
}))))));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
_defineProperty(ProjectInfo, "propTypes", {
|
|
240
|
+
// eslint-disable-next-line camelcase
|
|
241
|
+
__experimental_before: PropTypes.array,
|
|
242
|
+
data: PropTypes.array
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
_defineProperty(ProjectInfo, "defaultProps", {
|
|
246
|
+
// eslint-disable-next-line camelcase
|
|
247
|
+
__experimental_before: [],
|
|
248
|
+
data: []
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
export default ProjectInfo;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var _templateObject;
|
|
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
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { map, switchMap } from 'rxjs/operators';
|
|
9
|
+
import { Stack, Spinner, Card, Box, Text, Button } from '@sanity/ui';
|
|
10
|
+
import { RobotIcon } from '@sanity/icons';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
import { DefaultPreview } from '@sanity/base/components';
|
|
13
|
+
import { versionedClient } from '../../versionedClient';
|
|
14
|
+
import { DashboardWidget } from '../../DashboardTool';
|
|
15
|
+
import { userStore } from '../../legacyParts';
|
|
16
|
+
var AvatarWrapper = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n box-sizing: border-box;\n border-radius: 50%;\n border-color: transparent;\n overflow: hidden;\n width: 100%;\n height: 100%;\n\n & > img {\n width: 100%;\n height: auto;\n }\n"])));
|
|
17
|
+
|
|
18
|
+
function getInviteUrl(projectId) {
|
|
19
|
+
return "https://manage.sanity.io/projects/".concat(projectId, "/team/invite");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function sortUsersByRobotStatus(userA, userB, project) {
|
|
23
|
+
var members = project.members;
|
|
24
|
+
var membershipA = members.find(member => member.id === userA.id);
|
|
25
|
+
var membershipB = members.find(member => member.id === userB.id);
|
|
26
|
+
|
|
27
|
+
if (membershipA.isRobot) {
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (membershipB.isRobot) {
|
|
32
|
+
return -1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class ProjectUsers extends React.PureComponent {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "state", {
|
|
43
|
+
project: null,
|
|
44
|
+
users: null,
|
|
45
|
+
error: null
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
_defineProperty(this, "handleRetryFetch", () => {
|
|
49
|
+
this.fetchData();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
componentDidMount() {
|
|
54
|
+
this.fetchData();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
componentWillUnmount() {
|
|
58
|
+
if (this.subscription) {
|
|
59
|
+
this.subscription.unsubscribe();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fetchData() {
|
|
64
|
+
if (this.subscription) {
|
|
65
|
+
this.subscription.unsubscribe();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var _versionedClient$conf = versionedClient.config(),
|
|
69
|
+
projectId = _versionedClient$conf.projectId;
|
|
70
|
+
|
|
71
|
+
this.subscription = versionedClient.observable.request({
|
|
72
|
+
uri: "/projects/".concat(projectId)
|
|
73
|
+
}).pipe(switchMap(project => userStore.observable.getUsers(project.members.map(mem => mem.id)).pipe(map(users => ({
|
|
74
|
+
project,
|
|
75
|
+
users
|
|
76
|
+
}))))).subscribe({
|
|
77
|
+
next: _ref => {
|
|
78
|
+
var users = _ref.users,
|
|
79
|
+
project = _ref.project;
|
|
80
|
+
return this.setState({
|
|
81
|
+
project,
|
|
82
|
+
users: (Array.isArray(users) ? users : [users]).sort((userA, userB) => sortUsersByRobotStatus(userA, userB, project))
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
error: _error => this.setState({
|
|
86
|
+
error: _error
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
var _this$state = this.state,
|
|
93
|
+
error = _this$state.error,
|
|
94
|
+
project = _this$state.project,
|
|
95
|
+
users = _this$state.users;
|
|
96
|
+
var isLoading = !users || !project;
|
|
97
|
+
|
|
98
|
+
if (error) {
|
|
99
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
100
|
+
header: "Project users"
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
102
|
+
padding: 4
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Text, null, "Something went wrong while fetching data. You could", ' ', /*#__PURE__*/React.createElement("a", {
|
|
104
|
+
onClick: this.handleRetryFetch,
|
|
105
|
+
title: "Retry users fetch",
|
|
106
|
+
style: {
|
|
107
|
+
cursor: 'pointer'
|
|
108
|
+
}
|
|
109
|
+
}, "retry"), "..?")));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
113
|
+
header: "Project users",
|
|
114
|
+
footer: /*#__PURE__*/React.createElement(Button, {
|
|
115
|
+
style: {
|
|
116
|
+
width: '100%'
|
|
117
|
+
},
|
|
118
|
+
paddingX: 2,
|
|
119
|
+
paddingY: 4,
|
|
120
|
+
mode: "bleed",
|
|
121
|
+
tone: "primary",
|
|
122
|
+
text: "Invite members",
|
|
123
|
+
as: "a",
|
|
124
|
+
loading: isLoading,
|
|
125
|
+
href: isLoading ? undefined : getInviteUrl(project.id)
|
|
126
|
+
})
|
|
127
|
+
}, isLoading && /*#__PURE__*/React.createElement(Box, {
|
|
128
|
+
paddingY: 5,
|
|
129
|
+
paddingX: 2
|
|
130
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
131
|
+
space: 4
|
|
132
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
133
|
+
align: "center",
|
|
134
|
+
muted: true,
|
|
135
|
+
size: 1
|
|
136
|
+
}, /*#__PURE__*/React.createElement(Spinner, null)), /*#__PURE__*/React.createElement(Text, {
|
|
137
|
+
align: "center",
|
|
138
|
+
size: 1,
|
|
139
|
+
muted: true
|
|
140
|
+
}, "Loading items..."))), !isLoading && /*#__PURE__*/React.createElement(Stack, {
|
|
141
|
+
space: 3,
|
|
142
|
+
padding: 3
|
|
143
|
+
}, users.map(user => {
|
|
144
|
+
var membership = project.members.find(member => member.id === user.id);
|
|
145
|
+
var media = membership.isRobot ? /*#__PURE__*/React.createElement(Text, {
|
|
146
|
+
size: 3
|
|
147
|
+
}, /*#__PURE__*/React.createElement(RobotIcon, null)) : /*#__PURE__*/React.createElement(AvatarWrapper, {
|
|
148
|
+
tone: "transparent"
|
|
149
|
+
}, (user === null || user === void 0 ? void 0 : user.imageUrl) && /*#__PURE__*/React.createElement("img", {
|
|
150
|
+
src: user.imageUrl,
|
|
151
|
+
alt: user === null || user === void 0 ? void 0 : user.displayName
|
|
152
|
+
}));
|
|
153
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
154
|
+
key: user.id
|
|
155
|
+
}, /*#__PURE__*/React.createElement(DefaultPreview, {
|
|
156
|
+
title: user.displayName,
|
|
157
|
+
subtitle: membership.role,
|
|
158
|
+
media: media
|
|
159
|
+
}));
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_defineProperty(ProjectUsers, "propTypes", {});
|
|
166
|
+
|
|
167
|
+
_defineProperty(ProjectUsers, "defaultProps", {});
|
|
168
|
+
|
|
169
|
+
export default ProjectUsers;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _get from "lodash/get";
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { Flex } from '@sanity/ui';
|
|
8
|
+
import { DashboardWidget } from '../../DashboardTool';
|
|
9
|
+
import Tutorial from './Tutorial';
|
|
10
|
+
import dataAdapter from './dataAdapter';
|
|
11
|
+
var urlBuilder = dataAdapter.urlBuilder,
|
|
12
|
+
getFeed = dataAdapter.getFeed;
|
|
13
|
+
|
|
14
|
+
function createUrl(slug, type) {
|
|
15
|
+
if (type === 'tutorial') {
|
|
16
|
+
return "https://www.sanity.io/docs/tutorials/".concat(slug.current);
|
|
17
|
+
} else if (type === 'guide') {
|
|
18
|
+
return "https://www.sanity.io/docs/guides/".concat(slug.current);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class SanityTutorials extends React.Component {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "state", {
|
|
29
|
+
feedItems: []
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
componentDidMount() {
|
|
34
|
+
var templateRepoId = this.props.templateRepoId;
|
|
35
|
+
this.subscription = getFeed(templateRepoId).subscribe(response => {
|
|
36
|
+
this.setState({
|
|
37
|
+
feedItems: response.items
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
componentWillUnmount() {
|
|
43
|
+
if (this.subscription) {
|
|
44
|
+
this.subscription.unsubscribe();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
render() {
|
|
49
|
+
var feedItems = this.state.feedItems;
|
|
50
|
+
var title = 'Learn about Sanity';
|
|
51
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
52
|
+
header: title
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
|
54
|
+
as: "ul",
|
|
55
|
+
overflow: "auto",
|
|
56
|
+
align: "stretch",
|
|
57
|
+
paddingY: 2
|
|
58
|
+
}, feedItems === null || feedItems === void 0 ? void 0 : feedItems.map((feedItem, index) => {
|
|
59
|
+
if (!feedItem.title || !feedItem.guideOrTutorial && !feedItem.externalLink) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var presenter = feedItem.presenter || _get(feedItem, 'guideOrTutorial.presenter') || {};
|
|
64
|
+
|
|
65
|
+
var subtitle = _get(feedItem, 'category');
|
|
66
|
+
|
|
67
|
+
var _feedItem$guideOrTuto = feedItem.guideOrTutorial,
|
|
68
|
+
guideOrTutorial = _feedItem$guideOrTuto === void 0 ? {} : _feedItem$guideOrTuto;
|
|
69
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
70
|
+
as: "li",
|
|
71
|
+
key: feedItem._id,
|
|
72
|
+
paddingRight: index < (feedItems === null || feedItems === void 0 ? void 0 : feedItems.length) - 1 ? 1 : 3,
|
|
73
|
+
paddingLeft: index === 0 ? 3 : 0,
|
|
74
|
+
align: "stretch",
|
|
75
|
+
flex: "0 0 27.5%",
|
|
76
|
+
style: {
|
|
77
|
+
minWidth: 272,
|
|
78
|
+
width: '30%'
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Tutorial, {
|
|
81
|
+
title: feedItem.title,
|
|
82
|
+
href: createUrl(guideOrTutorial.slug, guideOrTutorial._type) || feedItem.externalLink,
|
|
83
|
+
presenterName: presenter.name,
|
|
84
|
+
presenterSubtitle: subtitle,
|
|
85
|
+
showPlayIcon: feedItem.hasVideo,
|
|
86
|
+
posterURL: urlBuilder.image(feedItem.poster).height(360).url()
|
|
87
|
+
}));
|
|
88
|
+
})));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_defineProperty(SanityTutorials, "propTypes", {
|
|
94
|
+
templateRepoId: PropTypes.string
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
_defineProperty(SanityTutorials, "defaultProps", {
|
|
98
|
+
templateRepoId: null
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export default SanityTutorials;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
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
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { Card, Box, Heading, Flex, Text, Stack } from '@sanity/ui';
|
|
10
|
+
import { PlayIcon } from '@sanity/icons';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
var PlayIconBox = styled(Box)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n\n &:before {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 2.75em;\n height: 2.75em;\n border-radius: 50%;\n background: ", ";\n opacity: 0.75;\n }\n"])), _ref => {
|
|
13
|
+
var theme = _ref.theme;
|
|
14
|
+
return theme.sanity.color.card.enabled.bg;
|
|
15
|
+
});
|
|
16
|
+
var Root = styled(Flex)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &:hover {\n ", " {\n &:before {\n opacity: 1;\n }\n }\n }\n"])), PlayIconBox);
|
|
17
|
+
var PosterCard = styled(Card)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n padding-bottom: calc(9 / 16 * 100%);\n position: relative;\n"])));
|
|
18
|
+
var Poster = styled.img(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n object-fit: cover;\n display: block;\n\n &:not([src]) {\n display: none;\n }\n"])));
|
|
19
|
+
|
|
20
|
+
class Tutorial extends React.PureComponent {
|
|
21
|
+
render() {
|
|
22
|
+
var _this$props = this.props,
|
|
23
|
+
title = _this$props.title,
|
|
24
|
+
posterURL = _this$props.posterURL,
|
|
25
|
+
showPlayIcon = _this$props.showPlayIcon,
|
|
26
|
+
href = _this$props.href,
|
|
27
|
+
presenterName = _this$props.presenterName,
|
|
28
|
+
presenterSubtitle = _this$props.presenterSubtitle;
|
|
29
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
30
|
+
flex: 1
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
32
|
+
sizing: "border",
|
|
33
|
+
flex: 1,
|
|
34
|
+
padding: 2,
|
|
35
|
+
radius: 2,
|
|
36
|
+
as: "a",
|
|
37
|
+
href: href,
|
|
38
|
+
target: "_blank",
|
|
39
|
+
rel: "noopener noreferrer",
|
|
40
|
+
style: {
|
|
41
|
+
position: 'relative'
|
|
42
|
+
}
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
|
44
|
+
direction: "column",
|
|
45
|
+
style: {
|
|
46
|
+
height: '100%'
|
|
47
|
+
}
|
|
48
|
+
}, posterURL && /*#__PURE__*/React.createElement(PosterCard, {
|
|
49
|
+
marginBottom: 1
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Poster, {
|
|
51
|
+
src: posterURL
|
|
52
|
+
}), showPlayIcon && /*#__PURE__*/React.createElement(PlayIconBox, {
|
|
53
|
+
display: "flex"
|
|
54
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
55
|
+
align: "center"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(PlayIcon, null)))), /*#__PURE__*/React.createElement(Flex, {
|
|
57
|
+
direction: "column",
|
|
58
|
+
justify: "space-between",
|
|
59
|
+
paddingY: 2,
|
|
60
|
+
flex: 1
|
|
61
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
62
|
+
as: "h3",
|
|
63
|
+
size: 1
|
|
64
|
+
}, title), /*#__PURE__*/React.createElement(Box, {
|
|
65
|
+
marginTop: 4
|
|
66
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
67
|
+
space: 2,
|
|
68
|
+
flex: 1
|
|
69
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
70
|
+
size: 1
|
|
71
|
+
}, presenterName), /*#__PURE__*/React.createElement(Text, {
|
|
72
|
+
size: 0,
|
|
73
|
+
style: {
|
|
74
|
+
opacity: 0.7
|
|
75
|
+
}
|
|
76
|
+
}, presenterSubtitle)))))));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_defineProperty(Tutorial, "propTypes", {
|
|
82
|
+
title: PropTypes.string.isRequired,
|
|
83
|
+
posterURL: PropTypes.string,
|
|
84
|
+
href: PropTypes.string.isRequired,
|
|
85
|
+
showPlayIcon: PropTypes.bool,
|
|
86
|
+
presenterName: PropTypes.string.isRequired,
|
|
87
|
+
presenterSubtitle: PropTypes.string.isRequired
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
_defineProperty(Tutorial, "defaultProps", {
|
|
91
|
+
posterURL: null,
|
|
92
|
+
showPlayIcon: false
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export default Tutorial;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import imageUrlBuilder from '@sanity/image-url';
|
|
2
|
+
import { versionedClient } from '../../versionedClient';
|
|
3
|
+
var tutorialsProjectConfig = {
|
|
4
|
+
projectId: '3do82whm',
|
|
5
|
+
dataset: 'next'
|
|
6
|
+
};
|
|
7
|
+
export default {
|
|
8
|
+
getFeed: templateRepoId => {
|
|
9
|
+
var uri = templateRepoId ? "/addons/dashboard?templateRepoId=".concat(templateRepoId) : '/addons/dashboard';
|
|
10
|
+
return versionedClient.observable.request({
|
|
11
|
+
uri,
|
|
12
|
+
withCredentials: false
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
urlBuilder: imageUrlBuilder(tutorialsProjectConfig)
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/dashboard",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.12-purple-unicorn.1300+abdd014728",
|
|
4
4
|
"description": "Tool for rendering dashboard widgets",
|
|
5
|
-
"main": "./lib/DashboardTool.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "./lib/cjs/DashboardTool.js",
|
|
6
|
+
"module": "./lib/esm/DashboardTool.js",
|
|
7
|
+
"types": "./lib/dts/src/DashboardTool.d.ts",
|
|
7
8
|
"author": "Sanity.io <hello@sanity.io>",
|
|
8
9
|
"license": "MIT",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
+
"build": "../../../bin/pkg-utils transpile",
|
|
12
|
+
"clean": "rimraf lib",
|
|
13
|
+
"prebuild": "yarn clean",
|
|
14
|
+
"watch": "../../../bin/pkg-utils transpile --watch"
|
|
11
15
|
},
|
|
12
16
|
"keywords": [
|
|
13
17
|
"sanity",
|
|
@@ -22,15 +26,16 @@
|
|
|
22
26
|
"dependencies": {
|
|
23
27
|
"@sanity/icons": "^1.2.1",
|
|
24
28
|
"@sanity/image-url": "^1.0.1",
|
|
25
|
-
"@sanity/types": "2.21.
|
|
26
|
-
"@sanity/ui": "^0.
|
|
27
|
-
"lodash": "^4.17.
|
|
29
|
+
"@sanity/types": "2.21.12-purple-unicorn.1300+abdd014728",
|
|
30
|
+
"@sanity/ui": "^0.37.5",
|
|
31
|
+
"lodash": "^4.17.21",
|
|
28
32
|
"rxjs": "^6.5.3"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@sanity/base": "2.21.
|
|
35
|
+
"@sanity/base": "2.21.12-purple-unicorn.1300+abdd014728",
|
|
32
36
|
"prop-types": "^15.6.0",
|
|
33
|
-
"
|
|
37
|
+
"react": "17.0.2",
|
|
38
|
+
"rimraf": "^3.0.2"
|
|
34
39
|
},
|
|
35
40
|
"peerDependencies": {
|
|
36
41
|
"@sanity/base": "^2.0.0",
|
|
@@ -47,5 +52,5 @@
|
|
|
47
52
|
"url": "https://github.com/sanity-io/sanity/issues"
|
|
48
53
|
},
|
|
49
54
|
"homepage": "https://www.sanity.io/",
|
|
50
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "abdd014728981dd514951705252054db61bcd3f4"
|
|
51
56
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
"extends": "../../../tsconfig.settings",
|
|
3
|
+
"include": ["./src/"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": true,
|
|
6
|
+
"declarationDir": "./lib/dts/",
|
|
7
|
+
"rootDir": "./",
|
|
8
|
+
"outDir": "./lib/dts/",
|
|
9
|
+
"jsx": "react",
|
|
10
|
+
"noImplicitAny": false,
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"checkJs": false
|
|
13
|
+
},
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "../base/tsconfig.lib.json"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|