|
3 | 3 | <template> |
4 | 4 | <div |
5 | 5 | class="organization-request" |
6 | | - :class="request.status" |
| 6 | + :class="{ |
| 7 | + pending: request.info.tag === PKIInfoItemTag.Submitted, |
| 8 | + rejected: request.info.tag === PKIInfoItemTag.Rejected, |
| 9 | + accepted: request.info.tag === PKIInfoItemTag.Accepted, |
| 10 | + cancelled: request.info.tag === PKIInfoItemTag.Cancelled, |
| 11 | + }" |
7 | 12 | > |
8 | 13 | <ion-card-content class="organization-request-content"> |
9 | 14 | <div class="organization-request-info"> |
10 | | - <ion-text class="organization-request-organization title-h4">{{ request.organization }}</ion-text> |
11 | | - <ion-text class="organization-request-username body">{{ request.humanHandle.label }}</ion-text> |
| 15 | + <ion-text class="organization-request-organization title-h4">{{ addr?.organizationId ?? '' }}</ion-text> |
| 16 | + <ion-text class="organization-request-username body">{{ request.enrollment.payload.humanHandle.label }}</ion-text> |
12 | 17 | </div> |
13 | 18 | <div class="organization-request-status-container"> |
14 | 19 | <ion-text |
15 | 20 | class="organization-request-status button-small" |
16 | | - :class="`status-${request.status}`" |
17 | | - ref="statusText" |
| 21 | + :class="{ |
| 22 | + 'status-pending': request.info.tag === PKIInfoItemTag.Submitted, |
| 23 | + 'status-rejected': request.info.tag === PKIInfoItemTag.Rejected, |
| 24 | + 'status-accepted': request.info.tag === PKIInfoItemTag.Accepted, |
| 25 | + 'status-cancelled': request.info.tag === PKIInfoItemTag.Cancelled, |
| 26 | + }" |
| 27 | + ref="statusTextEl" |
18 | 28 | > |
19 | 29 | <span v-if="statusText">{{ $msTranslate(statusText) }}</span> |
20 | 30 | </ion-text> |
21 | 31 | <ion-icon |
22 | | - v-if="request.status !== JoinRequestStatus.Accepted" |
| 32 | + v-if="request.info.tag !== PKIInfoItemTag.Accepted" |
23 | 33 | @click="$emit('deleteRequest', request)" |
24 | 34 | :icon="closeCircle" |
25 | 35 | class="organization-request-icon" |
26 | 36 | /> |
27 | 37 | <ion-button |
28 | | - v-if="request.status === JoinRequestStatus.Accepted" |
| 38 | + v-if="request.info.tag === PKIInfoItemTag.Accepted" |
29 | 39 | fill="clear" |
30 | 40 | class="organization-request-button" |
31 | 41 | @click="$emit('joinOrganization', request)" |
|
42 | 52 | </template> |
43 | 53 |
|
44 | 54 | <script lang="ts" setup> |
45 | | -import { JoinRequestStatus, LocalJoinRequest } from '@/parsec'; |
| 55 | +import { ParsedParsecAddrPkiEnrollment, ParsedParsecAddrTag, parseParsecAddr, PKIInfoItemTag, PkiLocalRequest } from '@/parsec'; |
46 | 56 | import { IonButton, IonCardContent, IonIcon, IonText } from '@ionic/vue'; |
47 | 57 | import { arrowForward, closeCircle } from 'ionicons/icons'; |
48 | 58 | import { attachMouseOverTooltip } from 'megashark-lib'; |
49 | | -import { computed, onMounted, useTemplateRef, watch } from 'vue'; |
| 59 | +import { computed, onMounted, ref, useTemplateRef, watch } from 'vue'; |
50 | 60 |
|
51 | | -const statusTextRef = useTemplateRef<InstanceType<typeof IonText>>('statusText'); |
| 61 | +const statusTextRef = useTemplateRef<InstanceType<typeof IonText>>('statusTextEl'); |
| 62 | +const addr = ref<ParsedParsecAddrPkiEnrollment | undefined>(undefined); |
52 | 63 |
|
53 | 64 | const props = defineProps<{ |
54 | | - request: LocalJoinRequest; |
| 65 | + request: PkiLocalRequest; |
55 | 66 | }>(); |
56 | 67 |
|
57 | 68 | onMounted(async () => { |
58 | | - if (statusTextRef.value && props.request.status === JoinRequestStatus.Pending) { |
59 | | - attachMouseOverTooltip(statusTextRef.value.$el, 'HomePage.organizationRequest.pending.tooltip'); |
60 | | - } else if (statusTextRef.value && props.request.status === JoinRequestStatus.Rejected) { |
61 | | - attachMouseOverTooltip(statusTextRef.value.$el, 'HomePage.organizationRequest.rejected.tooltip'); |
| 69 | + attachTooltip(statusTextRef.value?.$el, props.request.info.tag); |
| 70 | + const addrResult = await parseParsecAddr(props.request.enrollment.addr); |
| 71 | + if (addrResult.ok && addrResult.value.tag === ParsedParsecAddrTag.PkiEnrollment) { |
| 72 | + addr.value = addrResult.value; |
62 | 73 | } |
63 | 74 | }); |
64 | 75 |
|
65 | 76 | watch( |
66 | | - () => props.request.status, |
| 77 | + () => props.request.info.tag, |
67 | 78 | (newStatus) => { |
68 | | - if (statusTextRef.value && newStatus === JoinRequestStatus.Pending) { |
69 | | - attachMouseOverTooltip(statusTextRef.value.$el, 'HomePage.organizationRequest.pending.tooltip'); |
70 | | - } else if (statusTextRef.value && newStatus === JoinRequestStatus.Rejected) { |
71 | | - attachMouseOverTooltip(statusTextRef.value.$el, 'HomePage.organizationRequest.rejected.tooltip'); |
72 | | - } |
| 79 | + attachTooltip(statusTextRef.value?.$el, newStatus); |
73 | 80 | }, |
74 | 81 | ); |
75 | 82 |
|
| 83 | +function attachTooltip(el: HTMLElement | undefined, status: PKIInfoItemTag): void { |
| 84 | + if (!el) { |
| 85 | + return; |
| 86 | + } |
| 87 | + if (status === PKIInfoItemTag.Submitted) { |
| 88 | + attachMouseOverTooltip(el, 'HomePage.organizationRequest.pending.tooltip'); |
| 89 | + } else if (status === PKIInfoItemTag.Rejected) { |
| 90 | + attachMouseOverTooltip(el, 'HomePage.organizationRequest.rejected.tooltip'); |
| 91 | + } else if (status === PKIInfoItemTag.Cancelled) { |
| 92 | + attachMouseOverTooltip(el, 'HomePage.organizationRequest.cancelled.tooltip'); |
| 93 | + } else if (status === PKIInfoItemTag.Accepted) { |
| 94 | + attachMouseOverTooltip(el, 'HomePage.organizationRequest.accepted.tooltip'); |
| 95 | + } |
| 96 | +} |
| 97 | +
|
76 | 98 | defineEmits<{ |
77 | | - (e: 'joinOrganization', request: LocalJoinRequest): void; |
78 | | - (e: 'deleteRequest', request: LocalJoinRequest): void; |
| 99 | + (e: 'joinOrganization', request: PkiLocalRequest): void; |
| 100 | + (e: 'deleteRequest', request: PkiLocalRequest): void; |
79 | 101 | }>(); |
80 | 102 |
|
81 | 103 | const statusText = computed(() => { |
82 | | - switch (props.request.status) { |
83 | | - case JoinRequestStatus.Pending: |
| 104 | + switch (props.request.info.tag) { |
| 105 | + case PKIInfoItemTag.Submitted: |
84 | 106 | return 'HomePage.organizationRequest.status.pending'; |
85 | | - case JoinRequestStatus.Rejected: |
| 107 | + case PKIInfoItemTag.Rejected: |
86 | 108 | return 'HomePage.organizationRequest.status.rejected'; |
87 | | - case JoinRequestStatus.Cancelled: |
| 109 | + case PKIInfoItemTag.Cancelled: |
88 | 110 | return 'HomePage.organizationRequest.status.cancelled'; |
89 | 111 | default: |
90 | 112 | return undefined; |
@@ -149,16 +171,20 @@ const statusText = computed(() => { |
149 | 171 | padding: 0.125rem 0.5rem; |
150 | 172 | flex-shrink: 0; |
151 | 173 |
|
152 | | - &.status-pending { |
| 174 | + &.status-cancelled { |
153 | 175 | background-color: var(--parsec-color-light-secondary-grey); |
154 | 176 | color: var(--parsec-color-light-secondary-white); |
155 | 177 | } |
156 | 178 |
|
157 | | - &.status-rejected, |
158 | | - &.status-cancelled { |
| 179 | + &.status-rejected { |
159 | 180 | background-color: var(--parsec-color-light-danger-500); |
160 | 181 | color: var(--parsec-color-light-secondary-white); |
161 | 182 | } |
| 183 | +
|
| 184 | + &.status-pending { |
| 185 | + background-color: var(--parsec-color-light-warning-100); |
| 186 | + color: var(--parsec-color-light-warning-700); |
| 187 | + } |
162 | 188 | } |
163 | 189 |
|
164 | 190 | .organization-request-icon { |
@@ -205,7 +231,7 @@ const statusText = computed(() => { |
205 | 231 | border-color: var(--parsec-color-light-secondary-light); |
206 | 232 |
|
207 | 233 | .organization-request-icon { |
208 | | - color: var(--parsec-color-light-secondary-light); |
| 234 | + color: var(--parsec-color-light-secondary-grey); |
209 | 235 |
|
210 | 236 | &:hover { |
211 | 237 | color: var(--parsec-color-light-secondary-text); |
|
0 commit comments