MCPcopy Create free account
hub / github.com/Rello/analytics / createLinkShare

Function createLinkShare

tests/playwright/50_navigation_share.js:47–93  ·  view source on GitHub ↗
(page)

Source from the content-addressed store, hash-verified

45}
46
47async function createLinkShare(page) {
48 const result = await page.evaluate(async () => {
49 const itemType = document.getElementById('shareItemType')?.value;
50 const itemId = document.getElementById('shareItemId')?.value;
51 const shareType = document.getElementById('newLinkShare')?.dataset?.shareType;
52 const requestUrl = OC.generateUrl('apps/analytics/share');
53
54 const response = await fetch(requestUrl, {
55 method: 'POST',
56 headers: OCA.Analytics.headers(),
57 body: JSON.stringify({
58 item_type: itemType,
59 item_source: itemId,
60 type: shareType,
61 }),
62 });
63
64 const body = await response.text();
65 let json = null;
66 try {
67 json = JSON.parse(body);
68 } catch (error) {
69 json = null;
70 }
71
72 if (response.ok && json) {
73 await OCA.Analytics.Share.updateShareModal(itemType, itemId);
74 }
75
76 return {
77 ok: response.ok,
78 status: response.status,
79 body,
80 json,
81 itemType,
82 itemId,
83 shareType,
84 };
85 });
86
87 if (!result.ok || !result.json) {
88 const snippet = (result.body || '').replace(/\s+/g, ' ').trim().slice(0, 240);
89 throw new Error(
90 `Create share failed (${result.status}) for ${result.itemType}/${result.itemId} type=${result.shareType}. Response: ${snippet}`
91 );
92 }
93}
94
95async function getCreatedShareRow(page) {
96 const rows = shareRows(page);

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected