-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into audit-backend
- Loading branch information
Showing
7 changed files
with
206 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<template> | ||
<v-menu | ||
offset-y | ||
left | ||
> | ||
<template | ||
#activator="{ on, attrs }" | ||
> | ||
<v-btn | ||
id="contact" | ||
outlined | ||
block | ||
v-bind="attrs" | ||
v-on="on" | ||
> | ||
<v-icon | ||
color="primary" | ||
left | ||
> | ||
mdi-card-account-mail | ||
</v-icon> | ||
<span>Contact</span> | ||
<v-spacer /> | ||
<v-icon right> | ||
mdi-chevron-down | ||
</v-icon> | ||
</v-btn> | ||
</template> | ||
<v-card | ||
> | ||
<v-card-title class="pb-0" style="min-width: fit-content;"> | ||
Select an e-mail recipient: | ||
</v-card-title> | ||
<v-list> | ||
<v-tooltip | ||
:disabled="!disableDandisetOwnersButton" | ||
open-on-hover | ||
left | ||
> | ||
<template #activator="{ on }"> | ||
<div | ||
v-on="on" | ||
> | ||
<v-list-item | ||
:disabled="disableDandisetOwnersButton" | ||
:href="makeTemplate(dandisetOwnerEmails)" | ||
> | ||
<v-icon | ||
color="primary" | ||
left | ||
small | ||
> | ||
mdi-card-account-mail | ||
</v-icon> | ||
Dandiset Owners | ||
</v-list-item> | ||
</div> | ||
</template> | ||
<span v-if="!loggedIn()"> You must be logged in to contact the owner </span> | ||
<span v-if="!dandisetOwnerEmails?.length"> No owner e-mail available </span> | ||
</v-tooltip> | ||
<v-divider /> | ||
<v-tooltip | ||
:disabled="!disableContactPersonButton" | ||
open-on-hover | ||
left | ||
> | ||
<template #activator="{ on }"> | ||
<div v-on="on"> | ||
<v-list-item | ||
:disabled="disableContactPersonButton" | ||
:href="makeTemplate(dandisetContactPersonEmails)" | ||
> | ||
<v-icon | ||
color="primary" | ||
left | ||
small | ||
> | ||
mdi-card-account-mail | ||
</v-icon> | ||
Dandiset Contact Person | ||
</v-list-item> | ||
</div> | ||
</template> | ||
<span> No contact e-mail available </span> | ||
</v-tooltip> | ||
</v-list> | ||
</v-card> | ||
</v-menu> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import { useDandisetStore } from '@/stores/dandiset'; | ||
import { loggedIn } from '@/rest'; | ||
import type { User, Person, Organization, Email} from '@/types'; | ||
const store = useDandisetStore(); | ||
const currentDandiset = computed(() => store.dandiset); | ||
const dandisetOwnerEmails = computed(() => store.owners?.map((owner: User) => owner.email) || []); | ||
const dandisetContactPersonEmails = computed(() => | ||
currentDandiset.value?.metadata?.contributor?.filter( | ||
(contact: Person | Organization) => | ||
contact.roleName?.includes("dcite:ContactPerson") | ||
) | ||
.map((contact: Person | Organization) => | ||
contact.email as Email | ||
) | ||
// Exclude users missing an email | ||
.filter((email?: Email) => email !== undefined) | ||
// Exclude users with an empty email | ||
.filter((email: Email) => email !== '') | ||
|| [] | ||
); | ||
|
||
const makeTemplate = (contacts: string[]) => { | ||
if (currentDandiset.value === undefined) { | ||
throw new Error('Dandiset is undefined.'); | ||
} | ||
if (currentDandiset.value){ | ||
const subject = encodeURIComponent(`Regarding Dandiset ${currentDandiset.value.dandiset.identifier} ("${currentDandiset.value.name}")`); | ||
const contact = contacts.join(','); | ||
return `mailto:${contact}?subject=${subject}`; | ||
} | ||
}; | ||
|
||
const disableContactPersonButton = computed(() => !dandisetContactPersonEmails.value?.length) | ||
const disableDandisetOwnersButton = computed( | ||
// Only logged in users can access owners' emails | ||
() => !loggedIn() || !dandisetOwnerEmails.value?.length | ||
); | ||
|
||
</script> | ||
<style scoped> | ||
.v-btn--outlined { | ||
border: thin solid #E0E0E0; | ||
color: #424242; | ||
font-weight: 400; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters