@vonaffenfels/contentful-teasermanager 1.1.52 → 1.1.53
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/dist/{_base_slate-editor_src_dev_testComponents_TestStory2_js.js → TestStory.js} +8 -8
- package/dist/{_base_slate-editor_src_dev_testComponents_TestStory_js.js → TestStory2.js} +8 -8
- package/dist/{_base_slate-editor_src_dev_testComponents_TestStory3_js.js → TestStory3.js} +2 -2
- package/dist/index.094ebe8a6da25ebef11e.hot-update.js +11 -0
- package/dist/index.094ebe8a6da25ebef11e.hot-update.json +1 -0
- package/dist/index.30eae97ccdf3a813b021.hot-update.js +42 -0
- package/dist/index.30eae97ccdf3a813b021.hot-update.json +1 -0
- package/dist/index.5ec068db2d05b046d371.hot-update.js +22 -0
- package/dist/index.5ec068db2d05b046d371.hot-update.json +1 -0
- package/dist/index.9c341de9e0f1bd4a79d2.hot-update.js +43 -0
- package/dist/index.9c341de9e0f1bd4a79d2.hot-update.json +1 -0
- package/dist/index.9dfef8895061a4ec159a.hot-update.js +398 -0
- package/dist/index.9dfef8895061a4ec159a.hot-update.json +1 -0
- package/dist/index.c062f00a592bcf4fd9e7.hot-update.js +20666 -0
- package/dist/index.c062f00a592bcf4fd9e7.hot-update.json +1 -0
- package/dist/index.d80013ee9c93571c5cd7.hot-update.js +11 -0
- package/dist/index.d80013ee9c93571c5cd7.hot-update.json +1 -0
- package/dist/index.fd3ea37b5951a3cb5357.hot-update.js +11 -0
- package/dist/index.fd3ea37b5951a3cb5357.hot-update.json +1 -0
- package/dist/index.js +62169 -57770
- package/package.json +2 -2
- package/src/components/Contentful/ConfigScreen.js +80 -63
- package/src/components/Contentful/Dialog.js +63 -48
- package/src/components/Contentful/EntryEditor.js +8 -2
- package/src/components/Contentful/Page.js +5 -3
- package/src/components/NoAccess.js +13 -0
- package/src/index.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-teasermanager",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.53",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublish": "yarn run build",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@vonaffenfels/slate-editor": "^1.1.52",
|
|
100
100
|
"webpack": "5.88.2"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "5fb290a60b6c1b427ab90c9687ee7289738d78f3",
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public"
|
|
105
105
|
}
|
|
@@ -1,77 +1,94 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useState,
|
|
3
|
+
} from 'react';
|
|
2
4
|
import {
|
|
3
|
-
|
|
5
|
+
Form, Workbench,
|
|
4
6
|
} from '@contentful/forma-36-react-components';
|
|
7
|
+
import {FormControl} from '@contentful/f36-components';
|
|
8
|
+
import {Multiselect} from '@contentful/f36-multiselect';
|
|
5
9
|
import {css} from 'emotion';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
const Config = ({sdk}) => {
|
|
12
|
+
const [params, setParams] = useState({usersWithAccess: []});
|
|
13
|
+
const [spaceUsers, setSpaceUsers] = useState([]);
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.state = {parameters: {}};
|
|
15
|
+
const onConfigure = async () => {
|
|
16
|
+
const currentState = await sdk.app.getCurrentState();
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
+
return {
|
|
19
|
+
parameters: params,
|
|
20
|
+
targetState: currentState,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (sdk) {
|
|
26
|
+
sdk.app.getParameters().then(params => {
|
|
27
|
+
setParams(params);
|
|
28
|
+
sdk.app.setReady();
|
|
29
|
+
});
|
|
30
|
+
sdk.space.getUsers().then(users => {
|
|
31
|
+
setSpaceUsers(users.items.map(v => v.email));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [sdk]);
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (sdk) {
|
|
38
|
+
sdk.app.onConfigure(() => onConfigure());
|
|
39
|
+
}
|
|
40
|
+
}, [sdk, params]);
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const handleSelectItem = (event) => {
|
|
43
|
+
const {
|
|
44
|
+
checked,
|
|
45
|
+
value,
|
|
46
|
+
} = event.target;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
let newValue = params?.usersWithAccess || [];
|
|
49
|
+
if (checked) {
|
|
50
|
+
newValue = [...newValue, value];
|
|
51
|
+
} else {
|
|
52
|
+
newValue = newValue.filter((email) => email !== value);
|
|
53
|
+
}
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// In case you don't want to submit any update to app
|
|
44
|
-
// locations, you can just pass the currentState as is
|
|
45
|
-
targetState: currentState,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
onFieldChanged(value, field) {
|
|
50
|
-
this.setState({
|
|
51
|
-
parameters: {
|
|
52
|
-
...this.state.parameters,
|
|
53
|
-
[field]: value,
|
|
54
|
-
},
|
|
55
|
+
setParams({
|
|
56
|
+
...params,
|
|
57
|
+
usersWithAccess: newValue,
|
|
55
58
|
});
|
|
56
|
-
}
|
|
59
|
+
};
|
|
60
|
+
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
return (
|
|
63
|
+
<Workbench className={css({
|
|
64
|
+
padding: '80px',
|
|
65
|
+
backgroundColor: "#FFF",
|
|
66
|
+
})}>
|
|
67
|
+
<Form>
|
|
68
|
+
<FormControl>
|
|
69
|
+
<FormControl.Label>Teasermanager Benutzer</FormControl.Label>
|
|
70
|
+
<Multiselect
|
|
71
|
+
currentSelection={params.usersWithAccess}
|
|
72
|
+
popoverProps={{isFullWidth: true}}
|
|
73
|
+
>
|
|
74
|
+
{spaceUsers.map((userEmail) => {
|
|
75
|
+
const val = userEmail.toLowerCase().replace(/\s/g, '-');
|
|
76
|
+
return (
|
|
77
|
+
<Multiselect.Option
|
|
78
|
+
key={`user-${val}}`}
|
|
79
|
+
itemId={val}
|
|
80
|
+
value={userEmail}
|
|
81
|
+
label={userEmail}
|
|
82
|
+
onSelectItem={handleSelectItem}
|
|
83
|
+
isChecked={params.usersWithAccess?.includes(userEmail)}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
})}
|
|
87
|
+
</Multiselect>
|
|
88
|
+
</FormControl>
|
|
89
|
+
</Form>
|
|
90
|
+
</Workbench>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
76
93
|
|
|
77
|
-
|
|
94
|
+
export default Config;
|
|
@@ -1,48 +1,63 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useState,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import {NewestArticles} from "./Dialog/NewestArticles";
|
|
5
|
+
import {NoAccess} from "../NoAccess";
|
|
6
|
+
|
|
7
|
+
const Dialog = ({
|
|
8
|
+
sdk,
|
|
9
|
+
portals,
|
|
10
|
+
getArticleThumbnailUrl,
|
|
11
|
+
}) => {
|
|
12
|
+
const [slotState, setSlotState] = useState({});
|
|
13
|
+
const enabled = sdk?.parameters?.installation?.usersWithAccess?.includes(sdk?.user?.email);
|
|
14
|
+
|
|
15
|
+
const selectEntry = (entry) => {
|
|
16
|
+
sdk.close(entry);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const loadSlotStateForPage = async () => {
|
|
20
|
+
try {
|
|
21
|
+
const apiRoot = sdk.parameters.instance.apiRoot;
|
|
22
|
+
const portal = sdk.parameters.invocation.portal;
|
|
23
|
+
const pageId = sdk.parameters.invocation.entryId;
|
|
24
|
+
const date = sdk.parameters.invocation.date;
|
|
25
|
+
const teasermanagerUrl = `${apiRoot}/api/findStateForPage?project=${portal}&page=${pageId}&date=${date.toISOString()}`;
|
|
26
|
+
const response = await fetch(teasermanagerUrl).then(res => res.json());
|
|
27
|
+
|
|
28
|
+
if (response?.message) {
|
|
29
|
+
console.error(response.message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return response?.data || {};
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
loadSlotStateForPage().then(setSlotState);
|
|
40
|
+
}, [sdk.parameters.invocation]);
|
|
41
|
+
|
|
42
|
+
if (!enabled) {
|
|
43
|
+
return <NoAccess sdk={sdk}/>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return <div style={{
|
|
47
|
+
backgroundColor: "#FFFFFF",
|
|
48
|
+
minHeight: "100vh",
|
|
49
|
+
}}>
|
|
50
|
+
<NewestArticles sdk={sdk} onEntryClick={selectEntry} slotState={slotState} getArticleThumbnailUrl={getArticleThumbnailUrl} portals={portals}/>
|
|
51
|
+
{/*
|
|
52
|
+
<Tabs defaultTab="newest">
|
|
53
|
+
<Tabs.List>
|
|
54
|
+
<Tabs.Tab panelId="newest">Neuste Artikel</Tabs.Tab>
|
|
55
|
+
</Tabs.List>
|
|
56
|
+
<Tabs.Panel id="newest">
|
|
57
|
+
</Tabs.Panel>
|
|
58
|
+
</Tabs>
|
|
59
|
+
*/}
|
|
60
|
+
</div>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default Dialog;
|
|
@@ -2,12 +2,14 @@ import React, {
|
|
|
2
2
|
useEffect, useState,
|
|
3
3
|
} from 'react';
|
|
4
4
|
import {Teasermanager} from "../Teasermanager";
|
|
5
|
+
import {NoAccess} from "../NoAccess";
|
|
5
6
|
|
|
6
7
|
const Entry = ({sdk}) => {
|
|
7
8
|
const contentField = sdk.parameters.instance.contentField;
|
|
8
9
|
const [locale, setLocale] = useState(sdk.locales.default);
|
|
9
10
|
const [portal, setPortal] = useState();
|
|
10
11
|
const portalField = sdk?.entry?.fields?.portal;
|
|
12
|
+
const enabled = sdk?.parameters?.installation?.usersWithAccess?.includes(sdk?.user?.email);
|
|
11
13
|
|
|
12
14
|
portalField?.onValueChanged(() => {
|
|
13
15
|
if (portalField.getValue() !== portal) {
|
|
@@ -86,7 +88,7 @@ const Entry = ({sdk}) => {
|
|
|
86
88
|
console.error(e);
|
|
87
89
|
alert("Fehler beim speichern!");
|
|
88
90
|
}
|
|
89
|
-
}
|
|
91
|
+
};
|
|
90
92
|
|
|
91
93
|
const loadSlotStateForPage = async (date) => {
|
|
92
94
|
try {
|
|
@@ -102,7 +104,7 @@ const Entry = ({sdk}) => {
|
|
|
102
104
|
} catch (e) {
|
|
103
105
|
console.error(e);
|
|
104
106
|
}
|
|
105
|
-
}
|
|
107
|
+
};
|
|
106
108
|
|
|
107
109
|
const loadTimelineStateForPage = async (fromDate, toDate) => {
|
|
108
110
|
try {
|
|
@@ -118,6 +120,10 @@ const Entry = ({sdk}) => {
|
|
|
118
120
|
} catch (e) {
|
|
119
121
|
console.error(e);
|
|
120
122
|
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (!enabled) {
|
|
126
|
+
return <NoAccess sdk={sdk}/>;
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
return <Teasermanager
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {Teasermanager} from "../Teasermanager";
|
|
3
|
+
import {NoAccess} from "../NoAccess";
|
|
3
4
|
|
|
4
5
|
const Page = ({sdk}) => {
|
|
6
|
+
const enabled = sdk?.parameters?.installation?.usersWithAccess?.includes(sdk?.user?.email);
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
if (!enabled) {
|
|
9
|
+
return <NoAccess sdk={sdk}/>;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
return <Teasermanager entryId={"4RvZ6fcUtBIgw2Hw5YILPs"}
|
|
12
|
+
return <Teasermanager entryId={"4RvZ6fcUtBIgw2Hw5YILPs"} />;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export default Page;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DisplayText, Flex, Paragraph,
|
|
3
|
+
} from "@contentful/f36-components";
|
|
4
|
+
|
|
5
|
+
export const NoAccess = ({sdk}) => {
|
|
6
|
+
return <Flex flexDirection="column" alignItems="center" paddingTop="spacing2Xl">
|
|
7
|
+
<DisplayText>
|
|
8
|
+
Kein Zugriff
|
|
9
|
+
</DisplayText>
|
|
10
|
+
<Paragraph>Bitte wenden Sie sich an einen Administrator wenn sie Zugriff benötigen</Paragraph>
|
|
11
|
+
<Paragraph>Angemeldeter Benutzer: {sdk?.user?.email}</Paragraph>
|
|
12
|
+
</Flex>;
|
|
13
|
+
};
|
package/src/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import Dialog from "./components/Contentful/Dialog";
|
|
|
12
12
|
import Page from "./components/Contentful/Page";
|
|
13
13
|
import {initContentfulClient} from "./lib/contentfulClient";
|
|
14
14
|
|
|
15
|
-
export const BaseContentfulApp = (props) => {
|
|
15
|
+
export const BaseContentfulApp = (props = {}) => {
|
|
16
16
|
init((sdk) => {
|
|
17
17
|
const rootContainer = document.getElementById('root');
|
|
18
18
|
|
|
@@ -43,6 +43,7 @@ export const BaseContentfulApp = (props) => {
|
|
|
43
43
|
];
|
|
44
44
|
|
|
45
45
|
ComponentLocationSettings.forEach((componentLocationSetting) => {
|
|
46
|
+
console.log("index.js:46 / ANON", sdk.location);
|
|
46
47
|
if (sdk.location.is(componentLocationSetting.location)) {
|
|
47
48
|
const root = createRoot(rootContainer); // createRoot(container!) if you use TypeScript
|
|
48
49
|
root.render(componentLocationSetting.component);
|