Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21-1494 Generate Info outdated ctl tools #2931

Merged
merged 23 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/components/administration/ExternalToolSection.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AuthModule from "@/store/auth";
import { ToolConfigurationStatus } from "@/store/external-tool";
import NotifierModule from "@/store/notifier";
import SchoolExternalToolsModule from "@/store/school-external-tools";
import { User } from "@/store/types/auth";
Expand All @@ -21,6 +20,7 @@ import { useSchoolExternalToolUsage } from "@data-external-tool";
import {
schoolExternalToolFactory,
schoolExternalToolMetadataFactory,
schoolToolConfigurationStatusFactory,
} from "@@/tests/test-utils/factory";

jest.mock("@data-external-tool");
Expand Down Expand Up @@ -119,7 +119,7 @@ describe("ExternalToolSection", () => {
schoolId: "schoolId",
parameters: [],
name: firstToolName,
status: ToolConfigurationStatus.Latest,
status: schoolToolConfigurationStatusFactory.build(),
version: 1,
},
{
Expand All @@ -128,7 +128,9 @@ describe("ExternalToolSection", () => {
schoolId: "schoolId",
parameters: [],
name: secondToolName,
status: ToolConfigurationStatus.Outdated,
status: schoolToolConfigurationStatusFactory.build({
isOutdatedOnScopeSchool: true,
}),
version: 1,
},
],
Expand Down Expand Up @@ -246,7 +248,7 @@ describe("ExternalToolSection", () => {
schoolId: "schoolId",
parameters: [],
name: "firstToolName",
status: ToolConfigurationStatus.Latest,
status: schoolToolConfigurationStatusFactory.build(),
version: 1,
},
],
Expand Down Expand Up @@ -278,7 +280,7 @@ describe("ExternalToolSection", () => {
schoolId: "schoolId",
parameters: [],
name: "firstToolName",
status: ToolConfigurationStatus.Latest,
status: schoolToolConfigurationStatusFactory.build(),
version: 1,
},
],
Expand Down Expand Up @@ -313,7 +315,7 @@ describe("ExternalToolSection", () => {
//@ts-ignore
wrapper.vm.itemToDelete = {
name: expectedName,
status: ToolConfigurationStatus.Latest,
status: schoolToolConfigurationStatusFactory.build(),
outdated: false,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { DataTableHeader } from "vuetify";
import { SchoolExternalToolItem } from "./school-external-tool-item";
import {
SchoolExternalTool,
ToolConfigurationStatus,
} from "@/store/external-tool";
import { ToolConfigurationStatusTranslationMapping } from "@/composables/external-tool-mappings.composable";
import { SchoolExternalTool } from "@/store/external-tool";
import SchoolExternalToolsModule from "@/store/school-external-tools";

export function useExternalToolsSectionUtils(
Expand Down Expand Up @@ -35,10 +31,10 @@ export function useExternalToolsSectionUtils(
const schoolExternalTools: SchoolExternalTool[] =
schoolExternalToolsModule.getSchoolExternalTools;
return schoolExternalTools.map((tool: SchoolExternalTool) => {
const outdated: boolean =
tool.status === ToolConfigurationStatus.Outdated;
const statusTranslationKey: string =
ToolConfigurationStatusTranslationMapping[tool.status];
const outdated: boolean = tool.status.isOutdatedOnScopeSchool;
const statusTranslationKey: string = tool.status.isOutdatedOnScopeSchool
? "components.externalTools.status.outdated"
: "components.externalTools.status.latest";

return {
id: tool.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { DataTableHeader } from "vuetify";
import { schoolExternalToolsModule } from "@/store";
import {
SchoolExternalToolResponse,
SchoolExternalToolResponseStatusEnum,
SchoolExternalToolSearchListResponse,
} from "@/serverApi/v3";
import { SchoolExternalToolItem } from "./school-external-tool-item";
import { ToolConfigurationStatus } from "@/store/external-tool";
import { ContextExternalToolConfigurationStatusFactory } from "@@/tests/test-utils";

const schoolExternalToolsModuleMock = () => {
return {
Expand All @@ -16,7 +15,9 @@ const schoolExternalToolsModuleMock = () => {
id: "id",
name: "toolName",
version: 1,
status: "Latest",
status: {
isOutdatedOnScopeSchool: false,
},
},
],
};
Expand Down Expand Up @@ -45,7 +46,9 @@ describe("useSchoolExternalToolUtils", () => {
value: "value",
},
],
status: SchoolExternalToolResponseStatusEnum.Latest,
status: ContextExternalToolConfigurationStatusFactory.build({
isOutdatedOnScopeSchool: false,
}),
};
const listResponse: SchoolExternalToolSearchListResponse = {
data: [toolResponse],
Expand All @@ -54,7 +57,7 @@ describe("useSchoolExternalToolUtils", () => {
const schoolExternaToolItem: SchoolExternalToolItem = {
name: toolResponse.name,
id: toolResponse.id,
status: ToolConfigurationStatus.Latest,
status: "translationKey",
outdated: false,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as serverApi from "@/serverApi/v3/api";
import { ToolReferenceResponse } from "@/serverApi/v3/api";
import { ExternalToolDisplayData } from "@/store/external-tool";
import {
ExternalToolDisplayData,
ToolConfigurationStatus,
} from "@/store/external-tool";
import {
ContextExternalToolConfigurationStatusFactory,
mockApiResponse,
toolReferenceResponseFactory,
} from "@@/tests/test-utils";
Expand Down Expand Up @@ -62,7 +60,7 @@ describe("ContextExternalToolApi.composable", () => {
contextExternalToolId: displayData.contextToolId,
name: displayData.displayName,
logoUrl: displayData.logoUrl,
status: ToolConfigurationStatus.Latest,
status: ContextExternalToolConfigurationStatusFactory.build(),
openInNewTab: displayData.openInNewTab,
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ContextExternalToolConfigurationStatus } from "@/store/external-tool";
import { AUTH_MODULE_KEY, injectStrict } from "@/utils/inject";

export const useContextExternalToolConfigurationStatus = () => {
const authModule = injectStrict(AUTH_MODULE_KEY);

const determineOutdatedTranslationKey = (
toolConfigStatus: ContextExternalToolConfigurationStatus
): string => {
const userRoles = authModule.getUserRoles;

if (userRoles.includes("teacher")) {
if (
toolConfigStatus.isOutdatedOnScopeContext &&
toolConfigStatus.isOutdatedOnScopeSchool
) {
return "common.tool.information.outdatedOnSchoolAndContext.teacher";
} else if (toolConfigStatus?.isOutdatedOnScopeSchool) {
return "common.tool.information.outdatedOnSchool.teacher";
} else {
return "common.tool.information.outdatedOnContext.teacher";
}
} else {
return "common.tool.information.outdated.student";
}
};

return {
determineOutdatedTranslationKey,
};
};
Loading
Loading