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
No related branches found
No related tags found
2 merge requests!260Dev,!258Fix: Minor fixes from internal testing
import { import {
LanguageApi, LanguageApi,
OrganizationApi, OrganizationApi,
SelfApi,
SelfApiTokenApi,
TitleApi, TitleApi,
TokenApi,
UserApi, UserApi,
} from "@coscine/api-client"; } from "@coscine/api-client";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
...@@ -18,7 +19,7 @@ import { removeQueryParameterFromUrl } from "@/router"; ...@@ -18,7 +19,7 @@ import { removeQueryParameterFromUrl } from "@/router";
import { DisciplineApi } from "@coscine/api-client"; import { DisciplineApi } from "@coscine/api-client";
import type { import type {
ApiTokenForCreationDto, ApiTokenForCreationDto,
ExternalAuthenticators, IdentityProviders,
UserForUpdateDto, UserForUpdateDto,
UserMergeDto, UserMergeDto,
} from "@coscine/api-client/dist/types/Coscine.Api"; } from "@coscine/api-client/dist/types/Coscine.Api";
...@@ -98,7 +99,7 @@ export const useUserStore = defineStore({ ...@@ -98,7 +99,7 @@ export const useUserStore = defineStore({
try { try {
const confirmationToken = route.query[tokenKey]?.toString(); const confirmationToken = route.query[tokenKey]?.toString();
if (confirmationToken) { if (confirmationToken) {
await UserApi.confirmUserEmail(confirmationToken); await SelfApi.confirmUserEmail(confirmationToken);
notificationStore.postNotification({ notificationStore.postNotification({
title: i18n.t("toast.contactChange.success.title").toString(), title: i18n.t("toast.contactChange.success.title").toString(),
body: i18n.t("toast.contactChange.success.message").toString(), body: i18n.t("toast.contactChange.success.message").toString(),
...@@ -171,7 +172,7 @@ export const useUserStore = defineStore({ ...@@ -171,7 +172,7 @@ export const useUserStore = defineStore({
async retrieveTokens() { async retrieveTokens() {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
let apiResponse = await TokenApi.getAllApiTokens(); let apiResponse = await SelfApiTokenApi.getAllApiTokens();
if (apiResponse.data.data) { if (apiResponse.data.data) {
// Assign the data from the first page // Assign the data from the first page
this.userProfile.tokens = [...apiResponse.data.data]; this.userProfile.tokens = [...apiResponse.data.data];
...@@ -186,7 +187,7 @@ export const useUserStore = defineStore({ ...@@ -186,7 +187,7 @@ export const useUserStore = defineStore({
? apiResponse.data.pagination.currentPage + 1 ? apiResponse.data.pagination.currentPage + 1
: 1; : 1;
// Retrieve the next page // Retrieve the next page
apiResponse = await TokenApi.getAllApiTokens(nextPage); apiResponse = await SelfApiTokenApi.getAllApiTokens(nextPage);
if (apiResponse.data.data) { if (apiResponse.data.data) {
// Extend the data with the newly fetched data // Extend the data with the newly fetched data
this.userProfile.tokens = [...apiResponse.data.data]; this.userProfile.tokens = [...apiResponse.data.data];
...@@ -204,7 +205,7 @@ export const useUserStore = defineStore({ ...@@ -204,7 +205,7 @@ export const useUserStore = defineStore({
async retrieveUser() { async retrieveUser() {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
const apiResponse = await UserApi.getCurrentUser(); const apiResponse = await SelfApi.getCurrentUser();
this.user = apiResponse.data.data; this.user = apiResponse.data.data;
} catch (error) { } catch (error) {
// Handle other Status Codes // Handle other Status Codes
...@@ -215,7 +216,7 @@ export const useUserStore = defineStore({ ...@@ -215,7 +216,7 @@ export const useUserStore = defineStore({
async deleteToken(tokenId: string) { async deleteToken(tokenId: string) {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
await TokenApi.revokeToken(tokenId); await SelfApiTokenApi.revokeToken(tokenId);
} catch (error) { } catch (error) {
// Handle other Status Codes // Handle other Status Codes
notificationStore.postApiErrorNotification(error as AxiosError); notificationStore.postApiErrorNotification(error as AxiosError);
...@@ -223,11 +224,11 @@ export const useUserStore = defineStore({ ...@@ -223,11 +224,11 @@ export const useUserStore = defineStore({
}, },
async initiateUserMerge( async initiateUserMerge(
provider: ExternalAuthenticators provider: IdentityProviders
): Promise<UserMergeDto | null | undefined> { ): Promise<UserMergeDto | null | undefined> {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
const apiResponse = await UserApi.initiateUserMerge(provider); const apiResponse = await SelfApi.initiateUserMerge(provider);
return apiResponse.data.data; return apiResponse.data.data;
} catch (error) { } catch (error) {
// Handle other Status Codes // Handle other Status Codes
...@@ -239,7 +240,9 @@ export const useUserStore = defineStore({ ...@@ -239,7 +240,9 @@ export const useUserStore = defineStore({
async createApiToken(tokenForCreation: ApiTokenForCreationDto) { async createApiToken(tokenForCreation: ApiTokenForCreationDto) {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
const apiResponse = await TokenApi.createApiToken(tokenForCreation); const apiResponse = await SelfApiTokenApi.createApiToken(
tokenForCreation
);
return apiResponse.data.data; return apiResponse.data.data;
} catch (error) { } catch (error) {
// Handle other Status Codes // Handle other Status Codes
...@@ -250,7 +253,7 @@ export const useUserStore = defineStore({ ...@@ -250,7 +253,7 @@ export const useUserStore = defineStore({
async updateUser(userForUpdateDto: UserForUpdateDto): Promise<boolean> { async updateUser(userForUpdateDto: UserForUpdateDto): Promise<boolean> {
const notificationStore = useNotificationStore(); const notificationStore = useNotificationStore();
try { try {
await UserApi.updateCurrentUser(userForUpdateDto); await SelfApi.updateCurrentUser(userForUpdateDto);
return true; return true;
} catch (error) { } catch (error) {
// Handle other Status Codes // Handle other Status Codes
......
...@@ -29,9 +29,9 @@ export interface TokenValidityBoundDates { ...@@ -29,9 +29,9 @@ export interface TokenValidityBoundDates {
} }
/** /**
* Defining the {@link ExternalAuthenticators} enum inside the types, because it is not being exported correctly from the @coscine/api-client library. * Defining the {@link IdentityProviders} enum inside the types, because it is not being exported correctly from the @coscine/api-client library.
*/ */
export enum ExternalAuthenticators { export enum IdentityProviders {
Shibboleth = "Shibboleth", Shibboleth = "Shibboleth",
OrciD = "ORCiD", OrciD = "ORCiD",
} }
import { createTestingPinia } from "@pinia/testing"; import { createTestingPinia } from "@pinia/testing";
import { testProjectState } from "@/data/mockup/testProject"; import { testProjectState } from "@/data/mockup/testProject";
import { getTestUserState } from "@/data/mockup/testUser"; import { getTestShibbolethUserState } from "@/data/mockup/testUser";
import { getTestResourceState } from "@/data/mockup/testResource"; import { getTestResourceState } from "@/data/mockup/testResource";
import { testLoginState } from "@/data/mockup/testLogin"; import { testLoginState } from "@/data/mockup/testLogin";
import { getTestMainState } from "@/data/mockup/testMain"; import { getTestMainState } from "@/data/mockup/testMain";
...@@ -14,7 +14,7 @@ const pinia = createTestingPinia({ ...@@ -14,7 +14,7 @@ const pinia = createTestingPinia({
project: testProjectState, project: testProjectState,
resource: await getTestResourceState(), resource: await getTestResourceState(),
search: testSearchState, search: testSearchState,
user: getTestUserState(), user: getTestShibbolethUserState(),
}, },
}); });
......
...@@ -105,8 +105,9 @@ export const useMainStore = defineStore({ ...@@ -105,8 +105,9 @@ export const useMainStore = defineStore({
}, },
async getMaintenance() { async getMaintenance() {
const apiResponse = await MaintenanceApi.getCurrentMaintenance(); const apiResponse = await MaintenanceApi.getCurrentMaintenances();
const maintenance = apiResponse.data.data; // TODO: Make it work with multiple maintenance messages
const maintenance = apiResponse.data.data?.at(0); // Take the first maintenance
if (maintenance?.startsDate) { if (maintenance?.startsDate) {
const now = new Date(Date.now()); const now = new Date(Date.now());
const startDate = new Date(maintenance.startsDate); const startDate = new Date(maintenance.startsDate);
......
...@@ -83,7 +83,7 @@ export const useNotificationStore = defineStore({ ...@@ -83,7 +83,7 @@ export const useNotificationStore = defineStore({
}, },
postNotification(toast: NotificationToast) { postNotification(toast: NotificationToast) {
this.notificationQueue.push(toast); this.notificationQueue.push(toast); // TODO: Address this warning
}, },
deleteNotification(toast: NotificationToast) { deleteNotification(toast: NotificationToast) {
......
...@@ -2,10 +2,9 @@ import type { RemovableRef } from "@vueuse/core"; ...@@ -2,10 +2,9 @@ import type { RemovableRef } from "@vueuse/core";
import type { MaintenanceDto } from "@coscine/api-client/dist/types/Coscine.Api"; import type { MaintenanceDto } from "@coscine/api-client/dist/types/Coscine.Api";
import type { VNode } from "vue"; import type { VNode } from "vue";
import type { BvToastOptions } from "bootstrap-vue"; import type { BvToastOptions } from "bootstrap-vue";
import type { TranslateResult } from "vue-i18n";
export interface NotificationToast extends BvToastOptions { export interface NotificationToast extends BvToastOptions {
body: string | TranslateResult | VNode | Array<VNode>; body: string | VNode | Array<VNode>;
variant?: "danger" | "warning" | "success" | "info" | "primary" | "secondary"; variant?: "danger" | "warning" | "success" | "info" | "primary" | "secondary";
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment