@sanity/dashboard 0.136.3-purple-unicorn-patch.5627
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 +21 -0
- package/README.md +118 -0
- package/lib/cjs/DashboardTool.js +59 -0
- package/lib/cjs/components/DashboardLayout.js +35 -0
- package/lib/cjs/components/NotFoundWidget.js +53 -0
- package/lib/cjs/components/WidgetGroup.js +71 -0
- package/lib/cjs/components/dashboardWidget.js +55 -0
- package/lib/cjs/containers/Dashboard.js +32 -0
- package/lib/cjs/containers/WidgetContainer.js +52 -0
- package/lib/cjs/dashboardConfig.js +16 -0
- package/lib/cjs/legacyParts.js +55 -0
- package/lib/cjs/versionedClient.js +20 -0
- package/lib/cjs/widget.css +62 -0
- package/lib/cjs/widgets/projectInfo/ProjectInfo.js +269 -0
- package/lib/cjs/widgets/projectInfo/index.js +19 -0
- package/lib/cjs/widgets/projectUsers/ProjectUsers.js +194 -0
- package/lib/cjs/widgets/projectUsers/index.js +16 -0
- package/lib/cjs/widgets/sanityTutorials/SanityTutorials.js +122 -0
- package/lib/cjs/widgets/sanityTutorials/Tutorial.js +114 -0
- package/lib/cjs/widgets/sanityTutorials/dataAdapter.js +28 -0
- package/lib/cjs/widgets/sanityTutorials/index.js +19 -0
- package/lib/dts/src/DashboardTool.d.ts +11 -0
- package/lib/dts/src/DashboardTool.d.ts.map +1 -0
- package/lib/dts/src/DashboardTool.js +18 -0
- package/lib/dts/src/DashboardTool.js.map +1 -0
- package/lib/dts/src/components/DashboardLayout.d.ts +13 -0
- package/lib/dts/src/components/DashboardLayout.d.ts.map +1 -0
- package/lib/dts/src/components/DashboardLayout.js +15 -0
- package/lib/dts/src/components/DashboardLayout.js.map +1 -0
- package/lib/dts/src/components/NotFoundWidget.d.ts +16 -0
- package/lib/dts/src/components/NotFoundWidget.d.ts.map +1 -0
- package/lib/dts/src/components/NotFoundWidget.js +29 -0
- package/lib/dts/src/components/NotFoundWidget.js.map +1 -0
- package/lib/dts/src/components/WidgetGroup.d.ts +3 -0
- package/lib/dts/src/components/WidgetGroup.d.ts.map +1 -0
- package/lib/dts/src/components/WidgetGroup.js +81 -0
- package/lib/dts/src/components/WidgetGroup.js.map +1 -0
- package/lib/dts/src/components/dashboardWidget.d.ts +9 -0
- package/lib/dts/src/components/dashboardWidget.d.ts.map +1 -0
- package/lib/dts/src/components/dashboardWidget.js +48 -0
- package/lib/dts/src/components/dashboardWidget.js.map +1 -0
- package/lib/dts/src/containers/Dashboard.d.ts +3 -0
- package/lib/dts/src/containers/Dashboard.d.ts.map +1 -0
- package/lib/dts/src/containers/Dashboard.js +14 -0
- package/lib/dts/src/containers/Dashboard.js.map +1 -0
- package/lib/dts/src/containers/WidgetContainer.d.ts +13 -0
- package/lib/dts/src/containers/WidgetContainer.d.ts.map +1 -0
- package/lib/dts/src/containers/WidgetContainer.js +42 -0
- package/lib/dts/src/containers/WidgetContainer.js.map +1 -0
- package/lib/dts/src/dashboardConfig.d.ts +7 -0
- package/lib/dts/src/dashboardConfig.d.ts.map +1 -0
- package/lib/dts/src/dashboardConfig.js +4 -0
- package/lib/dts/src/dashboardConfig.js.map +1 -0
- package/lib/dts/src/legacyParts.d.ts +8 -0
- package/lib/dts/src/legacyParts.d.ts.map +1 -0
- package/lib/dts/src/legacyParts.js +10 -0
- package/lib/dts/src/legacyParts.js.map +1 -0
- package/lib/dts/src/versionedClient.d.ts +8 -0
- package/lib/dts/src/versionedClient.d.ts.map +1 -0
- package/lib/dts/src/versionedClient.js +9 -0
- package/lib/dts/src/versionedClient.js.map +1 -0
- package/lib/dts/src/widgets/projectInfo/ProjectInfo.d.ts +31 -0
- package/lib/dts/src/widgets/projectInfo/ProjectInfo.d.ts.map +1 -0
- package/lib/dts/src/widgets/projectInfo/ProjectInfo.js +155 -0
- package/lib/dts/src/widgets/projectInfo/ProjectInfo.js.map +1 -0
- package/lib/dts/src/widgets/projectInfo/index.d.ts +10 -0
- package/lib/dts/src/widgets/projectInfo/index.d.ts.map +1 -0
- package/lib/dts/src/widgets/projectInfo/index.js +7 -0
- package/lib/dts/src/widgets/projectInfo/index.js.map +1 -0
- package/lib/dts/src/widgets/projectUsers/ProjectUsers.d.ts +20 -0
- package/lib/dts/src/widgets/projectUsers/ProjectUsers.d.ts.map +1 -0
- package/lib/dts/src/widgets/projectUsers/ProjectUsers.js +108 -0
- package/lib/dts/src/widgets/projectUsers/ProjectUsers.js.map +1 -0
- package/lib/dts/src/widgets/projectUsers/index.d.ts +7 -0
- package/lib/dts/src/widgets/projectUsers/index.d.ts.map +1 -0
- package/lib/dts/src/widgets/projectUsers/index.js +6 -0
- package/lib/dts/src/widgets/projectUsers/index.js.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/SanityTutorials.d.ts +21 -0
- package/lib/dts/src/widgets/sanityTutorials/SanityTutorials.d.ts.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/SanityTutorials.js +61 -0
- package/lib/dts/src/widgets/sanityTutorials/SanityTutorials.js.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/Tutorial.d.ts +21 -0
- package/lib/dts/src/widgets/sanityTutorials/Tutorial.d.ts.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/Tutorial.js +84 -0
- package/lib/dts/src/widgets/sanityTutorials/Tutorial.js.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/dataAdapter.d.ts +6 -0
- package/lib/dts/src/widgets/sanityTutorials/dataAdapter.d.ts.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/dataAdapter.js +16 -0
- package/lib/dts/src/widgets/sanityTutorials/dataAdapter.js.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/index.d.ts +10 -0
- package/lib/dts/src/widgets/sanityTutorials/index.d.ts.map +1 -0
- package/lib/dts/src/widgets/sanityTutorials/index.js +7 -0
- package/lib/dts/src/widgets/sanityTutorials/index.js.map +1 -0
- package/lib/dts/tsconfig.tsbuildinfo +1 -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 +55 -0
- package/sanity.json +59 -0
- 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
|
@@ -0,0 +1,174 @@
|
|
|
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';
|
|
13
|
+
import { versionedClient } from '../../versionedClient';
|
|
14
|
+
import { DashboardWidget } from '../../DashboardTool';
|
|
15
|
+
import { userStore } from '../../legacyParts';
|
|
16
|
+
const 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
|
+
const {
|
|
24
|
+
members
|
|
25
|
+
} = project;
|
|
26
|
+
const membershipA = members.find(member => member.id === userA.id);
|
|
27
|
+
const membershipB = members.find(member => member.id === userB.id);
|
|
28
|
+
|
|
29
|
+
if (membershipA.isRobot) {
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (membershipB.isRobot) {
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class ProjectUsers extends React.PureComponent {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
|
|
44
|
+
_defineProperty(this, "state", {
|
|
45
|
+
project: null,
|
|
46
|
+
users: null,
|
|
47
|
+
error: null
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
_defineProperty(this, "handleRetryFetch", () => {
|
|
51
|
+
this.fetchData();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
this.fetchData();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentWillUnmount() {
|
|
60
|
+
if (this.subscription) {
|
|
61
|
+
this.subscription.unsubscribe();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fetchData() {
|
|
66
|
+
if (this.subscription) {
|
|
67
|
+
this.subscription.unsubscribe();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
projectId
|
|
72
|
+
} = versionedClient.config();
|
|
73
|
+
this.subscription = versionedClient.observable.request({
|
|
74
|
+
uri: "/projects/".concat(projectId)
|
|
75
|
+
}).pipe(switchMap(project => userStore.observable.getUsers(project.members.map(mem => mem.id)).pipe(map(users => ({
|
|
76
|
+
project,
|
|
77
|
+
users
|
|
78
|
+
}))))).subscribe({
|
|
79
|
+
next: _ref => {
|
|
80
|
+
let {
|
|
81
|
+
users,
|
|
82
|
+
project
|
|
83
|
+
} = _ref;
|
|
84
|
+
return this.setState({
|
|
85
|
+
project,
|
|
86
|
+
users: (Array.isArray(users) ? users : [users]).sort((userA, userB) => sortUsersByRobotStatus(userA, userB, project))
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
error: error => this.setState({
|
|
90
|
+
error
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
render() {
|
|
96
|
+
const {
|
|
97
|
+
error,
|
|
98
|
+
project,
|
|
99
|
+
users
|
|
100
|
+
} = this.state;
|
|
101
|
+
const isLoading = !users || !project;
|
|
102
|
+
|
|
103
|
+
if (error) {
|
|
104
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
105
|
+
header: "Project users"
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
107
|
+
padding: 4
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Text, null, "Something went wrong while fetching data. You could", ' ', /*#__PURE__*/React.createElement("a", {
|
|
109
|
+
onClick: this.handleRetryFetch,
|
|
110
|
+
title: "Retry users fetch",
|
|
111
|
+
style: {
|
|
112
|
+
cursor: 'pointer'
|
|
113
|
+
}
|
|
114
|
+
}, "retry"), "..?")));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
118
|
+
header: "Project users",
|
|
119
|
+
footer: /*#__PURE__*/React.createElement(Button, {
|
|
120
|
+
style: {
|
|
121
|
+
width: '100%'
|
|
122
|
+
},
|
|
123
|
+
paddingX: 2,
|
|
124
|
+
paddingY: 4,
|
|
125
|
+
mode: "bleed",
|
|
126
|
+
tone: "primary",
|
|
127
|
+
text: "Invite members",
|
|
128
|
+
as: "a",
|
|
129
|
+
loading: isLoading,
|
|
130
|
+
href: isLoading ? undefined : getInviteUrl(project.id)
|
|
131
|
+
})
|
|
132
|
+
}, isLoading && /*#__PURE__*/React.createElement(Box, {
|
|
133
|
+
paddingY: 5,
|
|
134
|
+
paddingX: 2
|
|
135
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
136
|
+
space: 4
|
|
137
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
138
|
+
align: "center",
|
|
139
|
+
muted: true,
|
|
140
|
+
size: 1
|
|
141
|
+
}, /*#__PURE__*/React.createElement(Spinner, null)), /*#__PURE__*/React.createElement(Text, {
|
|
142
|
+
align: "center",
|
|
143
|
+
size: 1,
|
|
144
|
+
muted: true
|
|
145
|
+
}, "Loading items..."))), !isLoading && /*#__PURE__*/React.createElement(Stack, {
|
|
146
|
+
space: 3,
|
|
147
|
+
padding: 3
|
|
148
|
+
}, users.map(user => {
|
|
149
|
+
const membership = project.members.find(member => member.id === user.id);
|
|
150
|
+
const media = membership.isRobot ? /*#__PURE__*/React.createElement(Text, {
|
|
151
|
+
size: 3
|
|
152
|
+
}, /*#__PURE__*/React.createElement(RobotIcon, null)) : /*#__PURE__*/React.createElement(AvatarWrapper, {
|
|
153
|
+
tone: "transparent"
|
|
154
|
+
}, (user === null || user === void 0 ? void 0 : user.imageUrl) && /*#__PURE__*/React.createElement("img", {
|
|
155
|
+
src: user.imageUrl,
|
|
156
|
+
alt: user === null || user === void 0 ? void 0 : user.displayName
|
|
157
|
+
}));
|
|
158
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
159
|
+
key: user.id
|
|
160
|
+
}, /*#__PURE__*/React.createElement(DefaultPreview, {
|
|
161
|
+
title: user.displayName,
|
|
162
|
+
subtitle: membership.role,
|
|
163
|
+
media: media
|
|
164
|
+
}));
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_defineProperty(ProjectUsers, "propTypes", {});
|
|
171
|
+
|
|
172
|
+
_defineProperty(ProjectUsers, "defaultProps", {});
|
|
173
|
+
|
|
174
|
+
export default ProjectUsers;
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
const {
|
|
12
|
+
urlBuilder,
|
|
13
|
+
getFeed
|
|
14
|
+
} = dataAdapter;
|
|
15
|
+
|
|
16
|
+
function createUrl(slug, type) {
|
|
17
|
+
if (type === 'tutorial') {
|
|
18
|
+
return "https://www.sanity.io/docs/tutorials/".concat(slug.current);
|
|
19
|
+
} else if (type === 'guide') {
|
|
20
|
+
return "https://www.sanity.io/docs/guides/".concat(slug.current);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class SanityTutorials extends React.Component {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "state", {
|
|
31
|
+
feedItems: []
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
componentDidMount() {
|
|
36
|
+
const {
|
|
37
|
+
templateRepoId
|
|
38
|
+
} = this.props;
|
|
39
|
+
this.subscription = getFeed(templateRepoId).subscribe(response => {
|
|
40
|
+
this.setState({
|
|
41
|
+
feedItems: response.items
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
componentWillUnmount() {
|
|
47
|
+
if (this.subscription) {
|
|
48
|
+
this.subscription.unsubscribe();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
const {
|
|
54
|
+
feedItems
|
|
55
|
+
} = this.state;
|
|
56
|
+
const title = 'Learn about Sanity';
|
|
57
|
+
return /*#__PURE__*/React.createElement(DashboardWidget, {
|
|
58
|
+
header: title
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
|
60
|
+
as: "ul",
|
|
61
|
+
overflow: "auto",
|
|
62
|
+
align: "stretch",
|
|
63
|
+
paddingY: 2
|
|
64
|
+
}, feedItems === null || feedItems === void 0 ? void 0 : feedItems.map((feedItem, index) => {
|
|
65
|
+
if (!feedItem.title || !feedItem.guideOrTutorial && !feedItem.externalLink) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const presenter = feedItem.presenter || _get(feedItem, 'guideOrTutorial.presenter') || {};
|
|
70
|
+
|
|
71
|
+
const subtitle = _get(feedItem, 'category');
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
guideOrTutorial = {}
|
|
75
|
+
} = feedItem;
|
|
76
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
77
|
+
as: "li",
|
|
78
|
+
key: feedItem._id,
|
|
79
|
+
paddingRight: index < (feedItems === null || feedItems === void 0 ? void 0 : feedItems.length) - 1 ? 1 : 3,
|
|
80
|
+
paddingLeft: index === 0 ? 3 : 0,
|
|
81
|
+
align: "stretch",
|
|
82
|
+
flex: "0 0 27.5%",
|
|
83
|
+
style: {
|
|
84
|
+
minWidth: 272,
|
|
85
|
+
width: '30%'
|
|
86
|
+
}
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Tutorial, {
|
|
88
|
+
title: feedItem.title,
|
|
89
|
+
href: createUrl(guideOrTutorial.slug, guideOrTutorial._type) || feedItem.externalLink,
|
|
90
|
+
presenterName: presenter.name,
|
|
91
|
+
presenterSubtitle: subtitle,
|
|
92
|
+
showPlayIcon: feedItem.hasVideo,
|
|
93
|
+
posterURL: urlBuilder.image(feedItem.poster).height(360).url()
|
|
94
|
+
}));
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_defineProperty(SanityTutorials, "propTypes", {
|
|
101
|
+
templateRepoId: PropTypes.string
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_defineProperty(SanityTutorials, "defaultProps", {
|
|
105
|
+
templateRepoId: null
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export default SanityTutorials;
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
const 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
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref;
|
|
16
|
+
return theme.sanity.color.card.enabled.bg;
|
|
17
|
+
});
|
|
18
|
+
const Root = styled(Flex)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &:hover {\n ", " {\n &:before {\n opacity: 1;\n }\n }\n }\n"])), PlayIconBox);
|
|
19
|
+
const PosterCard = styled(Card)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n padding-bottom: calc(9 / 16 * 100%);\n position: relative;\n"])));
|
|
20
|
+
const 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"])));
|
|
21
|
+
|
|
22
|
+
class Tutorial extends React.PureComponent {
|
|
23
|
+
render() {
|
|
24
|
+
const {
|
|
25
|
+
title,
|
|
26
|
+
posterURL,
|
|
27
|
+
showPlayIcon,
|
|
28
|
+
href,
|
|
29
|
+
presenterName,
|
|
30
|
+
presenterSubtitle
|
|
31
|
+
} = this.props;
|
|
32
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
33
|
+
flex: 1
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
35
|
+
sizing: "border",
|
|
36
|
+
flex: 1,
|
|
37
|
+
padding: 2,
|
|
38
|
+
radius: 2,
|
|
39
|
+
as: "a",
|
|
40
|
+
href: href,
|
|
41
|
+
target: "_blank",
|
|
42
|
+
rel: "noopener noreferrer",
|
|
43
|
+
style: {
|
|
44
|
+
position: 'relative'
|
|
45
|
+
}
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
|
47
|
+
direction: "column",
|
|
48
|
+
style: {
|
|
49
|
+
height: '100%'
|
|
50
|
+
}
|
|
51
|
+
}, posterURL && /*#__PURE__*/React.createElement(PosterCard, {
|
|
52
|
+
marginBottom: 1
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Poster, {
|
|
54
|
+
src: posterURL
|
|
55
|
+
}), showPlayIcon && /*#__PURE__*/React.createElement(PlayIconBox, {
|
|
56
|
+
display: "flex"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
58
|
+
align: "center"
|
|
59
|
+
}, /*#__PURE__*/React.createElement(PlayIcon, null)))), /*#__PURE__*/React.createElement(Flex, {
|
|
60
|
+
direction: "column",
|
|
61
|
+
justify: "space-between",
|
|
62
|
+
paddingY: 2,
|
|
63
|
+
flex: 1
|
|
64
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
65
|
+
as: "h3",
|
|
66
|
+
size: 1
|
|
67
|
+
}, title), /*#__PURE__*/React.createElement(Box, {
|
|
68
|
+
marginTop: 4
|
|
69
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
70
|
+
space: 2,
|
|
71
|
+
flex: 1
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
73
|
+
size: 1
|
|
74
|
+
}, presenterName), /*#__PURE__*/React.createElement(Text, {
|
|
75
|
+
size: 0,
|
|
76
|
+
style: {
|
|
77
|
+
opacity: 0.7
|
|
78
|
+
}
|
|
79
|
+
}, presenterSubtitle)))))));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_defineProperty(Tutorial, "propTypes", {
|
|
85
|
+
title: PropTypes.string.isRequired,
|
|
86
|
+
posterURL: PropTypes.string,
|
|
87
|
+
href: PropTypes.string.isRequired,
|
|
88
|
+
showPlayIcon: PropTypes.bool,
|
|
89
|
+
presenterName: PropTypes.string.isRequired,
|
|
90
|
+
presenterSubtitle: PropTypes.string.isRequired
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_defineProperty(Tutorial, "defaultProps", {
|
|
94
|
+
posterURL: null,
|
|
95
|
+
showPlayIcon: false
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export default Tutorial;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import imageUrlBuilder from '@sanity/image-url';
|
|
2
|
+
import { versionedClient } from '../../versionedClient';
|
|
3
|
+
const tutorialsProjectConfig = {
|
|
4
|
+
projectId: '3do82whm',
|
|
5
|
+
dataset: 'next'
|
|
6
|
+
};
|
|
7
|
+
export default {
|
|
8
|
+
getFeed: templateRepoId => {
|
|
9
|
+
const 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
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sanity/dashboard",
|
|
3
|
+
"version": "0.136.3-purple-unicorn-patch.5627+c8b4b71ac",
|
|
4
|
+
"description": "Tool for rendering dashboard widgets",
|
|
5
|
+
"main": "./lib/cjs/DashboardTool.js",
|
|
6
|
+
"module": "./lib/esm/DashboardTool.js",
|
|
7
|
+
"types": "./lib/dts/src/DashboardTool.d.ts",
|
|
8
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "../../../bin/pkg-utils transpile",
|
|
12
|
+
"clean": "rimraf lib",
|
|
13
|
+
"watch": "../../../bin/pkg-utils transpile --watch"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sanity",
|
|
17
|
+
"cms",
|
|
18
|
+
"headless",
|
|
19
|
+
"realtime",
|
|
20
|
+
"content",
|
|
21
|
+
"dashboard",
|
|
22
|
+
"sanity-plugin",
|
|
23
|
+
"sanity-tool"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@sanity/icons": "^1.2.8",
|
|
27
|
+
"@sanity/image-url": "^1.0.1",
|
|
28
|
+
"@sanity/types": "0.136.3-purple-unicorn-patch.5627+c8b4b71ac",
|
|
29
|
+
"@sanity/ui": "^0.37.8",
|
|
30
|
+
"lodash": "^4.17.21",
|
|
31
|
+
"rxjs": "^6.5.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@sanity/base": "0.136.3-purple-unicorn-patch.5627+c8b4b71ac",
|
|
35
|
+
"prop-types": "^15.6.0",
|
|
36
|
+
"react": "17.0.2",
|
|
37
|
+
"rimraf": "^3.0.2"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@sanity/base": "^2.0.0",
|
|
41
|
+
"prop-types": "^15.6 || ^16",
|
|
42
|
+
"react": "^16.9 || ^17",
|
|
43
|
+
"styled-components": "^5.2.0"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/sanity-io/sanity.git",
|
|
48
|
+
"directory": "packages/@sanity/dashboard"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/sanity-io/sanity/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://www.sanity.io/",
|
|
54
|
+
"gitHead": "c8b4b71acd7cf035f6f0a2efd19c39ced849811f"
|
|
55
|
+
}
|
package/sanity.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"paths": {
|
|
3
|
+
"source": "./src",
|
|
4
|
+
"compiled": "./lib"
|
|
5
|
+
},
|
|
6
|
+
"parts": [
|
|
7
|
+
{
|
|
8
|
+
"implements": "part:@sanity/base/tool",
|
|
9
|
+
"path": "DashboardTool"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"implements": "part:@sanity/base/component",
|
|
13
|
+
"path": "components/story"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "part:@sanity/dashboard/config",
|
|
17
|
+
"description": "Tool for rendering dashboard widgets"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"implements": "part:@sanity/dashboard/config",
|
|
21
|
+
"path": "dashboardConfig"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "part:@sanity/dashboard/widget",
|
|
25
|
+
"description": "Anything suitable for the dashboard"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "part:@sanity/dashboard/widget/sanity-tutorials",
|
|
29
|
+
"implements": "part:@sanity/dashboard/widget",
|
|
30
|
+
"path": "widgets/sanityTutorials"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "part:@sanity/dashboard/widget/project-info",
|
|
34
|
+
"implements": "part:@sanity/dashboard/widget",
|
|
35
|
+
"path": "widgets/projectInfo"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "part:@sanity/dashboard/widget/project-users",
|
|
39
|
+
"implements": "part:@sanity/dashboard/widget",
|
|
40
|
+
"path": "widgets/projectUsers"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "part:@sanity/dashboard/widget-styles",
|
|
44
|
+
"description": "Provides pseudo styles for selectable items"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"implements": "part:@sanity/dashboard/widget-styles",
|
|
48
|
+
"path": "widget.css"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "part:@sanity/dashboard/widget-container",
|
|
52
|
+
"description": "A container component that resolves and renders widget components"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"implements": "part:@sanity/dashboard/widget-container",
|
|
56
|
+
"path": "containers/WidgetContainer"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Dashboard from './containers/Dashboard'
|
|
3
|
+
|
|
4
|
+
const strokeStyle = {
|
|
5
|
+
stroke: 'currentColor',
|
|
6
|
+
strokeWidth: 1.2,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const DashboardIcon = () => (
|
|
10
|
+
<svg
|
|
11
|
+
data-sanity-icon
|
|
12
|
+
viewBox="0 0 25 25"
|
|
13
|
+
fill="none"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
preserveAspectRatio="xMidYMid"
|
|
16
|
+
width="1em"
|
|
17
|
+
height="1em"
|
|
18
|
+
>
|
|
19
|
+
<path d="M19.5 19.5H5.5V5.5H19.5V19.5Z" style={strokeStyle} />
|
|
20
|
+
<path d="M5.5 12.5H19.5" style={strokeStyle} />
|
|
21
|
+
<path d="M14.5 19.5V12.5M10.5 12.5V5.5" style={strokeStyle} />
|
|
22
|
+
</svg>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export * from './components/dashboardWidget'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
title: 'Dashboard',
|
|
29
|
+
name: 'dashboard',
|
|
30
|
+
icon: DashboardIcon,
|
|
31
|
+
component: Dashboard,
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {Container} from '@sanity/ui'
|
|
4
|
+
|
|
5
|
+
function DashboardLayout(props) {
|
|
6
|
+
return (
|
|
7
|
+
<Container width={4} padding={4} sizing="border" style={{minHeight: '100%'}}>
|
|
8
|
+
{props.children}
|
|
9
|
+
</Container>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
DashboardLayout.propTypes = {
|
|
14
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
15
|
+
children: PropTypes.any,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
DashboardLayout.defaultProps = {
|
|
19
|
+
children: 'Dummy',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default DashboardLayout
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {Card, Stack, Heading, Box} from '@sanity/ui'
|
|
4
|
+
import styled from 'styled-components'
|
|
5
|
+
|
|
6
|
+
const Root = styled(Card)`
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
justify-content: stretch;
|
|
10
|
+
height: 100%;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
function NotFoundWidget(props) {
|
|
14
|
+
const {title, children} = props
|
|
15
|
+
return (
|
|
16
|
+
<Root radius={3} paddingX={3} paddingY={4} tone="critical">
|
|
17
|
+
<Stack space={2}>
|
|
18
|
+
{title && (
|
|
19
|
+
<Heading size={1} as="h2">
|
|
20
|
+
{title}
|
|
21
|
+
</Heading>
|
|
22
|
+
)}
|
|
23
|
+
{children && <Box>{children}</Box>}
|
|
24
|
+
</Stack>
|
|
25
|
+
</Root>
|
|
26
|
+
)
|
|
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
|
+
|
|
36
|
+
NotFoundWidget.defaultProps = {
|
|
37
|
+
children: null,
|
|
38
|
+
title: null,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default NotFoundWidget
|