Skip to content

Commit

Permalink
Issue #PS-2876 feat: Set channel and framework value from metadata fo…
Browse files Browse the repository at this point in the history
…r existing content
  • Loading branch information
rajnishdargan committed Dec 24, 2024
2 parents 1edf90e + e6e4d11 commit e965393
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
echo '${{ secrets.QA_ENV }}' > .env
ls -ltra
./deploy.sh
#Testing
#Testing
55 changes: 35 additions & 20 deletions src/components/ConfirmActionPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
Dialog,
DialogTitle,
Expand All @@ -14,7 +14,7 @@ import {
TextField,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';

import {getFormFields} from '@/services/ContentService';
interface ConfirmActionPopupProps {
open: boolean;
onClose: () => void;
Expand All @@ -29,23 +29,9 @@ const ConfirmActionPopup: React.FC<ConfirmActionPopupProps> = ({
actionType,
}) => {
const [checkedItems, setCheckedItems] = useState<string[]>([]);
const [comment, setComment] = useState<string>('');

const usabilityOptions = [
'Correct Spellings and Grammar',
'Simple Language',
'Content/Audio/Video quality',
'Suitable font size for app and portal',
'Copyright infringement (images and texts)',
];

const contentDetailsOptions = [
'Appropriate Title',
'Standard description of the course/resource',
'Relevant tags and keywords',
'Appropriate image',
];

const [usabilityOptions, setUsabilityOptions] = useState<string[]>([]);
const [contentDetailsOptions, setContentDetailsOptions] = useState<string[]>([]);
const [comment, setComment] = useState<string>('');
const handleCheckboxChange = (item: string) => {
setCheckedItems((prev) =>
prev.includes(item)
Expand All @@ -66,7 +52,36 @@ const ConfirmActionPopup: React.FC<ConfirmActionPopupProps> = ({

const allOptions = [...usabilityOptions, ...contentDetailsOptions];
const allChecked = allOptions.every((option) => checkedItems.includes(option));

useEffect(() => {
const fetchFields = async () => {
try {

if(open){

const data = await getFormFields();

const contents = data?.result?.form?.data?.fields[0]?.contents;
let usabilityCheckList: any = [];
let contentDetailsCheckList: any = [];
contents.forEach((item: any) => {
if (item.name === "Usability") {
usabilityCheckList = item.checkList;
} else if (item.name === "Content details") {
contentDetailsCheckList = item.checkList;
}
});
setUsabilityOptions(usabilityCheckList);
setContentDetailsOptions(contentDetailsCheckList);


}
} catch (err) {
console.error("data", err);
} finally {
}
};
fetchFields();
}, [open]);
return (
<Dialog open={open} onClose={handleClose} maxWidth="md" fullWidth>
<DialogTitle
Expand Down
174 changes: 128 additions & 46 deletions src/pages/api/mocked-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,56 +434,138 @@ export const genericEditorReviewFormResponse = {
"ver": "1.0"
}


export const genericEditorRequestForChangesFormResponse = {
"id": "api.form.read",
"params": {
"resmsgid": "dd529494-4996-47c8-849d-f5862426fb39",
"msgid": "06aa0ffa-306f-42eb-b7d6-b15596b858fe",
"status": "successful"
id: "api.form.read",
params: {
resmsgid: "fb345240-8d49-459d-a99c-4fcf3aa04da2",
msgid: "b54b2ac7-2db4-406a-80f7-140d86bcccbb",
status: "successful",
},
responseCode: "OK",
result: {
form: {
type: "content",
subtype: "resource",
action: "requestforchanges",
component: "*",
framework: "*",
data: {
templateName: "defaultTemplate",
action: "requestforchanges",
fields: [
{
title:
"Please confirm that ALL the following items are verified (by ticking the check-boxes) before you can publish:",
contents: [
{
name: "Usability",
checkList: [
"Correct Spellings and Grammar",
"Simple Language",
"Content/Audio/Video quality",
"Suitable font size for app and portal",
"Copyright infringement (images and texts)",
],
},
{
name: "Content details",
checkList: [
"Appropriate Title",
"Standard description of the course/resource",
"Relevant tags and keywords",
"Appropritae image ",
],
},
],
},
],
},
created_on: "2019-09-08T15:25:00.291Z",
last_modified_on: "2020-08-24T06:06:08.120Z",
rootOrgId: "*",
},
"responseCode": "OK",
"result": {
"form": {
"type": "content",
"subtype": "resource",
"action": "requestforchanges",
"component": "*",
"framework": "*",
"data": {
"templateName": "defaultTemplate",
"action": "requestforchanges",
"fields": [{ "contents": [] }]
},
"created_on": "2019-09-08T15:25:00.291Z",
"last_modified_on": "2020-08-24T06:06:08.120Z",
"rootOrgId": "*"
}
},
"ts": "2024-10-25T07:24:32.384Z",
"ver": "1.0"
}
},
ts: "2024-12-12T14:40:25.246Z",
ver: "1.0",
};

export const telemetryResponse = {
"id": "api.telemetry.post",
"params": {
"status": "successful"
},
"responseCode": "OK",
"result": {
"message": "This is mocked response"
},
"ver": "1.0"
}
id: "api.telemetry.post",
params: {
status: "successful",
},
responseCode: "OK",
result: {
message: "This is mocked response",
},
ver: "1.0",
};

export const creatLockResponse = {
"id": "api.lock.create",
"params": {
"status": "successful",
id: "api.lock.create",
params: {
status: "successful",
},
responseCode: "OK",
result: {
lockKey: "69d82e1c-6d91-4b2e-a873-39ebeab007b9",
expiresAt: "2026-10-09T12:53:41.138Z",
expiresIn: 63072000,
},
};

export const publishResourceFormResponse = {
id: "api.form.read",
params: {
resmsgid: "0455438d-8bd5-4bfb-a97c-0d962cab1951",
msgid: "2db53598-185f-44f9-a35c-e760e08fe62a",
status: "successful",
},
responseCode: "OK",
result: {
form: {
type: "content",
subtype: "resource",
action: "publish",
component: "*",
framework: "*",
data: {
templateName: "defaultTemplate",
action: "publish",
fields: [
{
title:
"Please confirm that ALL the following items are verified (by ticking the check-boxes) before you can publish:",
contents: [
{
name: "Usability",
checkList: [
"Correct Spellings and Grammar",
"Simple Language",
"Content/Audio/Video quality",
"Suitable font size for app and portal",
"Copyright infringement (images and texts)",
],
},
{
name: "Content details",
checkList: [
"Appropriate Title",
"Standard description of the course/resource",
"Relevant tags and keywords",
"Appropritae image ",
],
},
],
},
],
},
created_on: "2019-09-08T15:25:39.638Z",
last_modified_on: "2020-08-16T11:47:24.215Z",
rootOrgId: "*",
},
"responseCode": "OK",
"result": {
"lockKey": "69d82e1c-6d91-4b2e-a873-39ebeab007b9",
"expiresAt": "2026-10-09T12:53:41.138Z",
"expiresIn": 63072000
}
}
},
ts: "2024-12-24T05:46:18.384Z",
ver: "1.0",
};
6 changes: 5 additions & 1 deletion src/pages/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
creatLockResponse,
genericEditorReviewFormResponse,
genericEditorRequestForChangesFormResponse,
publishResourceFormResponse,
} from "./mocked-response";
import * as cookie from "cookie";

Expand Down Expand Up @@ -41,7 +42,7 @@ export default async function handler(
}

if (pathString === "/action/data/v1/form/read") {
const { action, subType } = body.request;
const { action, subType, type } = body.request;
if (action === "save" && subType === "resource") {
return res.status(200).json(genericEditorSaveFormResponse);
}
Expand All @@ -51,6 +52,9 @@ export default async function handler(
if (action === "requestforchanges" && subType === "resource") {
return res.status(200).json(genericEditorRequestForChangesFormResponse);
}
if (action === "publish" && subType === "resource" && type === 'content') {
return res.status(200).json(publishResourceFormResponse);
}
}

if (pathString === "/action/lock/v1/create") {
Expand Down
30 changes: 27 additions & 3 deletions src/services/ContentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,15 @@ export const createCourse = async (userId: any) => {
}
};

export const publishContent = async (identifier: any, publishChecklist?: any) => {
export const publishContent = async (
identifier: any,
publishChecklist?: any
) => {
const requestBody = {
request: {
content: {
lastPublishedBy: userId,
publishChecklist:publishChecklist
publishChecklist: publishChecklist,
},
},
};
Expand All @@ -282,7 +285,11 @@ export const publishContent = async (identifier: any, publishChecklist?: any) =>
}
};

export const submitComment = async (identifier: any, comment: any, rejectReasons?:any) => {
export const submitComment = async (
identifier: any,
comment: any,
rejectReasons?: any
) => {
const requestBody = {
request: {
content: {
Expand Down Expand Up @@ -332,3 +339,20 @@ export const getFrameworkDetails = async (): Promise<any> => {
return error;
}
};
export const getFormFields = async (): Promise<any> => {
const apiUrl: string = `/action/data/v1/form/read`;

try {
const response = await axios.post(apiUrl, {
request: {
action: "publish",
type: "content",
subType: "resource",
},
});
return response?.data;
} catch (error) {
console.error("Error in getting Framework Details", error);
return error;
}
};

0 comments on commit e965393

Please sign in to comment.