Skip to content
Snippets Groups Projects
Commit 39de9951 authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Minor fixes from internal testing

parent 1012700b
Branches
Tags
2 merge requests!260Dev,!258Fix: Minor fixes from internal testing
Showing
with 212 additions and 135 deletions
......@@ -5,6 +5,7 @@
},
"cSpell.words": [
"Coscine",
"Orcid",
"pinia",
"RWTH",
"vite",
......
......@@ -11,9 +11,9 @@
{{ `${messageType}${$t("banner.separator")}` }}
</span>
{{ messageBody }}
<span v-if="maintenance.url">
<span v-if="maintenance.href">
{{ $t("banner.maintenance.linkText") }}
<a :href="maintenance.url" target="_blank"
<a :href="maintenance.href" target="_blank"
>{{ $t("banner.maintenance.moreInformation") }}
</a>
</span>
......
......@@ -18,19 +18,20 @@ import useUserStore from "@/modules/user/store";
import { loadingCounterEventHandler } from "@/plugins/loadingCounter";
import { defineComponent } from "vue";
import type { StoreDefinition } from "pinia";
export default defineComponent({
setup() {
const mainStore = useMainStore();
loadingCounterEventHandler(useAdminStore);
loadingCounterEventHandler(useErrorStore);
loadingCounterEventHandler(useLoginStore);
loadingCounterEventHandler(usePidStore);
loadingCounterEventHandler(useProjectStore);
loadingCounterEventHandler(useResourceStore);
loadingCounterEventHandler(useSearchStore);
loadingCounterEventHandler(useUserStore);
loadingCounterEventHandler(useAdminStore as unknown as StoreDefinition);
loadingCounterEventHandler(useErrorStore as unknown as StoreDefinition);
loadingCounterEventHandler(useLoginStore as unknown as StoreDefinition);
loadingCounterEventHandler(usePidStore as unknown as StoreDefinition);
loadingCounterEventHandler(useProjectStore as unknown as StoreDefinition);
loadingCounterEventHandler(useResourceStore as unknown as StoreDefinition);
loadingCounterEventHandler(useSearchStore as unknown as StoreDefinition);
loadingCounterEventHandler(useUserStore as unknown as StoreDefinition);
return { mainStore };
},
......
import type {
FileDto,
MetadataDto,
FileTreeDto,
MetadataTreeDto,
TreeDataType,
} from "@coscine/api-client/dist/types/Coscine.Api";
export const getMetadataTreeResponse: MetadataDto[] = [
export const getMetadataTreeResponse: MetadataTreeDto[] = [
{
version: "1693212042",
availableVersions: ["1693212042"],
definition:
definition: {
content:
'@base <https://purl.org/coscine/resources/4103cbea-ffa3-40a5-9e5c-b99cc16f0007/folder_1/folder_2/A.txt/@type=metadata&version=1693212042>.\r\n\r\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\r\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\r\n@prefix ns2: <http://purl.org/dc/terms/>.\r\n\r\n_:b8477997 ns2:created "2023-08-15"^^xsd:date;\r\n ns2:creator "Petar Hristov";\r\n ns2:title "Title inside Form Generator";\r\n a <https://purl.org/coscine/ap/base/>.\r\n',
format: "text/turtle",
type: "text/turtle",
},
path: "folder_1/folder_2/A.txt",
type: "Leaf" as TreeDataType.Leaf,
},
{
version: "1692777419",
availableVersions: ["1692777419"],
definition:
definition: {
content:
'@base <https://purl.org/coscine/resources/4103cbea-ffa3-40a5-9e5c-b99cc16f0007/file_1.txt/@type=metadata&version=1692777419>.\r\n\r\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\r\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\r\n@prefix ns2: <http://purl.org/dc/terms/>.\r\n\r\n_:b8425359 ns2:created "2023-08-18"^^xsd:date;\r\n ns2:creator "Petar Hristov";\r\n ns2:title "file_1";\r\n a <https://purl.org/coscine/ap/base/>.\r\n',
format: "text/turtle",
type: "text/turtle",
},
path: "file_1.txt",
type: "Leaf" as TreeDataType.Leaf,
},
......@@ -32,25 +36,29 @@ export const getMetadataTreeResponse: MetadataDto[] = [
"1692341031",
"1692779210",
],
definition:
definition: {
content:
'@base <https://purl.org/coscine/resources/4103cbea-ffa3-40a5-9e5c-b99cc16f0007/file_0.txt/@type=metadata&version=1692779210>.\r\n\r\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\r\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\r\n@prefix ns2: <http://purl.org/dc/terms/>.\r\n\r\n_:b8425361 ns2:created "2023-08-18"^^xsd:date;\r\n ns2:creator "Petar Hristov";\r\n ns2:title "Revised";\r\n a <https://purl.org/coscine/ap/base/>.\r\n',
format: "text/turtle",
type: "text/turtle",
},
path: "file_0.txt",
type: "Leaf" as TreeDataType.Leaf,
},
{
version: "1693209938",
availableVersions: ["1693209938"],
definition:
definition: {
content:
'@base <https://purl.org/coscine/resources/4103cbea-ffa3-40a5-9e5c-b99cc16f0007/my_folder/file_of_folder.txt/@type=metadata&version=1693209938>.\r\n\r\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\r\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\r\n@prefix ns2: <http://purl.org/dc/terms/>.\r\n\r\n_:b8477996 ns2:created "2023-08-15"^^xsd:date;\r\n ns2:creator "Petar Hristov";\r\n ns2:title "From Insomnia";\r\n a <https://purl.org/coscine/ap/base/>.\r\n',
format: "text/turtle",
type: "text/turtle",
},
path: "my_folder/file_of_folder.txt",
type: "Leaf" as TreeDataType.Leaf,
},
];
export const getFileTreeResponse: FileDto[] = [
export const getFileTreeResponse: FileTreeDto[] = [
{
parentDirectory: "",
directory: "",
name: "folder_1",
size: 0,
creationDate: "2023-09-01T16:57:48.2525218+02:00",
......@@ -59,7 +67,7 @@ export const getFileTreeResponse: FileDto[] = [
type: "Tree" as TreeDataType.Tree,
},
{
parentDirectory: "",
directory: "",
name: "my_folder",
size: 0,
creationDate: "2023-09-01T16:57:48.2525245+02:00",
......@@ -68,7 +76,7 @@ export const getFileTreeResponse: FileDto[] = [
type: "Tree" as TreeDataType.Tree,
},
{
parentDirectory: "",
directory: "",
name: "file_0.txt",
extension: "txt",
size: 2513352,
......
......@@ -2,9 +2,8 @@ import { type LoginState } from "@/modules/login/types";
import { useLocalStorage } from "@vueuse/core";
export const testLoginState: LoginState = {
currentTosVersion: "1",
currentTosVersion: { version: "1", isCurrent: true },
expiredSession: false,
tosAccepted: { version: ["1"] },
loginStoredData: useLocalStorage("coscine.login.storedData", ""),
loginUrls: {
orcidUrl: "http://example.org",
......
import { userMapper, PublicUserDto2ProjectRoleUserDto } from "@/mapping/user";
import {
type VisitedProjectDto,
type ProjectState,
} from "@/modules/project/types";
import type { RoleDto } from "@coscine/api-client/dist/types/Coscine.Api";
import { testDiscipline, testOrganization, getTestUser } from "./testUser";
import {
testDiscipline,
testOrganizationFromShibboleth,
getTestShibbolethUser,
} from "./testUser";
export const testOwnerRole: RoleDto = {
id: "ownerRole",
......@@ -26,13 +29,13 @@ export const testSlug = "testProject";
export const testProject: VisitedProjectDto = {
id: "987654321",
displayName: "Test Project",
projectName: "Test Project Full",
name: "Test Project Full",
description: "Test Project Description",
principleInvestigators: "Test PI",
startDate: "2023-01-01",
endDate: "2033-01-01",
disciplines: [testDiscipline],
organizations: [testOrganization],
organizations: [testOrganizationFromShibboleth],
visibility: { id: "1234", displayName: "Project Members" },
slug: testSlug,
invitations: [],
......@@ -45,13 +48,13 @@ export const testProject: VisitedProjectDto = {
],
roles: [
{
projectId: "987654321",
project: { id: "987654321" },
role: testOwnerRole,
user: userMapper.map(PublicUserDto2ProjectRoleUserDto, getTestUser()),
user: getTestShibbolethUser(),
},
], // TODO: Beware the object types!
subProjects: [],
creator: getTestUser().id,
creator: { id: getTestShibbolethUser().id },
};
export const testProjectState: ProjectState = {
......@@ -59,7 +62,7 @@ export const testProjectState: ProjectState = {
currentSlug: testSlug,
disciplines: [testDiscipline],
licenses: [{ id: "452545", displayName: "TestLicense" }],
organizations: [testOrganization],
organizations: [testOrganizationFromShibboleth],
roles: [testOwnerRole, testMemberRole, testGuestRole],
topLevelProjects: [testProject],
visibilities: [
......
......@@ -8,7 +8,7 @@ import {
baseApplicationProfileFormat,
} from "./metadata/applicationProfile";
import { radarFixedValues } from "./metadata/fixedValues";
import { testDiscipline, getTestUser } from "./testUser";
import { testDiscipline, getTestShibbolethUser } from "./testUser";
import type {
ResourceTypeInformationDto,
ResourceTypeStatus,
......@@ -50,9 +50,9 @@ export const getTestResource: () => Promise<VisitedResourceObject> =
apUrl
);
const resourceObject: VisitedResourceObject = {
applicationProfile: apUrl,
applicationProfile: { uri: apUrl },
archived: false,
creator: getTestUser().id,
creator: getTestShibbolethUser().id,
dateCreated: null,
description: "TestResource",
disciplines: [testDiscipline],
......@@ -64,13 +64,13 @@ export const getTestResource: () => Promise<VisitedResourceObject> =
license: {},
pid: "21.11102/eeb8d803-46a1-49ba-a47c-81cd4f49cd65",
rawApplicationProfile: ap,
resourceName: "TestResource",
name: "TestResource",
storedColumns: null,
type: {
specificType: testResourceType.specificType,
specificType: testResourceType.specificType ?? undefined,
id: testResourceType.id,
options: {
gitLabOptions: {},
gitLab: {},
},
},
usageRights: "",
......
......@@ -2,48 +2,112 @@ import { type UserState } from "@/modules/user/types";
import type {
DisciplineDto,
UserDto,
UserInstituteDto,
UserOrganizationDto,
} from "@coscine/api-client/dist/types/Coscine.Api/api";
export const testOrganization: UserOrganizationDto = {
name: "TestOrg",
readOnly: true,
rorUri: "example.com",
export const testOrganizationFromShibboleth: UserOrganizationDto = {
displayName: "Test SSO Organization",
readOnly: true, // Shibboleth organizations are always read-only
uri: "example.com",
};
export const testInstitute: UserOrganizationDto = {
name: "TestInstitute",
readOnly: true,
rorUri: "example.com#institute",
export const testInstituteFromShibboleth: UserInstituteDto = {
displayName: "Test SSO Institute",
readOnly: true, // Shibboleth institutes are always read-only
uri: "example.com#institute",
};
export const testOrganizationFromOrcid: UserOrganizationDto = {
displayName: "Test ORCiD Organization",
readOnly: true, // ORCiD organizations are never read-only
uri: "example.com",
};
export const testInstituteFromOrcid: UserInstituteDto = {
displayName: "Test ORCiD Institute",
readOnly: true, // ORCiD institutes are never read-only
uri: "example.com#institute",
};
export const testDiscipline: DisciplineDto = {
id: "1",
displayNameDe: "Test",
displayNameEn: "Test",
url: "example.com",
uri: "example.com",
};
export const testLanguage = { id: "1", displayName: "en" };
export const getTestUser: () => UserDto = () => {
/**
* Generates a mock Shibboleth user data object for testing purposes.
*
* @returns {UserDto} A mock Shibboleth user data object.
*/
export const getTestShibbolethUser: () => UserDto = () => {
return {
id: "d302cb44-c934-4b54-a581-9765cab96fca",
lastName: "Coscine",
firstName: "Example",
givenName: "Coscine",
familyName: "Example",
displayName: "Coscine Example",
email: "example@example.com",
emails: [
{ email: "example@university.com", isConfirmed: true, isPrimary: true },
],
disciplines: [testDiscipline],
language: testLanguage,
organizations: [testOrganization],
institutes: [testInstitute],
organizations: [testOrganizationFromShibboleth],
institutes: [testInstituteFromShibboleth],
};
};
/**
* Generates a mock ORCID user data object for testing purposes.
*
* @returns {UserDto} A mock ORCID user data object.
*/
export const getTestOrcidUser: () => UserDto = () => {
return {
id: "d302cb44-c934-4b54-a581-9765cab96fca",
givenName: "Coscine",
familyName: "Example",
displayName: "Coscine Example",
emails: [
{ email: "example@orcid.com", isConfirmed: true, isPrimary: true },
],
disciplines: [testDiscipline],
language: testLanguage,
organizations: [testOrganizationFromOrcid],
institutes: [testInstituteFromOrcid],
};
};
export const getTestShibbolethUserState: () => UserState = () => {
return {
userProfile: {
disciplines: [testDiscipline],
languages: [testLanguage, { id: "2", displayName: "de" }],
organizations: [testOrganizationFromShibboleth],
institutes: [testInstituteFromShibboleth],
titles: [
{
id: "1",
displayName: "Prof.",
},
{
id: "2",
displayName: "Dr.",
},
],
tokens: null,
},
user: getTestShibbolethUser(),
};
};
export const getTestUserState: () => UserState = () => {
export const getTestOrcidUserState: () => UserState = () => {
return {
userProfile: {
disciplines: [testDiscipline],
languages: [testLanguage, { id: "2", displayName: "de" }],
organizations: [testOrganization],
institutes: [testInstitute],
organizations: [testOrganizationFromShibboleth],
institutes: [testInstituteFromShibboleth],
titles: [
{
id: "1",
......@@ -56,6 +120,6 @@ export const getTestUserState: () => UserState = () => {
],
tokens: null,
},
user: getTestUser(),
user: getTestOrcidUser(),
};
};
......@@ -24,6 +24,7 @@ export const OrganizationDto2OrganizationForProjectManipulationDto =
const configuration = new MapperConfiguration((cfg) => {
cfg.createAutoMap(ProjectDto2ProjectForUpdateDto, {
name: (opt) => opt.mapFrom((e) => e.name ?? ""),
disciplines: (opt) =>
opt.mapFromUsing(
(e) => e.disciplines,
......@@ -45,7 +46,9 @@ const configuration = new MapperConfiguration((cfg) => {
.createAutoMap(VisibilityDto2VisibilityForProjectManipulationDto, {})
.forSourceMember("displayName", (opt) => opt.ignore());
cfg.createAutoMap(DisciplineDto2DisciplineForProjectManipulationDto, {});
cfg.createAutoMap(OrganizationDto2OrganizationForProjectManipulationDto, {});
cfg.createAutoMap(OrganizationDto2OrganizationForProjectManipulationDto, {
uri: (opt) => opt.mapFrom((e) => e.uri ?? ""),
});
});
export const projectMapper = configuration.createMapper();
......@@ -70,6 +70,8 @@ export const ResourceTypeInformationDto2ResourceTypeOptionsForCreationDto =
const configuration = new MapperConfiguration((cfg) => {
cfg.createAutoMap(ResourceDto2ResourceForUpdateDto, {
name: (opt) => opt.mapFrom((e) => e.name ?? ""),
usageNote: (opt) => opt.mapFrom((e) => e.usageRights),
license: (opt) =>
opt.mapFromUsing(
(e) => e.license,
......@@ -98,31 +100,31 @@ const configuration = new MapperConfiguration((cfg) => {
gitlabResourceTypeOptions: (opt) =>
opt
.mapFromUsing(
(e) => e.gitLabOptions,
(e) => e.gitLab,
GitLabOptionsDto2GitlabResourceTypeOptionsForUpdateDto
)
.condition((con) => con.gitLabOptions !== undefined),
.condition((con) => con.gitLab !== undefined),
rdsResourceTypeOptions: (opt) =>
opt
.mapFromUsing(
(e) => e.rdsOptions,
(e) => e.rds,
RdsOptionsDto2RdsResourceTypeOptionsForManipulationDto
)
.condition((con) => con.rdsOptions !== undefined),
.condition((con) => con.rds !== undefined),
rdsS3ResourceTypeOptions: (opt) =>
opt
.mapFromUsing(
(e) => e.rdsS3Options,
(e) => e.rdsS3,
RdsS3OptionsDto2RdsS3ResourceTypeOptionsForManipulationDto
)
.condition((con) => con.rdsS3Options !== undefined),
.condition((con) => con.rdsS3 !== undefined),
rdsS3WormResourceTypeOptions: (opt) =>
opt
.mapFromUsing(
(e) => e.rdsS3WormOptions,
(e) => e.rdsS3Worm,
RdsS3WormOptionsDto2RdsS3WormResourceTypeOptionsForManipulationDto
)
.condition((con) => con.rdsS3WormOptions !== undefined),
.condition((con) => con.rdsS3Worm !== undefined),
});
cfg.createMap(ResourceTypeInformationDto2ResourceTypeOptionsForCreationDto, {
linkedResourceTypeOptions: (opt) =>
......@@ -176,20 +178,20 @@ const configuration = new MapperConfiguration((cfg) => {
});
cfg.createAutoMap(GitLabOptionsDto2GitlabResourceTypeOptionsForUpdateDto, {});
cfg.createAutoMap(RdsOptionsDto2RdsResourceTypeOptionsForManipulationDto, {
size: (opt) =>
quota: (opt) =>
opt.mapFromUsing((e) => e.size, QuotaDto2QuotaForManipulationDto),
});
cfg.createAutoMap(
RdsS3OptionsDto2RdsS3ResourceTypeOptionsForManipulationDto,
{
size: (opt) =>
quota: (opt) =>
opt.mapFromUsing((e) => e.size, QuotaDto2QuotaForManipulationDto),
}
);
cfg.createAutoMap(
RdsS3WormOptionsDto2RdsS3WormResourceTypeOptionsForManipulationDto,
{
size: (opt) =>
quota: (opt) =>
opt.mapFromUsing((e) => e.size, QuotaDto2QuotaForManipulationDto),
}
);
......
......@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from "uuid";
import type {
TreeDataType,
FileDto,
FileTreeDto,
} from "@coscine/api-client/dist/types/Coscine.Api";
import type {
FileInformation,
......@@ -11,12 +11,12 @@ import type {
} from "@/modules/resource/types";
export const TreeDto2FileInformation = new MappingPair<
FileDto,
FileTreeDto,
FileInformation
>();
export const TreeDto2FolderInformation = new MappingPair<
FileDto,
FileTreeDto,
FolderInformation
>();
......@@ -24,7 +24,7 @@ const configuration = new MapperConfiguration((cfg) => {
cfg.createMap(TreeDto2FileInformation, {
id: (opt) => opt.mapFrom((_) => uuidv4()),
name: (opt) => opt.mapFrom((dto) => dto.name ?? ""),
parentDirectory: (opt) => opt.mapFrom((dto) => dto.parentDirectory ?? ""),
parentDirectory: (opt) => opt.mapFrom((dto) => dto.directory ?? ""),
path: (opt) => opt.mapFrom((dto) => dto.path ?? ""),
type: (opt) => opt.mapFrom((_) => "Leaf" as TreeDataType.Leaf),
isFolder: (opt) => opt.mapFrom((_) => false),
......@@ -38,7 +38,7 @@ const configuration = new MapperConfiguration((cfg) => {
cfg.createMap(TreeDto2FolderInformation, {
id: (opt) => opt.mapFrom((_) => uuidv4()),
name: (opt) => opt.mapFrom((dto) => dto.name ?? ""),
parentDirectory: (opt) => opt.mapFrom((dto) => dto.parentDirectory ?? ""),
parentDirectory: (opt) => opt.mapFrom((dto) => dto.directory ?? ""),
path: (opt) => opt.mapFrom((dto) => dto.path ?? ""),
type: (opt) => opt.mapFrom((_) => "Tree" as TreeDataType.Tree),
isFolder: (opt) => opt.mapFrom((_) => true),
......
......@@ -5,18 +5,12 @@ import type {
DisciplineForUserManipulationDto,
LanguageDto,
LanguageForUserManipulationDto,
ProjectRoleUserDto,
PublicUserDto,
TitleDto,
TitleForUserManipulationDto,
UserDto,
UserForUpdateDto,
} from "@coscine/api-client/dist/types/Coscine.Api";
export const PublicUserDto2ProjectRoleUserDto = new MappingPair<
PublicUserDto,
ProjectRoleUserDto
>();
export const UserDto2UserForUpdateDto = new MappingPair<
UserDto,
UserForUpdateDto
......@@ -35,16 +29,11 @@ export const LanguageDto2LanguageForUserManipulationDto = new MappingPair<
>();
const configuration = new MapperConfiguration((cfg) => {
cfg.createAutoMap(PublicUserDto2ProjectRoleUserDto, {
emailAddress: (opt) => opt.mapFrom((u) => u.email),
userId: (opt) => opt.mapFrom((u) => u.id),
firstName: (opt) => opt.mapFrom((u) => u.firstName),
lastName: (opt) => opt.mapFrom((u) => u.lastName),
});
cfg.createMap(UserDto2UserForUpdateDto, {
firstName: (opt) => opt.auto(),
lastName: (opt) => opt.auto(),
email: (opt) => opt.auto(),
givenName: (opt) => opt.mapFrom((dto) => dto.givenName ?? ""),
familyName: (opt) => opt.mapFrom((dto) => dto.familyName ?? ""),
email: (opt) =>
opt.mapFrom((dto) => dto.emails?.find((e) => e.isPrimary)?.email ?? ""),
title: (opt) =>
opt
.condition((dto) => undefined !== dto.title)
......@@ -61,11 +50,11 @@ const configuration = new MapperConfiguration((cfg) => {
),
institute: (opt) =>
opt.mapFrom((dto) =>
dto.institutes?.length ? dto.institutes[0].name : ""
dto.institutes?.length ? dto.institutes[0].displayName : ""
),
organization: (opt) =>
opt.mapFrom((dto) =>
dto.organizations?.length ? dto.organizations[0].name : null
dto.organizations?.length ? dto.organizations[0].displayName : null
),
});
cfg.createAutoMap(TitleDto2TitleForUserManipulationDto, {});
......
......@@ -8,10 +8,11 @@ import type { DFNAAIData, DFNAAIInstitution, LoginState } from "./types";
import useMainStore from "@/store/index";
import useNotificationStore from "@/store/notification";
import { useLocalStorage } from "@vueuse/core";
import { AccountApi, ToSApi, UserApi } from "@coscine/api-client";
import { AccountApi, SelfApi, TosApi } from "@coscine/api-client";
import type { AxiosError } from "axios";
import axios from "axios";
import type { LoginUrls } from "@coscine/api-client/dist/types/Coscine.Api.STS";
import { UserTermsOfServiceAcceptDto } from "@coscine/api-client/dist/types/Coscine.Api";
/*
Store variable name is "this.<id>Store"
......@@ -145,7 +146,7 @@ export const useLoginStore = defineStore({
async retrieveCurrentTosVersion() {
const notificationStore = useNotificationStore();
try {
const apiResponse = await ToSApi.getToS();
const apiResponse = await TosApi.getTos();
this.currentTosVersion = apiResponse.data.data;
} catch (error) {
// Handle other Status Codes
......@@ -171,7 +172,15 @@ export const useLoginStore = defineStore({
async acceptToS(): Promise<boolean> {
const notificationStore = useNotificationStore();
try {
await UserApi.acceptCurrentToS();
// Retrieve the current TOS version if missing
if (!this.currentTosVersion?.version) {
await this.retrieveCurrentTosVersion();
}
// Build the DTO and send it
const userTermsOfServiceAcceptDto: UserTermsOfServiceAcceptDto = {
version: this.currentTosVersion?.version ?? "",
};
await SelfApi.acceptCurrentTos(userTermsOfServiceAcceptDto);
return true;
} catch (error) {
// Handle other Status Codes
......
......@@ -149,7 +149,7 @@ import usePidStore from "../store";
import useNotificationStore from "@/store/notification";
import { useVuelidate, type ValidationArgs } from "@vuelidate/core";
import { email, maxLength, required } from "@vuelidate/validators";
import type { PidEnquiryDto } from "@coscine/api-client/dist/types/Coscine.Api/api";
import type { PidRequestDto } from "@coscine/api-client/dist/types/Coscine.Api/api";
export default defineComponent({
setup() {
......@@ -168,7 +168,7 @@ export default defineComponent({
email: "",
message: "",
sendConfirmationEmail: true,
} as PidEnquiryDto,
} as PidRequestDto,
isLoading: false,
isPidValid: null as boolean | null,
};
......@@ -190,7 +190,7 @@ export default defineComponent({
email: { email, required },
message: { required, maxLength: maxLength(5000) },
sendConfirmationEmail: { required },
} as ValidationArgs<PidEnquiryDto>,
} as ValidationArgs<PidRequestDto>,
};
},
......
......@@ -5,7 +5,7 @@ import useNotificationStore from "@/store/notification";
import { PidApi } from "@coscine/api-client";
import { AxiosError } from "axios";
import { StatusCodes } from "http-status-codes";
import type { PidEnquiryDto } from "@coscine/api-client/dist/types/Coscine.Api/api";
import type { PidRequestDto } from "@coscine/api-client/dist/types/Coscine.Api/api";
/*
Store variable name is "this.<id>Store"
......@@ -64,20 +64,20 @@ export const usePidStore = defineStore({
* Contacts the PID owner using the provided PID prefix, ID, and PID enquiry data.
* @param {string} prefix - The PID prefix value.
* @param {string} id - The ID value.
* @param {PidEnquiryDto} pidEnquiryDto - The PID enquiry data.
* @param {PidRequestDto} pidRequestDto - The PID request data.
* @returns {Promise<boolean | null>} A promise that resolves to a boolean indicating whether the contact operation was successful, or null if there was an error.
*/
async contactPidOwner(
prefix: string,
id: string,
pidEnquiryDto: PidEnquiryDto
pidRequestDto: PidRequestDto
): Promise<boolean | null> {
const notificationStore = useNotificationStore();
try {
const apiResponse = await PidApi.sendEmailToOwner(
const apiResponse = await PidApi.sendRequestToOwner(
prefix,
id,
pidEnquiryDto
pidRequestDto
);
// Note: Beware that only 204 (No Content) is considered a success in this implementation.
return apiResponse.status === StatusCodes.NO_CONTENT ? true : false;
......
......@@ -45,8 +45,8 @@ export default {
"Sie können eine Einladung an diese E-Mail Adresse senden",
alreadyGotRole: "(bereits Mitglied)",
selectRolePlaceholder: "Rolle auswählen",
firstName: "Vorname",
lastName: "Nachname",
givenName: "Vorname",
familyName: "Nachname",
email: "E-Mail",
actions: "Aktionen",
status: "Status",
......
......@@ -42,8 +42,8 @@ export default {
searchEmailInvite: "You may send an invitation to this email address",
alreadyGotRole: "(Already added)",
selectRolePlaceholder: "Select Role",
firstName: "First Name",
lastName: "Last Name",
givenName: "Given Name",
familyName: "Family Name",
email: "Email",
actions: "Actions",
status: "Status",
......
......@@ -21,7 +21,7 @@ import type Vue from "vue";
/* Import of relevant mockup data */
import { testProjectState } from "@/data/mockup/testProject";
import { getTestUserState } from "@/data/mockup/testUser";
import { getTestShibbolethUserState } from "@/data/mockup/testUser";
/* Create a local Vue instance */
const localVue = createLocalVue();
......@@ -31,7 +31,7 @@ describe("ConfigurationMetadata.vue", () => {
/* Describe Pre-initialization steps */
/* Description of the test */
test("should enable buttons and update project name", async () => {
test("Should enable buttons and update project name", async () => {
/* Test Pre-initialization steps */
/* Mount the Component */
......@@ -40,7 +40,7 @@ describe("ConfigurationMetadata.vue", () => {
createSpy: vitest.fn,
initialState: {
project: testProjectState,
user: getTestUserState(),
user: getTestShibbolethUserState(),
},
}),
i18n,
......@@ -48,31 +48,29 @@ describe("ConfigurationMetadata.vue", () => {
});
// Check initial state of buttons
expect(wrapper.get("#DeleteProjectBtn").attributes()["disabled"]).not.toBe(
"disabled"
); // Delete button - active
expect(wrapper.get("#SubmitProjectBtn").attributes()["disabled"]).toBe(
"disabled"
); // Submit button - disabled
expect(
(wrapper.get("#DeleteProjectBtn").element as HTMLButtonElement).disabled
).toBeFalsy(); // Delete button - active
expect(
(wrapper.get("#SubmitProjectBtn").element as HTMLButtonElement).disabled
).toBeTruthy(); // Submit button - disabled
await wrapper.vm.$nextTick();
// Find element (Project Name)
const element = wrapper.get("#ProjectName");
expect(element.exists()).toBe(true);
expect(element.exists()).toBeTruthy();
// Change value of element
await element.setValue("New Test Project");
expect(wrapper.vm.$data.projectForUpdate.projectName).toBe(
"New Test Project"
);
expect(wrapper.vm.$data.projectForUpdate.name).toBe("New Test Project");
// Buttons should be enabled
expect(wrapper.get("#DeleteProjectBtn").attributes()["disabled"]).not.toBe(
"disabled"
); // Delete button - active
expect(wrapper.get("#SubmitProjectBtn").attributes()["disabled"]).not.toBe(
"disabled"
); // Submit button - active
expect(
(wrapper.get("#DeleteProjectBtn").element as HTMLButtonElement).disabled
).toBeFalsy(); // Delete button - active
expect(
(wrapper.get("#SubmitProjectBtn").element as HTMLButtonElement).disabled
).toBeFalsy(); // Submit button - active
});
});
......@@ -121,7 +121,7 @@ export default defineComponent({
startDate: "",
endDate: "",
keywords: [] as string[],
projectName: "",
name: "",
principleInvestigators: "",
grantId: "",
slug: "",
......
......@@ -103,7 +103,7 @@ export default defineComponent({
startDate: moment(new Date()).format("YYYY-MM-DD"),
endDate: moment(new Date()).format("YYYY-MM-DD"),
keywords: [] as string[],
projectName: "",
name: "",
principleInvestigators: "",
grantId: "",
disciplines: [],
......@@ -126,7 +126,7 @@ export default defineComponent({
const memberships = this.userStore.user?.organizations;
if (memberships) {
return memberships.some(
(membership) => membership.rorUri === "https://ror.org/04xfq0f34"
(membership) => membership.uri === "https://ror.org/04xfq0f34"
);
}
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment