@live-change/access-control-frontend 0.0.3

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.
@@ -0,0 +1,60 @@
1
+ const { devices } = require('playwright')
2
+
3
+ const testServerPort = process.env.TEST_URL ? 0 : require('get-port-sync')()
4
+ const testServerUrl = process.env.TEST_URL || `http://localhost:${testServerPort}`
5
+
6
+ const device = devices['Pixel 2']
7
+
8
+ exports.config = {
9
+ tests: './*.test.js',
10
+ output: './output',
11
+ helpers: {
12
+ LiveChange: {
13
+ require: '@live-change/codeceptjs-helper',
14
+ startServer: !process.env.TEST_URL,
15
+ enableSessions: true,
16
+ initScript: "./init.js",
17
+ port: testServerPort,
18
+ dev: true
19
+ },
20
+ VideoHelper: {
21
+ require: 'codeceptjs-video-helper'
22
+ },
23
+ AssertWrapper : {
24
+ require: "codeceptjs-assert"
25
+ },
26
+ Playwright: {
27
+ browser: 'chromium',
28
+ url: testServerUrl,
29
+ show: true,
30
+ emulate: {
31
+ ...device,
32
+ recordVideo: process.env.RECORD_TESTS ? {
33
+ dir: "./output",
34
+ //size: { width: 1080, height: 1920 }
35
+ } : undefined,
36
+ },
37
+ chromium: {
38
+ args: [`--force-device-scale-factor=${device.deviceScaleFactor}`]
39
+ }
40
+ }
41
+ },
42
+ include: {
43
+ I: './steps_file.js'
44
+ },
45
+ bootstrap: null,
46
+ mocha: {},
47
+ name: 'e2e',
48
+ plugins: {
49
+ pauseOnFail: {},
50
+ retryFailedStep: {
51
+ enabled: true
52
+ },
53
+ tryTo: {
54
+ enabled: true
55
+ },
56
+ screenshotOnFail: {
57
+ enabled: true
58
+ }
59
+ }
60
+ }
package/e2e/steps.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /// <reference types='codeceptjs' />
2
+ // @ts-ignore
3
+ type steps_file = typeof import('./steps_file.js');
4
+
5
+ declare namespace CodeceptJS {
6
+ interface SupportObject { I: I, current: any }
7
+ interface Methods extends Playwright {}
8
+ interface I extends ReturnType<steps_file> {}
9
+ namespace Translation {
10
+ interface Actions {}
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ // in this file you can append custom step methods to 'I' object
2
+
3
+ const userSteps = require('../../user-frontend/e2e/steps_file.js')
4
+
5
+ module.exports = function() {
6
+ return actor({
7
+
8
+ ...userSteps
9
+
10
+ })
11
+ }
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <!--head-->
5
+ </head>
6
+ <body>
7
+ <div id="app"><!--app-html--></div>
8
+ <!--app-data-->
9
+ <script type="module" src="/src/entry-client.js"></script>
10
+ </body>
11
+ </html>
Binary file
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+
4
+ <svg
5
+ version="1.1"
6
+ id="Layer_1"
7
+ x="0px"
8
+ y="0px"
9
+ width="512px"
10
+ height="512px"
11
+ viewBox="0 0 512 512"
12
+ enable-background="new 0 0 512 512"
13
+ xml:space="preserve"
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ xmlns:svg="http://www.w3.org/2000/svg"
16
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
17
+ xmlns:cc="http://creativecommons.org/ns#"
18
+ xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
19
+ id="metadata9"><rdf:RDF><cc:Work
20
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
21
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
22
+ id="defs7" />
23
+ <rect
24
+ style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
25
+ id="rect821"
26
+ width="512.54236"
27
+ height="512.54236"
28
+ x="0.54237288"
29
+ y="0.54237235" />
30
+ <path
31
+ style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
32
+ d="M 0.54237288,470.23729 125.83051,306.44068 l 60.20339,70.50847 130.71186,-174.10169 195.79661,261.42373 0.54235,48.81353 H 0.54237288 Z"
33
+ id="path816" /><circle
34
+ style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:4.80000019;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
35
+ id="path818"
36
+ cx="118.50848"
37
+ cy="106.57627"
38
+ r="57.762711" /></svg>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+
4
+ <svg
5
+ version="1.1"
6
+ id="Layer_1"
7
+ x="0px"
8
+ y="0px"
9
+ width="512px"
10
+ height="512px"
11
+ viewBox="0 0 512 512"
12
+ enable-background="new 0 0 512 512"
13
+ xml:space="preserve"
14
+ xmlns="http://www.w3.org/2000/svg"
15
+ xmlns:svg="http://www.w3.org/2000/svg"
16
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
17
+ xmlns:cc="http://creativecommons.org/ns#"
18
+ xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
19
+ id="metadata9"><rdf:RDF><cc:Work
20
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
21
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
22
+ id="defs7" />
23
+ <rect
24
+ style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
25
+ id="rect821"
26
+ width="512.54236"
27
+ height="512.54236"
28
+ x="0.54237288"
29
+ y="0.54237235" /><path
30
+ d="m 313.14122,310.64877 c 9.02181,-8.85097 12.15686,-31.23733 20.41627,-39.3056 11.69771,-11.43183 24.39381,-25.50218 27.98588,-43.06851 4.82003,-23.34203 -4.96846,-26.30516 -4.96846,-34.3713 0,-16.90002 -0.15376,-44.65739 -5.43081,-62.68607 -0.30326,-23.7809 -4.20499,-34.123578 -12.38858,-43.031138 -7.72017,-8.33522 -26.68637,-6.366203 -36.59125,-11.85361 C 286.83605,67.825407 274.23818,64.594254 258.15823,64.17461 v -0.09503 c -0.47624,0 -0.93539,0.05659 -1.41162,0.05659 -0.78484,0 -1.53123,-0.05659 -2.35343,-0.05659 l 0.0395,0.151627 c -39.17105,1.472492 -80.84608,26.170627 -95.16524,65.895863 -5.31335,14.71958 -3.28881,46.87521 -3.28881,63.77522 0,8.06721 -9.78742,11.02927 -4.96846,34.37131 3.61129,17.56632 16.28817,31.63668 27.98588,43.06851 8.26048,8.06827 11.39446,30.45462 20.39705,39.30559 1.96902,13.0378 2.1986,9.31012 2.12278,21.23954 -0.0203,4.03307 0.11426,10.28502 -6.32669,16.4398 -12.17822,11.6614 -40.14595,36.95324 -63.08756,46.79832 -30.24,12.98014 -79.41203,33.74237 -90.746691,39.59069 -11.334661,5.84833 -41.2532541,21.69763 -41.2532541,31.79045 0,10.11417 0,47.33542 0,47.33542 h 253.3742451 5.79494 253.37318 c 0,0 0,-37.22125 0,-47.33542 0,-10.09282 -29.89723,-25.94212 -41.25645,-31.79045 -11.35389,-5.84938 -60.48321,-26.61055 -90.72641,-39.59069 -22.32976,-9.57707 -49.43685,-33.81712 -62.09344,-45.84158 -4.2808,-4.05228 -7.3016,-8.29784 -7.3411,-18.62023 -0.0737,-12.00417 0.23278,-7.41692 2.14306,-20.01478"
31
+ id="path2"
32
+ style="clip-rule:evenodd;fill-rule:evenodd;stroke-width:1.06779659;fill:#f6f6f6;fill-opacity:1" />
33
+ </svg>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ width="512"
4
+ height="512"
5
+ viewBox="0 0 135.46667 135.46667"
6
+ version="1.1"
7
+ id="svg977"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ xmlns:svg="http://www.w3.org/2000/svg"
10
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
11
+ xmlns:cc="http://creativecommons.org/ns#"
12
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
13
+ <defs
14
+ id="defs971" />
15
+ <metadata
16
+ id="metadata974">
17
+ <rdf:RDF>
18
+ <cc:Work
19
+ rdf:about="">
20
+ <dc:format>image/svg+xml</dc:format>
21
+ <dc:type
22
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
23
+ </cc:Work>
24
+ </rdf:RDF>
25
+ </metadata>
26
+ <g
27
+ id="layer1"
28
+ style="fill:#666666">
29
+ <path
30
+ style="fill:#666666;fill-opacity:1;stroke:none;stroke-width:2.70907px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
31
+ d="M 54.181439,13.558436 67.726801,0.01304296 135.45359,67.739804 67.726801,135.46667 29.799793,97.539626 V 65.030766 L 13.545362,81.285197 0,67.739804 40.636077,27.103727 81.272154,67.739804 67.726801,81.285197 51.472371,65.030766 V 92.12155 l 16.25443,16.25433 40.636069,-40.636076 z"
32
+ id="path892" />
33
+ </g>
34
+ </svg>
Binary file
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <view-root>
3
+ <template #navbar>
4
+ <NavBar />
5
+ </template>
6
+ </view-root>
7
+ </template>
8
+
9
+ <script setup>
10
+ import 'primevue/resources/themes/saga-green/theme.css'
11
+ //import 'primevue/resources/themes/lara-light-blue/theme.css'
12
+ //import 'primevue/resources/themes/vela-orange/theme.css'
13
+
14
+ import NavBar from "./NavBar.vue"
15
+ import ViewRoot from "@live-change/frontend-base/ViewRoot.vue"
16
+ import "./notifications"
17
+
18
+ import { useMeta } from 'vue-meta'
19
+ const { meta } = useMeta({
20
+ title: 'Title',
21
+ htmlAttrs: {
22
+ lang: 'en',
23
+ amp: true
24
+ }
25
+ })
26
+
27
+ import { watch } from 'vue'
28
+ import { client as useClient } from '@live-change/vue3-ssr'
29
+ const client = useClient()
30
+ watch(client, (newClient, oldClient) => {
31
+ console.log("WATCH CLIENT", oldClient, '=>', newClient)
32
+ })
33
+
34
+ </script>
@@ -0,0 +1,103 @@
1
+ <template>
2
+ <div class="surface-overlay py-3 px-6 shadow-2 flex align-items-center justify-content-between
3
+ relative md:sticky top-0 z-5"
4
+ style="min-height: 80px" key="navbar">
5
+ <img src="/images/logo.svg" alt="Image" height="40" class="mr-0 lg:mr-6">
6
+ <div class="hidden lg:flex">
7
+ <!-- place for desktop menu -->
8
+ </div>
9
+ <div class="flex flex-grow-1"></div>
10
+ <NotificationsIcon />
11
+ <a v-ripple class="cursor-pointer block lg:hidden text-700 p-ripple ml-2 hover:surface-100 p-2"
12
+ v-styleclass="{ selector: '@next', enterClass: 'hidden', leaveToClass: 'hidden', hideOnOutsideClick: true }">
13
+ <i class="pi pi-bars text-4xl"></i>
14
+ </a>
15
+ <div class="align-items-center flex-grow-1 justify-content-between hidden absolute lg:static w-full surface-overlay left-0 top-100 z-1 shadow-2 lg:shadow-none">
16
+ <ul class="list-none p-0 m-0 flex lg:align-items-center select-none flex-column lg:flex-row">
17
+ <li>
18
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
19
+ <i class="pi pi-home mr-2"></i>
20
+ <span>Home</span>
21
+ </a>
22
+ </li>
23
+ <li class="lg:relative">
24
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple"
25
+ v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'scalein', leaveToClass: 'hidden', leaveActiveClass: 'fadeout', hideOnOutsideClick: true }">
26
+ <i class="pi pi-users mr-2"></i>
27
+ <span>Customers</span>
28
+ <i class="pi pi-angle-down ml-auto lg:ml-3"></i>
29
+ </a>
30
+ <ul class="list-none py-3 px-6 m-0 lg:px-0 lg:py-0 border-round shadow-0 lg:shadow-2 lg:border-1 border-50 lg:absolute surface-overlay hidden origin-top w-full lg:w-15rem cursor-pointer">
31
+ <li>
32
+ <a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
33
+ <i class="pi pi-user-plus mr-2"></i>
34
+ <span class="font-medium">Add New</span>
35
+ </a>
36
+ </li>
37
+ <li class="relative">
38
+ <a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple"
39
+ v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'scalein', leaveToClass: 'hidden', leaveActiveClass: 'fadeout', hideOnOutsideClick: true }">
40
+ <i class="pi pi-search mr-2"></i>
41
+ <span class="font-medium">Search</span>
42
+ <i class="pi pi-angle-down ml-auto lg:-rotate-90"></i>
43
+ </a>
44
+ <ul class="list-none py-3 pl-3 m-0 lg:px-0 lg:py-0 border-round shadow-0 lg:shadow-2 lg:border-1 border-50 lg:absolute surface-overlay hidden origin-top w-full lg:w-15rem cursor-pointer left-100 top-0">
45
+ <li>
46
+ <a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
47
+ <i class="pi pi-shopping-cart mr-2"></i>
48
+ <span class="font-medium">Purchases</span>
49
+ </a>
50
+ </li>
51
+ <li class="relative">
52
+ <a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
53
+ <i class="pi pi-comments mr-2"></i>
54
+ <span class="font-medium">Messages</span>
55
+ </a>
56
+ </li>
57
+ </ul>
58
+ </li>
59
+ </ul>
60
+ </li>
61
+ <li>
62
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
63
+ <i class="pi pi-calendar mr-2"></i>
64
+ <span>Calendar</span>
65
+ </a>
66
+ </li>
67
+ <li>
68
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
69
+ <i class="pi pi-chart-line mr-2"></i>
70
+ <span>Stats</span>
71
+ </a>
72
+ </li>
73
+ </ul>
74
+ <ul class="list-none p-0 m-0 flex lg:align-items-center select-none flex-column lg:flex-row border-top-1 surface-border lg:border-top-none">
75
+ <li>
76
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
77
+ <i class="pi pi-inbox text-base lg:text-2xl mr-2 lg:mr-0"></i>
78
+ <span class="block lg:hidden font-medium">Inbox</span>
79
+ </a>
80
+ </li>
81
+ <li class="border-top-1 surface-border lg:border-top-none">
82
+ <a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
83
+ <img src="/images/empty-user-photo.svg" class="mr-3 lg:mr-0 border-circle" style="width: 28px; height: 28px"/>
84
+ <div class="block lg:hidden">
85
+ <div class="text-900 font-medium">Josephine Lillard</div>
86
+ <span class="text-600 font-medium text-sm">Marketing Specialist</span>
87
+ </div>
88
+ </a>
89
+ </li>
90
+ </ul>
91
+ </div>
92
+ </div>
93
+ </template>
94
+
95
+ <script setup>
96
+
97
+ import { NotificationsIcon } from "@live-change/user-frontend"
98
+
99
+ </script>
100
+
101
+ <style scoped>
102
+
103
+ </style>
@@ -0,0 +1,10 @@
1
+ <template>
2
+
3
+ </template>
4
+
5
+ <script setup>
6
+ </script>
7
+
8
+ <style scoped>
9
+
10
+ </style>
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <div class="w-full sm:w-9 md:w-8 lg:w-6 surface-card p-4 shadow-2 border-round">
3
+ <div class="text-center mb-5">
4
+ <div class="text-900 text-3xl font-medium mb-3">
5
+ Access Control
6
+ </div>
7
+ </div>
8
+
9
+ <div class="text-center">
10
+ <Button label="Invite with email" icon="pi pi-envelope" class="p-button mb-4" @click="inviteDialog = true" />
11
+ </div>
12
+
13
+ <InviteDialog v-if="isMounted"
14
+ :objectType="objectType" :object="object"
15
+ v-model:visible="inviteDialog"
16
+ :multiRole="multiRole"
17
+ :availableRoles="defaultInviteRoles" />
18
+
19
+ <AccessRequests :objectType="objectType" :object="object" :multiRole="multiRole"
20
+ :availableRoles="availableRoles" />
21
+
22
+ <AccessInvitations :objectType="objectType" :object="object" :multiRole="multiRole"
23
+ :availableRoles="availableRoles" />
24
+
25
+ <AccessList :objectType="objectType" :object="object" :multiRole="multiRole"
26
+ :availableRoles="availableRoles" />
27
+
28
+ <PublicAccess :objectType="objectType" :object="object" :multiRole="multiRole"
29
+ :availableSessionRoles="availablePublicSessionRoles ?? availablePublicRoles ?? availableRoles"
30
+ :availableUserRoles="availablePublicUserRoles ?? availablePublicRoles ?? availableRoles"
31
+ :availableRequestedRoles="availableRequestedRoles ?? availableRoles"
32
+ :sessionRolesVisible="sessionRolesVisible"
33
+ :userRolesVisible="userRolesVisible"
34
+ :requestedRolesVisible="requestedRolesVisible"
35
+ />
36
+
37
+ </div>
38
+ </template>
39
+
40
+ <script setup>
41
+ import Button from "primevue/button"
42
+
43
+ import InviteDialog from "../invite/InviteDialog.vue"
44
+ import AccessRequests from "./AccessRequests.vue"
45
+ import AccessInvitations from "./AccessInvitations.vue"
46
+ import AccessList from "./AccessList.vue"
47
+ import PublicAccess from "./PublicAccess.vue"
48
+
49
+ const {
50
+ object, objectType, paths,
51
+ availableRoles, availablePublicSessionRoles, availablePublicUserRoles, availableRequestedRoles,
52
+ defaultInviteRoles,
53
+ multiRole,
54
+ sessionRolesVisible, userRolesVisible, requestedRolesVisible
55
+ } = defineProps({
56
+ object: {
57
+ type: String,
58
+ required: true
59
+ },
60
+ objectType: {
61
+ type: String,
62
+ required: true
63
+ },
64
+ paths: {
65
+ type: Object,
66
+ default: () => ({
67
+ session_Session: (p, { session }) => p.userIdentification_Info({ session }),
68
+ user_User: (p, { user }) => p.userIdentification_Info({ user })
69
+ })
70
+ },
71
+ availableRoles: {
72
+ type: Array,
73
+ default: () => ['administrator', 'moderator', 'writer', 'reader']
74
+ },
75
+ availablePublicRoles: {
76
+ type: Array,
77
+ default: () => ['writer', 'reader']
78
+ },
79
+ availablePublicSessionRoles: {
80
+ type: Array
81
+ },
82
+ availablePublicUserRoles: {
83
+ type: Array
84
+ },
85
+ availableRequestedRoles: {
86
+ type: Array
87
+ },
88
+ defaultInviteRoles: {
89
+ type: Array,
90
+ default: () => ['reader']
91
+ },
92
+ multiRole: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ sessionRolesVisible: {
97
+ type: Boolean,
98
+ default: true
99
+ },
100
+ userRolesVisible: {
101
+ type: Boolean,
102
+ default: true
103
+ },
104
+ requestedRolesVisible: {
105
+ type: Boolean,
106
+ default: true
107
+ }
108
+ })
109
+
110
+ import { computed, watch, ref, onMounted } from 'vue'
111
+
112
+ const isMounted = ref(false)
113
+ onMounted(() => isMounted.value = true)
114
+
115
+ const inviteDialog = ref(false)
116
+
117
+ </script>
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <div v-if="synchronizedAccessInvitations.length > 0" class="mb-4">
3
+ <div class="text-900 font-medium text-xl mb-2">Access Invitations</div>
4
+ <div v-for="access of synchronizedAccessInvitations" :key="access.to"
5
+ class="flex flex-row flex-wrap align-items-center">
6
+ <div class="col-12 md:col-6 py-1">
7
+ <UserIdentification :ownerType="access.contactOrUserType" :owner="access.contactOrUser"
8
+ :data="access.identification" />
9
+ </div>
10
+ <div class="col-12 md:col-6 flex flex-row pr-0" v-if="isMounted">
11
+ <Dropdown v-if="!multiRole && (access.roles?.length ?? 0) <= 1" id="userPublicAccess" class="w-14em"
12
+ style="width: calc(100% - 2.357rem) !important"
13
+ :options="['none'].concat(availableRoles)"
14
+ :optionLabel="optionLabel"
15
+ :modelValue="access.roles?.[0] ?? 'none'"
16
+ @update:modelValue="newValue => access.roles = [newValue]"
17
+ :feedback="false" toggleMask />
18
+ <MultiSelect v-else id="userPublicAccess"
19
+ style="width: calc(100% - 2.357rem) !important"
20
+ :options="availableRoles"
21
+ :optionLabel="optionLabel"
22
+ v-model="access.roles"
23
+ :feedback="false" toggleMask />
24
+ <Button @click="deleteAccessInvitation(access)" icon="pi pi-times"
25
+ class="p-button-rounded p-button-text p-button-plain ml-2 px-3"
26
+ style="padding-top: 0.77rem" />
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </template>
31
+
32
+ <script setup>
33
+
34
+ import Button from "primevue/button"
35
+ import Dropdown from "primevue/dropdown"
36
+ import MultiSelect from "primevue/multiselect"
37
+
38
+ import { useToast } from 'primevue/usetoast'
39
+ const toast = useToast()
40
+ import { useConfirm } from 'primevue/useconfirm'
41
+ const confirm = useConfirm()
42
+
43
+ import { UserIdentification } from "@live-change/user-frontend"
44
+ import { synchronized, synchronizedList } from "@live-change/vue3-components"
45
+
46
+ import { computed, watch, ref, onMounted } from 'vue'
47
+
48
+ const { object, objectType, availableRoles, multiRole } = defineProps({
49
+ object: {
50
+ type: String,
51
+ required: true
52
+ },
53
+ objectType: {
54
+ type: String,
55
+ required: true
56
+ },
57
+ availableRoles: {
58
+ type: Array,
59
+ default: () => ['reader']
60
+ },
61
+ multiRole: {
62
+ type: Boolean,
63
+ default: false
64
+ }
65
+ })
66
+
67
+ const isMounted = ref(false)
68
+ onMounted(() => isMounted.value = true)
69
+
70
+ function optionLabel(option) {
71
+ if(option == 'none') return 'none'
72
+ return option
73
+ }
74
+
75
+ import { path, live, actions } from '@live-change/vue3-ssr'
76
+ const accessControlApi = actions().accessControl
77
+
78
+ const [ accessInvitations ] = await Promise.all([
79
+ live(path().accessControl.objectOwnedAccessInvitations({ object, objectType })
80
+ .with(access => path().userIdentification.sessionOrUserOwnedIdentification({
81
+ sessionOrUserType: access.contactOrUserType, sessionOrUser: access.contactOrUser
82
+ }).bind('identification'))
83
+ )
84
+ ])
85
+
86
+ const synchronizedAccessInvitationsList = synchronizedList({
87
+ source: accessInvitations,
88
+ update: accessControlApi.updateContactOrUserAndObjectOwnedAccessInvitation,
89
+ delete: accessControlApi.resetContactOrUserAndObjectOwnedAccessInvitation,
90
+ identifiers: { object, objectType },
91
+ objectIdentifiers: ({ to, sessionOrUser, sessionOrUserType }) =>
92
+ ({ accessInvitation: to, sessionOrUser, sessionOrUserType, object, objectType }),
93
+ onSave: () => toast.add({ severity: 'info', summary: 'Access invite saved', life: 1500 }),
94
+ recursive: true
95
+ })
96
+ const synchronizedAccessInvitations = synchronizedAccessInvitationsList.value
97
+
98
+ function deleteAccessInvitation(accessInvitation) {
99
+ console.log("DELETE ACCESS INVITE", accessInvitation)
100
+ confirm.require({
101
+ target: event.currentTarget,
102
+ message: `Do you want to delete user "${accessInvitation?.identification?.name ?? accessInvitation.to}" invitation?`,
103
+ icon: 'pi pi-info-circle',
104
+ acceptClass: 'p-button-danger',
105
+ accept: async () => {
106
+ await synchronizedAccessInvitationsList.delete(accessInvitation)
107
+ /*await accessControlApi.deleteObjectRelatedAccess({
108
+ access: access.to, object: access.object, objectType: access.objectType
109
+ })*/
110
+ toast.add({ severity:'info', summary: 'Invitation Deleted', life: 1500 })
111
+ },
112
+ reject: () => {
113
+ toast.add({ severity:'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 })
114
+ }
115
+ })
116
+ }
117
+
118
+ </script>