Skip to content

Commit bc40d75

Browse files
committed
fix: correct constant name from GET_AUIDT_DATA to GET_AUDIT_DATA and enhance response handling in migration controller for improved status management
1 parent 5d0a8d2 commit bc40d75

File tree

10 files changed

+43
-38
lines changed

10 files changed

+43
-38
lines changed

api/src/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export const MIGRATION_DATA_CONFIG = {
273273
EXPORT_INFO_FILE: "export-info.json",
274274
};
275275

276-
export const GET_AUIDT_DATA = {
276+
export const GET_AUDIT_DATA = {
277277
MIGRATION: "migration-v2",
278278
API_DIR: "api",
279279
MIGRATION_DATA_DIR: "migration-data",

api/src/controllers/migration.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ const deleteTestStack = async (req: Request, res: Response): Promise<void> => {
5151
};
5252
const getAuditData = async (req: Request, res: Response): Promise<void> => {
5353
const resp = await migrationService.getAuditData(req);
54-
res.status(200).json(resp);
54+
res.status(resp?.status).json(resp);
5555
};
5656
const getLogs = async (req: Request, res: Response): Promise<void> => {
5757
const resp = await migrationService.getLogs(req);
58-
res.status(200).json(resp);
58+
res.status(resp?.status).json(resp);
5959
};
6060

6161
const saveLocales = async (req: Request, res: Response): Promise<void> => {

api/src/services/migration.service.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import https from "../utils/https.utils.js";
77
import { LoginServiceType } from "../models/types.js";
88
import getAuthtoken from "../utils/auth.utils.js";
99
import logger from "../utils/logger.js";
10-
import { GET_AUIDT_DATA } from "../constants/index.js";
10+
import { GET_AUDIT_DATA } from "../constants/index.js";
1111
import {
1212
HTTP_TEXTS,
1313
HTTP_CODES,
@@ -157,8 +157,8 @@ const getAuditData = async (req: Request): Promise<any> => {
157157
}
158158

159159
try {
160-
const mainPath = process?.cwd()?.split?.(GET_AUIDT_DATA?.MIGRATION)?.[0];
161-
const logsDir = path.join(mainPath, GET_AUIDT_DATA?.MIGRATION, GET_AUIDT_DATA?.API_DIR, GET_AUIDT_DATA?.MIGRATION_DATA_DIR);
160+
const mainPath = process?.cwd()?.split?.(GET_AUDIT_DATA?.MIGRATION)?.[0];
161+
const logsDir = path.join(mainPath, GET_AUDIT_DATA?.MIGRATION, GET_AUDIT_DATA?.API_DIR, GET_AUDIT_DATA?.MIGRATION_DATA_DIR);
162162

163163
const stackFolders = fs.readdirSync(logsDir);
164164

@@ -167,7 +167,7 @@ const getAuditData = async (req: Request): Promise<any> => {
167167
throw new BadRequestError("Migration data not found for this stack");
168168
}
169169

170-
const auditLogPath = path?.resolve(logsDir, stackFolder, GET_AUIDT_DATA?.LOGS_DIR, GET_AUIDT_DATA?.AUDIT_DIR, GET_AUIDT_DATA?.AUDIT_REPORT);
170+
const auditLogPath = path?.resolve(logsDir, stackFolder, GET_AUDIT_DATA?.LOGS_DIR, GET_AUDIT_DATA?.AUDIT_DIR, GET_AUDIT_DATA?.AUDIT_REPORT);
171171
if (!fs.existsSync(auditLogPath)) {
172172
throw new BadRequestError("Audit log path not found");
173173
}
@@ -192,7 +192,7 @@ const getAuditData = async (req: Request): Promise<any> => {
192192
throw new BadRequestError(`No audit data found for module: ${moduleName}`);
193193
}
194194
let transformedData = transformAndFlattenData(fileData);
195-
if (filter != GET_AUIDT_DATA?.FILTERALL) {
195+
if (filter != GET_AUDIT_DATA?.FILTERALL) {
196196
const filters = filter?.split("-");
197197
moduleName === 'Entries_Select_feild' ? transformedData = transformedData?.filter((log) => {
198198
return filters?.some((filter) => {
@@ -222,7 +222,8 @@ const getAuditData = async (req: Request): Promise<any> => {
222222

223223
return {
224224
data: paginatedData,
225-
totalCount: transformedData?.length
225+
totalCount: transformedData?.length,
226+
status: HTTP_CODES?.OK
226227
};
227228

228229
} catch (error: any) {
@@ -250,24 +251,24 @@ const transformAndFlattenData = (data: any): Array<{ [key: string]: any, id: num
250251
// Handle the data based on its structure
251252
if (Array.isArray(data)) {
252253
// If data is already an array, use it directly
253-
data.forEach((item, index) => {
254-
flattenedItems.push({
254+
data?.forEach((item, index) => {
255+
flattenedItems?.push({
255256
...item ?? {},
256-
uid: item.uid || `item-${index}`
257+
uid: item?.uid || `item-${index}`
257258
});
258259
});
259260
} else if (typeof data === 'object' && data !== null) {
260261
Object?.entries?.(data)?.forEach(([key, value]) => {
261262
if (Array.isArray(value)) {
262-
value.forEach((item, index) => {
263+
value?.forEach((item, index) => {
263264
flattenedItems?.push({
264265
...item ?? {},
265266
parentKey: key,
266267
uid: item?.uid || `${key}-${index}`
267268
});
268269
});
269270
} else if (typeof value === 'object' && value !== null) {
270-
flattenedItems.push({
271+
flattenedItems?.push({
271272
...value,
272273
key,
273274
uid: (value as any)?.uid || key
@@ -972,9 +973,9 @@ const getLogs = async (req: Request): Promise<any> => {
972973
if (!logEntries?.length) {
973974
return { logs: [], total: 0 };
974975
}
975-
const filterOptions = Array.from(new Set(logEntries.map((log) => log.level)));
976-
const auditStartIndex = logEntries.findIndex(log => log.message.includes("Starting audit process"));
977-
const auditEndIndex = logEntries.findIndex(log => log.message.includes("Audit process completed"));
976+
const filterOptions = Array?.from(new Set(logEntries?.map((log) => log?.level)));
977+
const auditStartIndex = logEntries?.findIndex?.(log => log?.message?.includes("Starting audit process"));
978+
const auditEndIndex = logEntries?.findIndex?.(log => log?.message?.includes("Audit process completed"));
978979
logEntries = [
979980
...logEntries.slice(0, auditStartIndex),
980981
...logEntries.slice(auditEndIndex + 1)
@@ -1000,6 +1001,7 @@ const getLogs = async (req: Request): Promise<any> => {
10001001
logs: paginatedLogs,
10011002
total: logEntries?.length ?? 0,
10021003
filterOptions: filterOptions,
1004+
status: HTTP_CODES?.OK
10031005
};
10041006
} else {
10051007
logger.error(getLogMessage(srcFunc, HTTP_TEXTS.LOGS_NOT_FOUND));

ui/src/cmsData/setting.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"execution_logs": {
2929
"title": "Execution Logs"
3030
},
31+
"audit_logs": {
32+
"title": "Audit Logs"
33+
},
3134
"tags": [],
3235
"locale": "en-us",
3336
"uid": "blt96cda740c3157d20",
@@ -37,4 +40,4 @@
3740
"updated_at": "2024-03-11T06:03:23.420Z",
3841
"_version": 3,
3942
"_in_progress": false
40-
}
43+
}

ui/src/components/AuditFilterModal/index.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
position: absolute;
55
z-index: 1000;
66
width: 350px;
7-
background-color: #ffffff;
7+
background-color: $color-brand-white-base;
88
border-radius: 12px;
9-
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
9+
box-shadow: 0 8px 24px $color-base-black-31;
1010
display: flex;
1111
flex-direction: column;
1212
max-height: 350px;
@@ -65,10 +65,10 @@
6565
}
6666

6767
.close-btn:hover {
68-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
68+
box-shadow: 0 4px 12px $color-base-black-31;
6969
transform: scale(1.05);
7070
border-radius: 8px;
71-
background-color: #f0f1f3;
71+
background-color: $color-base-black-31 ;
7272
cursor: pointer;
7373
transition:
7474
box-shadow 0.2s ease,

ui/src/components/Common/Settings/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ const Settings = () => {
264264
{active === cmsData?.execution_logs?.title && (
265265
<ExecutionLog projectId={projectId} />
266266
)}
267-
{active === "AuditLogs" &&
267+
{active === cmsData?.audit_logs?.title &&
268268
<AuditLogs />
269269

270270
}
@@ -322,12 +322,12 @@ const Settings = () => {
322322
/>
323323
<ListRow
324324
rightArrow={true}
325-
active={active === "AuditLogs"}
326-
content={"AuditLogs"}
325+
active={active === cmsData?.audit_logs?.title}
326+
content={cmsData?.audit_logs?.title}
327327
leftIcon={<Icon icon="Stacks" version="v2" />}
328328
onClick={() => {
329-
setActive("AuditLogs");
330-
setCurrentHeader("AuditLogs");
329+
setActive(cmsData?.audit_logs?.title);
330+
setCurrentHeader(cmsData?.audit_logs?.title);
331331
}}
332332
version="v2"
333333
/>

ui/src/components/Common/Settings/setting.interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface CTA {
2121
title: string;
2222
url: string;
2323
with_icon: boolean;
24-
icon: string
24+
icon: string
2525
}
2626
interface IExecutionLogs {
2727
title: string;
@@ -33,5 +33,6 @@ interface IExecutionLogs {
3333
export interface Setting {
3434
project?: IProject;
3535
execution_logs?: IExecutionLogs;
36+
audit_logs?: IExecutionLogs;
3637
title?: string;
3738
}

ui/src/components/ExecutionLogs/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
300300
isRowSelect={false}
301301
columnSelector={false}
302302
canSearch={true}
303-
searchPlaceholder={EXECUTION_LOGS_UI_TEXT.SEARCH_PLACEHOLDER}
303+
searchPlaceholder={EXECUTION_LOGS_UI_TEXT?.SEARCH_PLACEHOLDER}
304304
searchValue={searchText ?? ''}
305305
onSearchChangeEvent={(value: string) => setSearchText(value)}
306306
withExportCta={{
@@ -311,7 +311,7 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
311311
version="v2"
312312
value={testStacks?.length ? selectedStack : ''}
313313
options={stackIds ?? []}
314-
placeholder={EXECUTION_LOGS_UI_TEXT.SELECT_PLACEHOLDER}
314+
placeholder={EXECUTION_LOGS_UI_TEXT?.SELECT_PLACEHOLDER}
315315
onChange={(s: DropdownOption) => {
316316
setSelectedStack({
317317
label: s?.label ?? '',
@@ -326,13 +326,13 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
326326
customEmptyState={
327327
<EmptyState
328328
forPage="list"
329-
heading={searchText === '' ? EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_HEADING.NO_LOGS : EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_HEADING.NO_MATCH}
329+
heading={searchText === '' ? EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_HEADING?.NO_LOGS : EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_HEADING?.NO_MATCH}
330330
description={
331331
searchText === ''
332-
? EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_DESCRIPTION.NO_LOGS
333-
: EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_DESCRIPTION.NO_RESULT
332+
? EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_DESCRIPTION?.NO_LOGS
333+
: EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_DESCRIPTION?.NO_RESULT
334334
}
335-
moduleIcon={searchText === '' ? EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_ICON.NO_LOGS : EXECUTION_LOGS_UI_TEXT.EMPTY_STATE_ICON.NO_MATCH}
335+
moduleIcon={searchText === '' ? EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_ICON?.NO_LOGS : EXECUTION_LOGS_UI_TEXT?.EMPTY_STATE_ICON?.NO_MATCH}
336336
type="secondary"
337337
className="custom-empty-state"
338338
/>

ui/src/services/api/project.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getAuditData = async (orgId: string, projectId: string, stackId: st
2525
return await getCall(`${API_VERSION}/migration/get_audit_data/${orgId}/${projectId}/${stackId}/${moduleName}/${skip}/${limit}/${startIndex}/${stopIndex}/${searchText}/${filter}`, options());
2626
} catch (error) {
2727
if (error instanceof Error) {
28-
throw new Error(`Error in userSession: ${error.message}`);
28+
throw new Error(`Error in userSession: ${error?.message}`);
2929
} else {
3030
throw new Error('Unknown error in userSession');
3131
}

upload-api/src/config/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
plan: {
33
dropdown: { optionLimit: 100 }
44
},
5-
cmsType: 'sitecore',
5+
cmsType: 'contentful',
66
isLocalPath: true,
77
awsData: {
88
awsRegion: 'us-east-2',
@@ -12,6 +12,5 @@ export default {
1212
bucketName: '',
1313
bucketKey: ''
1414
},
15-
// localPath: '/Users/sayali.joshi/Downloads/contentfulDummyEmbedData.json' //package 45.zip'
16-
localPath: '/Users/samarp.jain/Desktop/package 45.zip',
15+
localPath: 'your-local-legacy-cms-path',
1716
};

0 commit comments

Comments
 (0)