From 28f21975a19e45bfc94d81075ff56be5f363a428 Mon Sep 17 00:00:00 2001 From: Ashish Shetty <ashishbshetty@outlook.com> Date: Wed, 22 Feb 2023 13:58:58 +0100 Subject: [PATCH] New: Hint user organization affiliation --- src/components/coscine/CoscineFormGroup.vue | 5 ++ .../create-resource/Configuration.vue | 47 ++++++++++++++++++- src/modules/resource/i18n/de.ts | 4 ++ src/modules/resource/i18n/en.ts | 4 ++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/components/coscine/CoscineFormGroup.vue b/src/components/coscine/CoscineFormGroup.vue index a36f622c..53b653fc 100644 --- a/src/components/coscine/CoscineFormGroup.vue +++ b/src/components/coscine/CoscineFormGroup.vue @@ -34,6 +34,11 @@ </b-popover> </div> </template> + + <!-- Hint Text --> + <div id="hint" class="small text-muted"> + <slot name="hint" /> + </div> </b-form-group> </template> diff --git a/src/modules/resource/components/create-resource/Configuration.vue b/src/modules/resource/components/create-resource/Configuration.vue index adc1f181..ae33a8e5 100644 --- a/src/modules/resource/components/create-resource/Configuration.vue +++ b/src/modules/resource/components/create-resource/Configuration.vue @@ -57,6 +57,30 @@ v-model="selectedResourceType.iDisplayName" disabled /> + + <!-- Hint --> + <template #hint> + <!-- Logged in with ORCID --> + <i18n + v-if="externalUser" + path="page.createResource.configuration.labels.hintTextORCiD" + tag="span" + > + <template #userProfile> + <b-link :to="{ name: 'userprofile' }"> + {{ $t("breadcrumbs.user.profile") }} + </b-link> + </template> + </i18n> + <!-- Logged in with SSO --> + <span v-else> + {{ + $t("page.createResource.configuration.labels.hintTextSSO", { + organizationName: organizations[0], + }) + }} + </span> + </template> </CoscineFormGroup> <!-- Resource Description --> @@ -128,6 +152,8 @@ import type { ResourceTypeObject, } from "@coscine/api-client/dist/types/Coscine.Api.Resources"; import type { LabeledResourceObject, ResourceTypeOption } from "../../types"; +import useUserStore from "@/modules/user/store"; +import type { OrganizationObject } from "@coscine/api-client/dist/types/Coscine.Api.Organization"; export default defineComponent({ components: { @@ -156,8 +182,9 @@ export default defineComponent({ const mainStore = useMainStore(); const projectStore = useProjectStore(); const resourceStore = useResourceStore(); + const userStore = useUserStore(); - return { mainStore, projectStore, resourceStore }; + return { mainStore, projectStore, resourceStore, userStore }; }, data() { @@ -171,6 +198,24 @@ export default defineComponent({ isOwner(): boolean | undefined { return this.projectStore.currentUserRoleIsOwner; }, + organizations(): string[] { + if (this.userMemberships) { + return this.userMemberships + .filter((organization) => !(organization.url?.indexOf("#") !== -1)) // If does contain "#" it's a sub level organization, otherwise top level + .map((org) => (org.displayName ? org.displayName : "")) // Extract organization display name, could contain empty strings + .filter((n) => n); // Filter out empty strings, if any; + } + return []; + }, + organizationsSet(): boolean { + return this.organizations && this.organizations.length > 0; + }, + externalUser(): boolean { + return !this.organizationsSet; + }, + userMemberships(): null | OrganizationObject[] { + return this.userStore.userProfile.userMemberships; + }, resourceTypes(): LabeledResourceObject[] | null { const labeledResourceTypes: LabeledResourceObject[] = []; const resourceTypes = this.resourceStore.enabledResourceTypes; diff --git a/src/modules/resource/i18n/de.ts b/src/modules/resource/i18n/de.ts index 51554379..972be52a 100644 --- a/src/modules/resource/i18n/de.ts +++ b/src/modules/resource/i18n/de.ts @@ -20,6 +20,10 @@ export default { "Für weitere Informationen zu Ressourcentypen siehe", resourceTypePopoverUrl: "https://docs.coscine.de/de/rdm/resources/about/", + hintTextSSO: + "Die von Ihnen erstellbaren Ressourcentypen werden durch Ihre Zugehörigkeit zu Organisation {organizationName} beeinflusst. Bedienen Sie das Dropdown-Menü, um die für Sie verfügbaren Optionen zu sehen.", + hintTextORCiD: + "Die von Ihnen erstellbaren Ressourcentypen werden durch Ihre Zugehörigkeit zu einer Organisation beeinflusst. Verknüpfen Sie Ihr Organisationskonto unter {userProfile}, um mehr Optionen zu sehen", }, popover: { title: "Quota nicht ausreichend", diff --git a/src/modules/resource/i18n/en.ts b/src/modules/resource/i18n/en.ts index 6e92be96..9191a70f 100644 --- a/src/modules/resource/i18n/en.ts +++ b/src/modules/resource/i18n/en.ts @@ -20,6 +20,10 @@ export default { resourceTypePopover: "For more information on resource types see", resourceTypePopoverUrl: "https://docs.coscine.de/en/rdm/resources/about/", + hintTextSSO: + "The resource types you can create are impacted by your affiliation with {organizationName}. Check the dropdown menu to see the options available to you.", + hintTextORCiD: + "The resource types you can create are impacted by your affiliation. Merge your organization account under {userProfile} to make more options available to you", }, popover: { title: "Quota not sufficient", -- GitLab