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-1512 Fix SchoolExternalTool metadata #2925

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
ToolApiFactory,
ToolApiInterface,
} from "@/serverApi/v3";
import { $axios } from "@/utils/api";
import { SchoolExternalToolMetadata } from "@/store/external-tool";
import { SchoolExternalToolMapper } from "@/store/external-tool/mapper";
import { $axios } from "@/utils/api";
import { AxiosResponse } from "axios";

export const useSchoolExternalToolApi = () => {
Expand All @@ -19,18 +19,10 @@ export const useSchoolExternalToolApi = () => {
schoolExternalToolId
);

if (
response.data.contextExternalToolCountPerContext.course ||
response.data.contextExternalToolCountPerContext.boardElement
) {
const mapped: SchoolExternalToolMetadata =
SchoolExternalToolMapper.mapSchoolExternalToolMetadata(response.data);
const mapped: SchoolExternalToolMetadata =
SchoolExternalToolMapper.mapSchoolExternalToolMetadata(response.data);

return mapped;
}
throw new Error(
"SchoolExternalToolMetadataResponse is missing required fields"
);
return mapped;
};

return {
Expand Down
46 changes: 23 additions & 23 deletions src/serverApi/v3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,25 @@ export interface ContextExternalToolConfigurationTemplateResponse {
*/
version: number;
}
/**
*
* @export
* @interface ContextExternalToolCountPerContextResponse
*/
export interface ContextExternalToolCountPerContextResponse {
/**
*
* @type {number}
* @memberof ContextExternalToolCountPerContextResponse
*/
course: number;
/**
*
* @type {number}
* @memberof ContextExternalToolCountPerContextResponse
*/
boardElement: number;
}
/**
*
* @export
Expand Down Expand Up @@ -1633,10 +1652,10 @@ export interface ExternalToolMetadataResponse {
schoolExternalToolCount: number;
/**
*
* @type {SchoolExternalToolMetadataResponseContextExternalToolCountPerContext}
* @type {ContextExternalToolCountPerContextResponse}
* @memberof ExternalToolMetadataResponse
*/
contextExternalToolCountPerContext: SchoolExternalToolMetadataResponseContextExternalToolCountPerContext;
contextExternalToolCountPerContext: ContextExternalToolCountPerContextResponse;
}
/**
*
Expand Down Expand Up @@ -3923,29 +3942,10 @@ export interface SchoolExternalToolConfigurationTemplateResponse {
export interface SchoolExternalToolMetadataResponse {
/**
*
* @type {SchoolExternalToolMetadataResponseContextExternalToolCountPerContext}
* @type {ContextExternalToolCountPerContextResponse}
* @memberof SchoolExternalToolMetadataResponse
*/
contextExternalToolCountPerContext: SchoolExternalToolMetadataResponseContextExternalToolCountPerContext;
}
/**
*
* @export
* @interface SchoolExternalToolMetadataResponseContextExternalToolCountPerContext
*/
export interface SchoolExternalToolMetadataResponseContextExternalToolCountPerContext {
/**
*
* @type {number}
* @memberof SchoolExternalToolMetadataResponseContextExternalToolCountPerContext
*/
course?: number;
/**
*
* @type {number}
* @memberof SchoolExternalToolMetadataResponseContextExternalToolCountPerContext
*/
boardElement?: number;
contextExternalToolCountPerContext: ContextExternalToolCountPerContextResponse;
}
/**
*
Expand Down
6 changes: 3 additions & 3 deletions src/store/external-tool/mapper/school-external-tool.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SchoolExternalTool,
SchoolExternalToolSave,
} from "../school-external-tool";
import { SchoolExternalToolMetadata } from "../school-external-tool-metadata";
import { SchoolExternalToolConfigurationTemplate } from "../tool-configuration-template";
import { ToolParameter } from "../tool-parameter";
import { ToolParameterEntry } from "../tool-parameter-entry";
Expand All @@ -19,7 +20,6 @@ import {
ToolConfigurationStatusMapping,
} from "./common-tool.mapper";
import { ExternalToolMapper } from "./external-tool.mapper";
import { SchoolExternalToolMetadata } from "../school-external-tool-metadata";

export class SchoolExternalToolMapper {
static mapToSchoolExternalToolConfigurationTemplate(
Expand Down Expand Up @@ -121,8 +121,8 @@ export class SchoolExternalToolMapper {
response: SchoolExternalToolMetadataResponse
): SchoolExternalToolMetadata {
const mapped: SchoolExternalToolMetadata = {
course: response.contextExternalToolCountPerContext.course!,
boardElement: response.contextExternalToolCountPerContext.boardElement!,
course: response.contextExternalToolCountPerContext.course,
boardElement: response.contextExternalToolCountPerContext.boardElement,
};

return mapped;
Expand Down
Loading