@e-llm-studio/instant-learning 1.3.35 → 1.3.38
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/ILMarketplaceWrapper.js +41 -1
- package/dist/ILMarketplaceWrapper.js.map +1 -1
- package/dist/cjs/ILMarketplaceWrapper.js +40 -0
- package/dist/cjs/ILMarketplaceWrapper.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/GuidelineCardMenu.js +3 -2
- package/dist/cjs/features/IL-marketplace/components/GuidelineCardMenu.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/GuidelineConfirmDialog.module.css.js +2 -2
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js +188 -28
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryContent.js +10 -0
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryContent.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/RequestAccessDialog.js +206 -0
- package/dist/cjs/features/IL-marketplace/components/RequestAccessDialog.js.map +1 -0
- package/dist/cjs/features/IL-marketplace/components/RequestAccessDialog.module.css.js +12 -0
- package/dist/cjs/features/IL-marketplace/components/RequestAccessDialog.module.css.js.map +1 -0
- package/dist/cjs/features/IL-marketplace/services/instant-learning.api.js +27 -0
- package/dist/cjs/features/IL-marketplace/services/instant-learning.api.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/utils/shareModalPrefill.js +99 -0
- package/dist/cjs/features/IL-marketplace/utils/shareModalPrefill.js.map +1 -0
- package/dist/features/IL-marketplace/components/GuidelineCardMenu.js +4 -3
- package/dist/features/IL-marketplace/components/GuidelineCardMenu.js.map +1 -1
- package/dist/features/IL-marketplace/components/GuidelineConfirmDialog.js +9 -9
- package/dist/features/IL-marketplace/components/GuidelineConfirmDialog.js.map +1 -1
- package/dist/features/IL-marketplace/components/GuidelineConfirmDialog.module.css.js +2 -2
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js +188 -28
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
- package/dist/features/IL-marketplace/components/GuidelineLibraryContent.js +10 -0
- package/dist/features/IL-marketplace/components/GuidelineLibraryContent.js.map +1 -1
- package/dist/features/IL-marketplace/components/RequestAccessDialog.js +202 -0
- package/dist/features/IL-marketplace/components/RequestAccessDialog.js.map +1 -0
- package/dist/features/IL-marketplace/components/RequestAccessDialog.module.css.js +8 -0
- package/dist/features/IL-marketplace/components/RequestAccessDialog.module.css.js.map +1 -0
- package/dist/features/IL-marketplace/services/instant-learning.api.js +27 -1
- package/dist/features/IL-marketplace/services/instant-learning.api.js.map +1 -1
- package/dist/features/IL-marketplace/utils/shareModalPrefill.js +95 -0
- package/dist/features/IL-marketplace/utils/shareModalPrefill.js.map +1 -0
- package/dist/types/src/ILMarketplaceWrapper.d.ts +12 -2
- package/dist/types/src/ILMarketplaceWrapper.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/GuidelineCardMenu.d.ts +7 -2
- package/dist/types/src/features/IL-marketplace/components/GuidelineCardMenu.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryCard.d.ts +13 -2
- package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryCard.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryContent.d.ts +11 -3
- package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryContent.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/RequestAccessDialog.d.ts +74 -0
- package/dist/types/src/features/IL-marketplace/components/RequestAccessDialog.d.ts.map +1 -0
- package/dist/types/src/features/IL-marketplace/index.d.ts +2 -1
- package/dist/types/src/features/IL-marketplace/index.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/services/instant-learning.api.d.ts +12 -0
- package/dist/types/src/features/IL-marketplace/services/instant-learning.api.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/utils/shareModalPrefill.d.ts +26 -0
- package/dist/types/src/features/IL-marketplace/utils/shareModalPrefill.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@ import { GuidelineIconButton } from './GuidelineIconButton.js';
|
|
|
10
10
|
import { GuidelineTooltip } from './GuidelineTooltip.js';
|
|
11
11
|
import { createGuidelineCardMenuItems, GuidelineCardMenu } from './GuidelineCardMenu.js';
|
|
12
12
|
import { GuidelineConfirmDialog } from './GuidelineConfirmDialog.js';
|
|
13
|
+
import { RequestAccessDialog } from './RequestAccessDialog.js';
|
|
13
14
|
import { isUnderReviewStatus, isKnownApprovalStatus, isKnownGuidelineStatus, GuidelineStatusChip, GuidelineApprovalChip } from './GuidelineStatusChip.js';
|
|
14
15
|
import { VersionSelectDropdown } from './VersionSelectDropdown.js';
|
|
15
16
|
import useAuthStore from '../../LearningManagement/store/useAuthStore.js';
|
|
@@ -20,6 +21,7 @@ import { Toast } from 'primereact/toast';
|
|
|
20
21
|
import { RbacQueryProvider, AppsecProvider, ShareAccessModal } from 'appsec-ui';
|
|
21
22
|
import { fetchRBACConfig } from '../services/instant-learning.api.js';
|
|
22
23
|
import { createRoleFilterAxiosConfig, clearAppsecRoleLists } from '../utils/appsecRoles.js';
|
|
24
|
+
import { prefillShareModal } from '../utils/shareModalPrefill.js';
|
|
23
25
|
import ErrorToastContent from '../../LearningManagement/shared/ErrorToastContent.js';
|
|
24
26
|
import SuccessToastContent from '../../LearningManagement/shared/SuccessToastContent.js';
|
|
25
27
|
|
|
@@ -28,6 +30,12 @@ const DELETE_DISABLED_REASONS = {
|
|
|
28
30
|
denied: "You don't have permission to delete this.",
|
|
29
31
|
error: "Couldn't verify your delete permission. Reopen the menu to try again."
|
|
30
32
|
};
|
|
33
|
+
const IDLE_REQUEST_STATES = {
|
|
34
|
+
access: "idle",
|
|
35
|
+
share: "idle",
|
|
36
|
+
delete: "idle"
|
|
37
|
+
};
|
|
38
|
+
const getRoleRequestHint = (action, role, state) => state === "sent" ? `${role.label} access requested` : state === "sending" ? "Sending your request\u2026" : `You need ${role.label} access to ${action} this. Click to request it.`;
|
|
31
39
|
const REQUEST_ACCESS_TOOLTIPS = {
|
|
32
40
|
idle: "Request access",
|
|
33
41
|
sending: "Sending your request\u2026",
|
|
@@ -96,6 +104,11 @@ function GuidelineLibraryCard({
|
|
|
96
104
|
onApproveGuideline,
|
|
97
105
|
onRejectGuideline,
|
|
98
106
|
onRequestAccess,
|
|
107
|
+
requestAccessDialog,
|
|
108
|
+
autoOpenShare = false,
|
|
109
|
+
autoOpenShareEmail,
|
|
110
|
+
autoOpenShareRole,
|
|
111
|
+
onAutoOpenShareHandled,
|
|
99
112
|
waitingReviewLabel = "Waiting on your review",
|
|
100
113
|
approveLabel = "Approve",
|
|
101
114
|
rejectLabel = "Reject",
|
|
@@ -103,7 +116,7 @@ function GuidelineLibraryCard({
|
|
|
103
116
|
exploreHighlightConfig,
|
|
104
117
|
guidelinePinnedMessages
|
|
105
118
|
}) {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
|
|
107
120
|
const guidelineId = getGuidelineId(guideline);
|
|
108
121
|
const title = getGuidelineTitle(guideline);
|
|
109
122
|
const description = getGuidelineDisplayDescription(guideline);
|
|
@@ -167,6 +180,7 @@ function GuidelineLibraryCard({
|
|
|
167
180
|
enabled: Boolean(accessControl)
|
|
168
181
|
});
|
|
169
182
|
const isAccessDenied = isILMarketplace && guideline.has_access === false && !appAccess.permissions.has(viewPermission);
|
|
183
|
+
const showRequestAccessDialogButton = isAccessDenied && Boolean((requestAccessDialog == null ? void 0 : requestAccessDialog.approverGroupId) && onRequestAccess);
|
|
170
184
|
const { data: approvalCompletionStatus } = useMarketplaceApprovalStatus(
|
|
171
185
|
guideline == null ? void 0 : guideline.instant_learning_id,
|
|
172
186
|
guideline == null ? void 0 : guideline.scope_id,
|
|
@@ -230,7 +244,11 @@ function GuidelineLibraryCard({
|
|
|
230
244
|
);
|
|
231
245
|
const [wishlistLoading, setWishlistLoading] = useState(false);
|
|
232
246
|
const [decisionLoading, setDecisionLoading] = useState(null);
|
|
233
|
-
const [
|
|
247
|
+
const [requestStates, setRequestStates] = useState(IDLE_REQUEST_STATES);
|
|
248
|
+
const requestAccessState = requestStates.access;
|
|
249
|
+
const [requestDialogPurpose, setRequestDialogPurpose] = useState(
|
|
250
|
+
null
|
|
251
|
+
);
|
|
234
252
|
const [whenToApplyOpen, setWhenToApplyOpen] = useState(false);
|
|
235
253
|
const [whenNotToApplyOpen, setWhenNotToApplyOpen] = useState(false);
|
|
236
254
|
const resolvedDuplicateDescription = duplicateConfirmDescription != null ? duplicateConfirmDescription : `Are you sure you want to duplicate "${title}"? A copy will be created with "(1)" appended to the title.`;
|
|
@@ -280,6 +298,20 @@ function GuidelineLibraryCard({
|
|
|
280
298
|
const sharePermissionState = accessControl ? getPermissionState(sharePermission) : "allowed";
|
|
281
299
|
const isShareBusy = shareConfigLoading || sharePermissionState === "checking";
|
|
282
300
|
const isShareLocked = !isAccessDenied && (sharePermissionState === "denied" || sharePermissionState === "error");
|
|
301
|
+
const canSendRoleRequests = Boolean((requestAccessDialog == null ? void 0 : requestAccessDialog.approverGroupId) && onRequestAccess);
|
|
302
|
+
const findRequestRole = (value) => {
|
|
303
|
+
var _a2, _b2;
|
|
304
|
+
return canSendRoleRequests && value ? (_b2 = (_a2 = requestAccessDialog == null ? void 0 : requestAccessDialog.roles) == null ? void 0 : _a2.find((role) => role.value === value)) != null ? _b2 : {
|
|
305
|
+
value,
|
|
306
|
+
label: value
|
|
307
|
+
} : void 0;
|
|
308
|
+
};
|
|
309
|
+
const shareRequestRole = findRequestRole(requestAccessDialog == null ? void 0 : requestAccessDialog.shareRole);
|
|
310
|
+
const deleteRequestRole = findRequestRole(requestAccessDialog == null ? void 0 : requestAccessDialog.deleteRole);
|
|
311
|
+
const canRequestShareRole = Boolean(shareRequestRole) && !isAccessDenied && sharePermissionState === "denied";
|
|
312
|
+
const canRequestDeleteRole = Boolean(deleteRequestRole) && !isAccessDenied && deletePermissionState === "denied";
|
|
313
|
+
const isShareRequestOpen = canRequestShareRole && requestStates.share === "idle";
|
|
314
|
+
const isShareOff = isShareBusy || sharePermissionState === "denied" && !isShareRequestOpen;
|
|
283
315
|
const shareRolesKey = (_C = (_B = accessControl == null ? void 0 : accessControl.shareRoles) == null ? void 0 : _B.join("\n")) != null ? _C : "";
|
|
284
316
|
const ilkbShareAxiosConfig = useMemo(
|
|
285
317
|
() => shareRolesKey ? createRoleFilterAxiosConfig(shareRolesKey.split("\n")) : void 0,
|
|
@@ -383,27 +415,26 @@ function GuidelineLibraryCard({
|
|
|
383
415
|
}
|
|
384
416
|
onPreview(guideline);
|
|
385
417
|
};
|
|
386
|
-
const
|
|
418
|
+
const openShare = async () => {
|
|
387
419
|
var _a2, _b2, _c2, _d2;
|
|
388
|
-
event.stopPropagation();
|
|
389
420
|
if (!canShareGuideline || isShareBusy) {
|
|
390
|
-
return;
|
|
421
|
+
return false;
|
|
391
422
|
}
|
|
392
423
|
if (sharePermissionState === "error") {
|
|
393
424
|
retryFailedPermissionChecks();
|
|
394
|
-
return;
|
|
425
|
+
return false;
|
|
395
426
|
}
|
|
396
427
|
if (sharePermissionState !== "allowed") {
|
|
397
|
-
return;
|
|
428
|
+
return false;
|
|
398
429
|
}
|
|
399
430
|
if (ilkbShareTarget) {
|
|
400
431
|
clearAppsecRoleLists();
|
|
401
432
|
setShareDialogOpen(true);
|
|
402
|
-
return;
|
|
433
|
+
return true;
|
|
403
434
|
}
|
|
404
435
|
if (shareRbacConfig) {
|
|
405
436
|
setShareDialogOpen(true);
|
|
406
|
-
return;
|
|
437
|
+
return true;
|
|
407
438
|
}
|
|
408
439
|
setShareConfigLoading(true);
|
|
409
440
|
try {
|
|
@@ -422,19 +453,96 @@ function GuidelineLibraryCard({
|
|
|
422
453
|
setShareErrorMessage(
|
|
423
454
|
"This template's access configuration is incomplete, so sharing is unavailable."
|
|
424
455
|
);
|
|
425
|
-
return;
|
|
456
|
+
return false;
|
|
426
457
|
}
|
|
427
458
|
setShareRbacConfig(rbacConfig);
|
|
428
459
|
setShareDialogOpen(true);
|
|
460
|
+
return true;
|
|
429
461
|
} catch (error) {
|
|
430
462
|
console.error("Failed to fetch share RBAC config:", error);
|
|
431
463
|
setShareErrorMessage(
|
|
432
464
|
((_d2 = (_c2 = error == null ? void 0 : error.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || (error == null ? void 0 : error.message) || "Couldn't load share access for this template. Please try again."
|
|
433
465
|
);
|
|
466
|
+
return false;
|
|
434
467
|
} finally {
|
|
435
468
|
setShareConfigLoading(false);
|
|
436
469
|
}
|
|
437
470
|
};
|
|
471
|
+
const handleShareClick = async (event) => {
|
|
472
|
+
event.stopPropagation();
|
|
473
|
+
if (canRequestShareRole) {
|
|
474
|
+
if (isShareRequestOpen) setRequestDialogPurpose("share");
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
await openShare();
|
|
478
|
+
};
|
|
479
|
+
const onAutoOpenShareHandledRef = useRef(onAutoOpenShareHandled);
|
|
480
|
+
onAutoOpenShareHandledRef.current = onAutoOpenShareHandled;
|
|
481
|
+
const autoOpenShareDoneRef = useRef(false);
|
|
482
|
+
const articleRef = useRef(null);
|
|
483
|
+
const shareModalHostRef = useRef(null);
|
|
484
|
+
const [sharePrefill, setSharePrefill] = useState(null);
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
var _a2;
|
|
487
|
+
if (!autoOpenShare) {
|
|
488
|
+
autoOpenShareDoneRef.current = false;
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (autoOpenShareDoneRef.current) return;
|
|
492
|
+
const finish = (outcome) => {
|
|
493
|
+
var _a3;
|
|
494
|
+
autoOpenShareDoneRef.current = true;
|
|
495
|
+
(_a3 = onAutoOpenShareHandledRef.current) == null ? void 0 : _a3.call(onAutoOpenShareHandledRef, outcome);
|
|
496
|
+
};
|
|
497
|
+
if (appAccess.isPending) return;
|
|
498
|
+
if (isAccessDenied) {
|
|
499
|
+
finish(appAccess.isError ? "failed" : "not-allowed");
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
if (!canShareGuideline) {
|
|
503
|
+
finish("not-allowed");
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
if (isShareBusy) return;
|
|
507
|
+
if (sharePermissionState === "denied") {
|
|
508
|
+
finish("not-allowed");
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (sharePermissionState === "error") {
|
|
512
|
+
finish("failed");
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
autoOpenShareDoneRef.current = true;
|
|
516
|
+
(_a2 = articleRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
517
|
+
const emailToAdd = (autoOpenShareEmail == null ? void 0 : autoOpenShareEmail.trim()) || void 0;
|
|
518
|
+
const roleToPick = (autoOpenShareRole == null ? void 0 : autoOpenShareRole.trim()) || void 0;
|
|
519
|
+
void openShare().then((opened) => {
|
|
520
|
+
var _a3;
|
|
521
|
+
if (opened && (emailToAdd || roleToPick)) {
|
|
522
|
+
setSharePrefill({ email: emailToAdd, role: roleToPick });
|
|
523
|
+
}
|
|
524
|
+
(_a3 = onAutoOpenShareHandledRef.current) == null ? void 0 : _a3.call(onAutoOpenShareHandledRef, opened ? "opened" : "failed");
|
|
525
|
+
});
|
|
526
|
+
}, [
|
|
527
|
+
autoOpenShare,
|
|
528
|
+
appAccess.isPending,
|
|
529
|
+
appAccess.isError,
|
|
530
|
+
isAccessDenied,
|
|
531
|
+
canShareGuideline,
|
|
532
|
+
isShareBusy,
|
|
533
|
+
sharePermissionState
|
|
534
|
+
]);
|
|
535
|
+
useEffect(() => {
|
|
536
|
+
if (!shareDialogOpen || !sharePrefill) return;
|
|
537
|
+
return prefillShareModal(
|
|
538
|
+
() => shareModalHostRef.current,
|
|
539
|
+
sharePrefill,
|
|
540
|
+
() => setSharePrefill(null)
|
|
541
|
+
);
|
|
542
|
+
}, [shareDialogOpen, sharePrefill]);
|
|
543
|
+
useEffect(() => {
|
|
544
|
+
if (!shareDialogOpen) setSharePrefill(null);
|
|
545
|
+
}, [shareDialogOpen]);
|
|
438
546
|
const handleCardClick = (event) => {
|
|
439
547
|
if (!handleCardClickCallback || isAccessDenied) return;
|
|
440
548
|
if (event.target.closest('button, a, input, select, [role="menuitem"]')) {
|
|
@@ -488,14 +596,16 @@ function GuidelineLibraryCard({
|
|
|
488
596
|
setDecisionLoading(null);
|
|
489
597
|
}
|
|
490
598
|
};
|
|
491
|
-
const
|
|
599
|
+
const setRequestState = (purpose, state) => setRequestStates((previous) => ({ ...previous, [purpose]: state }));
|
|
600
|
+
const sendAccessRequest = async (purpose = "access", role) => {
|
|
492
601
|
var _a2, _b2;
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
setRequestAccessState("sending");
|
|
602
|
+
if (!onRequestAccess || requestStates[purpose] !== "idle") return false;
|
|
603
|
+
setRequestState(purpose, "sending");
|
|
496
604
|
try {
|
|
497
|
-
await Promise.resolve(
|
|
498
|
-
|
|
605
|
+
await Promise.resolve(
|
|
606
|
+
role ? onRequestAccess(guideline, { role: role.value, purpose }) : onRequestAccess(guideline)
|
|
607
|
+
);
|
|
608
|
+
setRequestState(purpose, "sent");
|
|
499
609
|
(_a2 = shareToastRef.current) == null ? void 0 : _a2.show({
|
|
500
610
|
severity: "success",
|
|
501
611
|
sticky: false,
|
|
@@ -504,12 +614,13 @@ function GuidelineLibraryCard({
|
|
|
504
614
|
SuccessToastContent,
|
|
505
615
|
{
|
|
506
616
|
title: "Access requested",
|
|
507
|
-
message: `Your request to access "${title}" has been sent.`
|
|
617
|
+
message: role ? `Your request for ${role.label} access to "${title}" has been sent.` : `Your request to access "${title}" has been sent.`
|
|
508
618
|
}
|
|
509
619
|
)
|
|
510
620
|
});
|
|
621
|
+
return true;
|
|
511
622
|
} catch (error) {
|
|
512
|
-
|
|
623
|
+
setRequestState(purpose, "idle");
|
|
513
624
|
(_b2 = shareToastRef.current) == null ? void 0 : _b2.show({
|
|
514
625
|
severity: "error",
|
|
515
626
|
sticky: false,
|
|
@@ -522,8 +633,23 @@ function GuidelineLibraryCard({
|
|
|
522
633
|
}
|
|
523
634
|
)
|
|
524
635
|
});
|
|
636
|
+
return false;
|
|
525
637
|
}
|
|
526
638
|
};
|
|
639
|
+
const handleRequestAccessClick = async (event) => {
|
|
640
|
+
event.stopPropagation();
|
|
641
|
+
await sendAccessRequest();
|
|
642
|
+
};
|
|
643
|
+
const handleRequestAccessDialogOpen = (event) => {
|
|
644
|
+
event.stopPropagation();
|
|
645
|
+
if (requestAccessState !== "idle") return;
|
|
646
|
+
setRequestDialogPurpose("access");
|
|
647
|
+
};
|
|
648
|
+
const handleRequestAccessDialogSend = async (role) => {
|
|
649
|
+
const purpose = requestDialogPurpose;
|
|
650
|
+
if (!purpose) return;
|
|
651
|
+
if (await sendAccessRequest(purpose, role)) setRequestDialogPurpose(null);
|
|
652
|
+
};
|
|
527
653
|
const handleRejectClick = async (event) => {
|
|
528
654
|
event.stopPropagation();
|
|
529
655
|
if (!onRejectGuideline) return;
|
|
@@ -549,14 +675,16 @@ function GuidelineLibraryCard({
|
|
|
549
675
|
}
|
|
550
676
|
};
|
|
551
677
|
const menuItems = createGuidelineCardMenuItems({
|
|
552
|
-
|
|
678
|
+
// A Delete the user's role doesn't allow can ask for the role that would (`deleteRole`).
|
|
679
|
+
onDelete: () => canRequestDeleteRole ? setRequestDialogPurpose("delete") : setDeleteDialogOpen(true),
|
|
553
680
|
deleteLabel: deleteOptionLabel,
|
|
554
681
|
// TODO: Temporarily hiding delete option in UI until deep research on deleteInstantLearningQuestion API is complete.
|
|
555
682
|
hideDelete: false,
|
|
556
683
|
// hideDeleteOption || !onDelete,
|
|
557
|
-
deleteDisabled: !canDeleteGuideline,
|
|
684
|
+
deleteDisabled: canRequestDeleteRole ? requestStates.delete !== "idle" : !canDeleteGuideline,
|
|
558
685
|
deleteLoading: deletePermissionState === "checking",
|
|
559
|
-
|
|
686
|
+
deleteLocked: canRequestDeleteRole,
|
|
687
|
+
deleteDisabledReason: canRequestDeleteRole && deleteRequestRole ? getRoleRequestHint("delete", deleteRequestRole, requestStates.delete) : deleteDisabledReason,
|
|
560
688
|
onToggleVariant: handleToggleVariant,
|
|
561
689
|
isVariantEnabled,
|
|
562
690
|
enableVariantLabel,
|
|
@@ -697,6 +825,7 @@ function GuidelineLibraryCard({
|
|
|
697
825
|
/* @__PURE__ */ jsxs(
|
|
698
826
|
"article",
|
|
699
827
|
{
|
|
828
|
+
ref: articleRef,
|
|
700
829
|
"data-guideline-id": guidelineId,
|
|
701
830
|
onClick: handleCardClickCallback ? handleCardClick : void 0,
|
|
702
831
|
className: cx(
|
|
@@ -766,7 +895,7 @@ function GuidelineLibraryCard({
|
|
|
766
895
|
className: cx(cssStyles.libraryCardActions, classNames == null ? void 0 : classNames.libraryCardActions),
|
|
767
896
|
style: styles == null ? void 0 : styles.libraryCardActions,
|
|
768
897
|
children: [
|
|
769
|
-
isAccessDenied && /* @__PURE__ */ jsx(GuidelineTooltip, { content: REQUEST_ACCESS_TOOLTIPS[requestAccessState], children: /* @__PURE__ */ jsx(
|
|
898
|
+
isAccessDenied && !showRequestAccessDialogButton && /* @__PURE__ */ jsx(GuidelineTooltip, { content: REQUEST_ACCESS_TOOLTIPS[requestAccessState], children: /* @__PURE__ */ jsx(
|
|
770
899
|
"button",
|
|
771
900
|
{
|
|
772
901
|
type: "button",
|
|
@@ -989,19 +1118,20 @@ function GuidelineLibraryCard({
|
|
|
989
1118
|
canShareGuideline && /* @__PURE__ */ jsx(
|
|
990
1119
|
GuidelineTooltip,
|
|
991
1120
|
{
|
|
992
|
-
content: shareConfigLoading ? "Loading share access" : SHARE_TOOLTIPS[sharePermissionState],
|
|
1121
|
+
content: shareConfigLoading ? "Loading share access" : canRequestShareRole && shareRequestRole ? getRoleRequestHint("share", shareRequestRole, requestStates.share) : SHARE_TOOLTIPS[sharePermissionState],
|
|
993
1122
|
children: /* @__PURE__ */ jsx(
|
|
994
1123
|
"button",
|
|
995
1124
|
{
|
|
996
1125
|
type: "button",
|
|
997
1126
|
onClick: handleShareClick,
|
|
998
1127
|
disabled: isAccessDenied,
|
|
999
|
-
"aria-disabled":
|
|
1128
|
+
"aria-disabled": isShareOff,
|
|
1129
|
+
"aria-haspopup": isShareRequestOpen ? "dialog" : void 0,
|
|
1000
1130
|
className: cx(
|
|
1001
1131
|
cssStyles.previewButton,
|
|
1002
|
-
|
|
1132
|
+
isShareOff && cssStyles.previewButtonDisabled
|
|
1003
1133
|
),
|
|
1004
|
-
"aria-label": isShareLocked ? `Share ${title} (locked)` : `Share ${title}`,
|
|
1134
|
+
"aria-label": isShareRequestOpen && shareRequestRole ? `Request ${shareRequestRole.label} access to share ${title}` : isShareLocked ? `Share ${title} (locked)` : `Share ${title}`,
|
|
1005
1135
|
children: isShareBusy ? /* @__PURE__ */ jsx(Loader2, { className: cssStyles.previewIconSpinner, strokeWidth: 2 }) : isShareLocked ? /* @__PURE__ */ jsxs("span", { className: cssStyles.lockedIcon, children: [
|
|
1006
1136
|
/* @__PURE__ */ jsx(Share2, { className: cssStyles.previewIcon, strokeWidth: 2 }),
|
|
1007
1137
|
/* @__PURE__ */ jsx(Lock, { className: cssStyles.lockedIconBadge, strokeWidth: 2.5 })
|
|
@@ -1025,7 +1155,22 @@ function GuidelineLibraryCard({
|
|
|
1025
1155
|
}
|
|
1026
1156
|
)
|
|
1027
1157
|
] }),
|
|
1028
|
-
/* @__PURE__ */
|
|
1158
|
+
showRequestAccessDialogButton && /* @__PURE__ */ jsx("div", { className: cx(cssStyles.primaryActionGroup, cssStyles.requestAccessFooterGroup), children: /* @__PURE__ */ jsxs(
|
|
1159
|
+
"button",
|
|
1160
|
+
{
|
|
1161
|
+
type: "button",
|
|
1162
|
+
onClick: handleRequestAccessDialogOpen,
|
|
1163
|
+
"aria-disabled": requestAccessState !== "idle",
|
|
1164
|
+
"aria-haspopup": "dialog",
|
|
1165
|
+
className: cssStyles.requestAccessFooterButton,
|
|
1166
|
+
"aria-label": requestAccessState === "sent" ? `Access requested for ${title}` : `Request access to ${title}`,
|
|
1167
|
+
children: [
|
|
1168
|
+
requestAccessState === "sent" && /* @__PURE__ */ jsx(Check, { className: cssStyles.requestAccessIcon, strokeWidth: 2.4 }),
|
|
1169
|
+
/* @__PURE__ */ jsx("span", { children: requestAccessState === "sent" ? "Access requested" : (_I = requestAccessDialog == null ? void 0 : requestAccessDialog.buttonLabel) != null ? _I : "Request access" })
|
|
1170
|
+
]
|
|
1171
|
+
}
|
|
1172
|
+
) }),
|
|
1173
|
+
!showRequestAccessDialogButton && /* @__PURE__ */ jsxs("div", { className: cssStyles.primaryActionGroup, children: [
|
|
1029
1174
|
viewActionButton,
|
|
1030
1175
|
promoteActionButton,
|
|
1031
1176
|
shouldShowPrimaryAction && /* @__PURE__ */ jsx(
|
|
@@ -1144,6 +1289,21 @@ function GuidelineLibraryCard({
|
|
|
1144
1289
|
styles
|
|
1145
1290
|
}
|
|
1146
1291
|
),
|
|
1292
|
+
requestAccessDialog && (showRequestAccessDialogButton || canRequestShareRole || canRequestDeleteRole || requestDialogPurpose !== null) && /* @__PURE__ */ jsx(
|
|
1293
|
+
RequestAccessDialog,
|
|
1294
|
+
{
|
|
1295
|
+
open: requestDialogPurpose !== null,
|
|
1296
|
+
onClose: () => setRequestDialogPurpose(null),
|
|
1297
|
+
onSend: handleRequestAccessDialogSend,
|
|
1298
|
+
sending: requestDialogPurpose !== null && requestStates[requestDialogPurpose] === "sending",
|
|
1299
|
+
resourceName: title,
|
|
1300
|
+
config: requestAccessDialog,
|
|
1301
|
+
purpose: requestDialogPurpose != null ? requestDialogPurpose : "access",
|
|
1302
|
+
fixedRole: requestDialogPurpose === "share" ? shareRequestRole : requestDialogPurpose === "delete" ? deleteRequestRole : void 0,
|
|
1303
|
+
appsecRbacUrl,
|
|
1304
|
+
token: instantLearning == null ? void 0 : instantLearning.token
|
|
1305
|
+
}
|
|
1306
|
+
),
|
|
1147
1307
|
/* @__PURE__ */ jsx(
|
|
1148
1308
|
Toast,
|
|
1149
1309
|
{
|
|
@@ -1154,7 +1314,7 @@ function GuidelineLibraryCard({
|
|
|
1154
1314
|
}
|
|
1155
1315
|
),
|
|
1156
1316
|
shareDialogOpen && shareDialogTarget && (instantLearning == null ? void 0 : instantLearning.token) && createPortal(
|
|
1157
|
-
/* @__PURE__ */ jsx("div", { className: cx(appsecStyles.accessPanel, cssStyles.shareModalHost), children: /* @__PURE__ */ jsx(RbacQueryProvider, { children: /* @__PURE__ */ jsx(
|
|
1317
|
+
/* @__PURE__ */ jsx("div", { ref: shareModalHostRef, className: cx(appsecStyles.accessPanel, cssStyles.shareModalHost), children: /* @__PURE__ */ jsx(RbacQueryProvider, { children: /* @__PURE__ */ jsx(
|
|
1158
1318
|
AppsecProvider,
|
|
1159
1319
|
{
|
|
1160
1320
|
appId: shareDialogTarget.appName,
|