Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
stacks limit check
  • Loading branch information
RohitKini committed Sep 26, 2024
commit c456e3e341e654a61eda8882377abcec66c45b6e
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,
};
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: 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,
};
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: 1 addition & 1 deletion ui/src/components/TestMigration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const TestMigration = () => {
<div className='content-block'>
<div className='content-header'>Execution Logs</div>
<div>
<LogViewer serverPath="http://localhost:5000" />
<LogViewer serverPath="http://localhost:5001" />
</div>
</div>
</div>
Expand Down
22 changes: 21 additions & 1 deletion ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { RootState } from '../../store';
import { updateMigrationData, updateNewMigrationData } from '../../store/slice/migrationDataSlice';

// Services
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, createTestStack, updateAffixData, fileformatConfirmation, updateFileFormatData, affixConfirmation, updateStackDetails } from '../../services/api/migration.service';
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, createTestStack, updateAffixData, fileformatConfirmation, updateFileFormatData, affixConfirmation, updateStackDetails, getOrgDetails } from '../../services/api/migration.service';
import { getAllStacksInOrg } from '../../services/api/stacks.service';
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

// Utilities
Expand Down Expand Up @@ -367,6 +368,25 @@ const Migration = () => {
const handleOnClickContentMapper = async (event: MouseEvent) => {
setIsModalOpen(true);

//get org plan details
const orgDetails = await getOrgDetails(selectedOrganisation?.value);
const stacks_details_key = Object.keys(orgDetails?.data?.organization?.plan?.features).find(key => orgDetails?.data?.organization?.plan?.features[key].uid === 'stacks') || '';

const max_stack_limit = orgDetails?.data?.organization?.plan?.features[stacks_details_key]?.max_limit;

const stackData = await getAllStacksInOrg(selectedOrganisation?.value, ''); // org id will always be there

const stack_count = stackData?.data?.stacks?.length;

if (stack_count >= max_stack_limit) {
setIsLoading(false);
Notification({
notificationContent: { text: 'You have reached the maximum limit of stacks for your organization' },
type: 'warning'
});
return;
}

if(newMigrationData?.content_mapping?.isDropDownChanged){
return cbModal({
component: (props: ModalObj) => (
Expand Down
12 changes: 11 additions & 1 deletion ui/src/services/api/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,14 @@ export const updateStackDetails = async(orgId: string, projectId: string, data:
return error;

}
}
}

export const getOrgDetails = async(orgId: string) => {
try {
return await getCall(`${API_VERSION}/org/${orgId}/get_org_details`, options);
} catch (error) {
return error;
}
}

// const { orgId } = req.params;
2 changes: 1 addition & 1 deletion upload-api/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PORT=4002
NODE_BACKEND_API =http://localhost:5000
NODE_BACKEND_API =http://localhost:5001
2 changes: 1 addition & 1 deletion upload-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default {
bucketName: 'migartion-test',
buketKey: 'project/package 45.zip'
},
localPath: '/Users/umesh.more/Documents/ui-migration/migration-v2-node-server/upload-api/extracted_files/package 45.zip'
localPath: '/Users/rohit/Desktop/package 45.zip'
};