Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3753d46
Resolved mapped content types disable issue
sayalijoshi27 Sep 16, 2024
7d3a1ea
Merge pull request #277 from contentstack/bugfix/content-mapper
RohitKini Sep 16, 2024
d330ad9
refactor:content mapper bugs
AishDani Sep 17, 2024
1942f7b
Merge pull request #278 from contentstack/feature/dropdown-field-choices
RohitKini Sep 17, 2024
9111c79
[CMG-312] - Destination stack | When an existing project is open and …
sayalijoshi27 Sep 17, 2024
ee3449f
Merge pull request #279 from contentstack/bugfix/content-mapper
RohitKini Sep 17, 2024
b2d3fdc
Fixed bug CMG-315
BhagyahsreeMatere Sep 17, 2024
e87f622
Merge pull request #280 from contentstack/bugfix/popup-modal
RohitKini Sep 17, 2024
4058b10
refactor:resolved uncaught error deu to token expiration
AishDani Sep 17, 2024
1d709e7
[CMG-317] - Destination stack | When creating a new project and going…
sayalijoshi27 Sep 17, 2024
76816e2
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Sep 17, 2024
3072571
refactor:content-mapper-bugs
AishDani Sep 5, 2024
ab68581
refactor:css for required text
AishDani Sep 17, 2024
a4d6731
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Sep 17, 2024
3aaf384
refactor:legacy cms validation msg was getting showed for empty project
AishDani Sep 18, 2024
7c8ede5
refactor:required text in all steps of legacy cms
AishDani Sep 18, 2024
55937b8
Merge pull request #282 from contentstack/feature/dropdown-field-choices
RohitKini Sep 18, 2024
05f941c
Merge pull request #281 from contentstack/bugfix/content-mapper
RohitKini Sep 18, 2024
8a12ba4
[CMG-129], [CMG-136]
sayalijoshi27 Sep 18, 2024
fd18eba
Merge pull request #285 from contentstack/bugfix/content-mapper
RohitKini Sep 18, 2024
b29e2b0
refactor:content mapper bugs
AishDani Sep 20, 2024
e8d18db
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Sep 20, 2024
5391588
Merge pull request #287 from contentstack/feature/dropdown-field-choices
RohitKini Sep 20, 2024
4ddabee
refactor:changed logic for setting stepIndex in stepper to avoid by d…
AishDani Sep 20, 2024
0586d91
refactor:removed file format confirmation api call form useEffect
AishDani Sep 20, 2024
d8d6bbc
refactor:content mapper bugs and api calls
AishDani Sep 20, 2024
be3c5c5
refcator:uncommented code for isDropdown change
AishDani Sep 20, 2024
0170197
Merge pull request #288 from contentstack/feature/dropdown-field-choices
RohitKini Sep 20, 2024
20e5293
[CMG-324] - Content mapper | Global fields | When opening global fiel…
sayalijoshi27 Sep 20, 2024
b1eff9c
Conflict resolved
sayalijoshi27 Sep 20, 2024
ebf6800
Dropdown placeholder changes for global fields
sayalijoshi27 Sep 23, 2024
b57a338
Merge pull request #289 from contentstack/bugfix/content-mapper
RohitKini Sep 23, 2024
a26cd52
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
RohitKini Sep 24, 2024
c456e3e
stacks limit check
RohitKini Sep 26, 2024
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
2 changes: 1 addition & 1 deletion api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type ConfigType = {
* Configuration object for the application.
*/
export const config: ConfigType = {
APP_TOKEN_EXP: "1d",
APP_TOKEN_EXP: "2d",
PORT: process.env.PORT!,
APP_ENV: process.env.NODE_ENV!,
APP_TOKEN_KEY: process.env.APP_TOKEN_KEY!,
Expand Down
15 changes: 14 additions & 1 deletion api/src/controllers/org.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,24 @@ const getStackLocale = async (req: Request, res: Response) => {
res.status(resp.status).json(resp.data);
};

/* Retrieves the org details.
*
* @param req - The request object.
* @param res - The response object.
* @returns A Promise that resolves to the org details response.
*/
const getOrgDetails = async (req: Request, res: Response) => {
const resp = await orgService.getOrgDetails(req);
res.status(resp.status).json(resp.data);
};



export const orgController = {
getAllStacks,
createStack,
getLocales,
getStackStatus,
getStackLocale
getStackLocale,
getOrgDetails,
};
19 changes: 18 additions & 1 deletion api/src/controllers/projects.contentMapper.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ const getExistingContentTypes = async (
const resp = await contentMapperService.getExistingContentTypes(req);
res.status(201).json(resp);
};

/**
* Retrieves the existing global fields.
*
* @param {Request} req - The request object.
* @param {Response} res - The response object.
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
*/
const getExistingGlobalFields = async (
req: Request,
res: Response
): Promise<void> => {
const resp = await contentMapperService.getExistingGlobalFields(req);
res.status(201).json(resp);
};

/**
* Updates the content type fields.
*
Expand Down Expand Up @@ -131,5 +147,6 @@ export const contentMapperController = {
// removeMapping,
getSingleContentTypes,
removeContentMapper,
updateContentMapper
updateContentMapper,
getExistingGlobalFields
};
2 changes: 1 addition & 1 deletion api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface Project {
isNewStack: boolean;
newStackId: string;
stackDetails: [];
mapperKeys: [];
mapperKeys: {};
extract_path: string;
}

Expand Down
9 changes: 9 additions & 0 deletions api/src/routes/contentMapper.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ router.get(
asyncRouter(contentMapperController.getExistingContentTypes)
);

/**
* Get Existing GlobalFields List
* @route GET /:projectId
*/
router.get(
"/globalFields/:projectId",
asyncRouter(contentMapperController.getExistingGlobalFields)
);

/**
* Update FieldMapping or contentType
* @route PUT /contentTypes/:orgId/:projectId/:contentTypeId
Expand Down
9 changes: 9 additions & 0 deletions api/src/routes/org.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ router.post(
router.get("/get_stack_locales", asyncRouter(orgController.getStackLocale));


/**
* GET all contentstack org details route.
* @param req - Express request object.
* @param res - Express response object.
*/
router.get("/get_org_details", asyncRouter(orgController.getOrgDetails));



export default router;
58 changes: 53 additions & 5 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ const getExistingContentTypes = async (req: Request) => {
data: err.response.data,
status: err.response.status,
};

const contentTypes = res.data.content_types.map((singleCT: any) => {
return {
title: singleCT.title,
Expand All @@ -280,6 +279,57 @@ const getExistingContentTypes = async (req: Request) => {
//Add logic to get Project from DB
return { contentTypes };
};

/**
* Retrieves existing global fields for a given project.
* @param req - The request object containing the project ID and token payload.
* @returns An object containing the retrieved content types.
*/
const getExistingGlobalFields = async (req: Request) => {
const projectId = req?.params?.projectId;

const { token_payload } = req.body;

const authtoken = await getAuthtoken(
token_payload?.region,
token_payload?.user_id
);
await ProjectModelLowdb.read();
const project = ProjectModelLowdb.chain
.get("projects")
.find({ id: projectId })
.value();
const stackId = project?.destination_stack_id;
const [err, res] = await safePromise(
https({
method: "GET",
url: `${config.CS_API[
token_payload?.region as keyof typeof config.CS_API
]!}/global_fields`,
headers: {
api_key: stackId,
authtoken: authtoken,
},
})
);

if (err)
return {
data: err.response.data,
status: err.response.status,
};
const globalFields = res.data.global_fields.map((global: any) => {
return {
title: global.title,
uid: global.uid,
schema: global.schema,
};
});

//Add logic to get Project from DB
return { globalFields };
};

/**
* Updates the content type based on the provided request.
* @param req - The request object containing the necessary parameters and data.
Expand Down Expand Up @@ -923,8 +973,6 @@ const removeContentMapper = async (req: Request) => {
* @throws ExceptionFunction if an error occurs during the update.
*/
const updateContentMapper = async (req: Request) => {
console.info("updateContentMapper", req.params, req.body);

const { orgId, projectId } = req.params;
const { token_payload, content_mapper } = req.body;
const srcFunc = "updateContentMapper";
Expand All @@ -944,7 +992,6 @@ const updateContentMapper = async (req: Request) => {

try {
ProjectModelLowdb.update((data: any) => {
// console.info("data ===============", data, content_mapper)
data.projects[projectIndex].mapperKeys = content_mapper;
data.projects[projectIndex].updated_at = new Date().toISOString();
});
Expand Down Expand Up @@ -989,5 +1036,6 @@ export const contentMapperService = {
removeContentMapper,
removeMapping,
getSingleContentTypes,
updateContentMapper
updateContentMapper,
getExistingGlobalFields
};
58 changes: 58 additions & 0 deletions api/src/services/org.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,68 @@ const getStackLocale = async (req: Request) => {
}
};

/**
* Retrieves the plan details of a org.
* @param req - The request object containing the orgId, token_payload.
* @returns An object containing the org details.
* @throws ExceptionFunction if an error occurs while getting the org details.
*/
const getOrgDetails = async (req: Request) => {
const { orgId } = req.params;
const { token_payload } = req.body;
const srcFunc = "getOrgDetails";

const authtoken = await getAuthtoken(
token_payload?.region,
token_payload?.user_id
);

try {
const [stackErr, stackRes] = await safePromise(
https({
method: "GET",
url: `${config.CS_API[
token_payload?.region as keyof typeof config.CS_API
]!}/organizations/${orgId}?include_plan=true`,
headers: {
authtoken,
},
})
);

if (stackErr)
return {
data: {
message: HTTP_TEXTS.DESTINATION_STACK_ERROR,
},
status: stackErr.response.status,
};

return {
status: HTTP_CODES.OK,
data: stackRes.data,
};
} catch (error: any) {
logger.error(
getLogMessage(
srcFunc,
`Error occurred while getting locales a stack.`,
token_payload,
error
)
);
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};

export const orgService = {
getAllStacks,
getLocales,
createStack,
getStackStatus,
getStackLocale,
getOrgDetails,
};
2 changes: 1 addition & 1 deletion api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const createProject = async (req: Request) => {
created_at: '',
isNewStack: false
},
mapperKeys: []
mapperKeys: {}
};

try {
Expand Down
11 changes: 10 additions & 1 deletion ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"axios": "^1.5.1",
"bootstrap": "5.1.3",
"chokidar": "^3.6.0",
"final-form": "^4.20.10",
"html-react-parser": "^4.2.9",
"jwt-decode": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-final-form": "^6.5.9",
Expand Down
7 changes: 3 additions & 4 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Libraries
import { Suspense, useEffect } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
Expand All @@ -9,11 +10,12 @@ import { persistor, store } from './store';
import AppRouter from './components/Common/router';
import ErrorBoundary from './components/ErrorBoundary';
import AppLayout from './components/layout/AppLayout';
import { useNetworkCheck } from './components/NetworkProvider';


// Styles
import '@contentstack/venus-components/build/main.css';
import './scss/App.scss';
import { useNetworkCheck } from './components/NetworkProvider';

function App() {
const isOnline = useNetworkCheck();
Expand All @@ -25,9 +27,6 @@ function App() {
if (!isOnline) {
// Hide the modal by setting display to none
selectModal.style.display = 'none';
} else {
// Show the modal by setting display to block
selectModal.style.display = 'block';
}
}
}, [isOnline]);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/cmsData/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"type": "doc",
"_version": 12
},
"heading": "Welcome to Content Migrations",
"heading": "Welcome to Content Migration!",
"help_text": {
"type": "doc",
"attrs": {},
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/AdvancePropertise/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@
font-size: 14px;
color: $color-stepper-title;

}
}
1 change: 1 addition & 0 deletions ui/src/components/ContentMapper/contentMapper.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface FieldMetadata {
allow_json_rte?: boolean;
}
export interface ContentTypesSchema {
display_type: string;
data_type?: 'text' | 'number' | 'isodate' | 'json' | 'file' | 'reference' | 'group' | 'boolean' | 'link';
display_name: string;
enum?: any;
Expand Down
Loading