Skip to content
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
3 changes: 3 additions & 0 deletions api/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const HTTP_TEXTS = {
"Reseting the content mapping is restricted. Please verify the status and review preceding actions.",
CONTENTMAPPER_NOT_FOUND:
"Sorry, the requested content mapper id does not exists.",
ADMIN_LOGIN_ERROR:
"Sorry, You Don't have admin access in any of the Organisation"
};

export const HTTP_RESPONSE_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
Expand Down
8 changes: 7 additions & 1 deletion api/src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const login = async (req: Request): Promise<LoginServiceType> => {
method: "POST",
url: `${config.CS_API[
userData?.region as keyof typeof config.CS_API
]!}/user-session`,
]!}/user-session?include_orgs_roles=true`,
headers: {
"Content-Type": "application/json",
},
Expand All @@ -48,6 +48,12 @@ const login = async (req: Request): Promise<LoginServiceType> => {
status: err?.response?.status,
};
}
const orgs = (res?.data?.user?.organizations || [])
?.filter((org: any) => org?.org_roles?.some((item: any) => item.admin))
?.map(({ uid, name }: any) => ({ org_id: uid, org_name: name }));
if (!orgs.length) {
throw new BadRequestError(HTTP_TEXTS.ADMIN_LOGIN_ERROR);
}

if (res?.status === HTTP_CODES.SUPPORT_DOC)
return {
Expand Down
18 changes: 18 additions & 0 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,27 @@
src="https://ui.contentstack.com/contentstack.min.js"
async
></script>

<style type="text/css">
.skip-to-main-content-link {
position: absolute;
left: -9999px;
z-index: 999;
padding: 1em;
color: white;
opacity: 0;
}
.skip-to-main-content-link:focus {
left: 50%;
transform: translateX(-50%);
opacity: 1;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<a href="#root" class="skip-to-main-content-link">Skip to main content</a>

<div id="root"></div>
</body>
</html>
3 changes: 2 additions & 1 deletion ui/src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useContext, useEffect, useState } from 'react';
import { Tooltip } from '@contentstack/venus-components';
import { useNavigate } from 'react-router-dom';
// Utilities
import { PROJECT_STATUS } from '../../utilities/constants';
import { getDays, isEmptyString } from '../../utilities/functions';
import { AppContext } from '../../context/app/app.context';
// Interface
Expand Down Expand Up @@ -42,7 +43,7 @@ const CardList = ({ project }: ProjectType) => {
<div className="ProjectCard__stats">
<div className="ProjectCard__unit">
<span className="ProjectCard__stats-number">Project Status</span>
<span className="ProjectCard__stats-category">{project?.status}</span>
<span className="ProjectCard__stats-category">{PROJECT_STATUS?.[project?.status !== undefined ? project?.status : 0]}</span>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions ui/src/components/Common/AddStack/addStack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
width: 200px !important;
}
}
.ReactModal__Overlay .ReactModal__Content .ReactModal__Content__body.selectWrapperBody {
overflow: visible;
}

4 changes: 2 additions & 2 deletions ui/src/components/Common/AddStack/addStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const AddStack = (props: any): JSX.Element => {
setIsLoading(false);
});
}, []);

return (
<>
{isLoading ? (
Expand Down Expand Up @@ -110,7 +109,7 @@ const AddStack = (props: any): JSX.Element => {
<div className="ReactModal__add-stack">
<form onSubmit={handleSubmit}>
<ModalHeader title={addStackCMSData?.title} closeModal={props?.closeModal} />
<ModalBody className="no-scroll">
<ModalBody className="no-scroll selectWrapperBody">
<Field>
<ReactFinalField name="name" type="input">
{({ input, meta }): JSX.Element => {
Expand Down Expand Up @@ -204,6 +203,7 @@ const AddStack = (props: any): JSX.Element => {
name="locale"
width="300px"
options={props?.locales}
maxMenuHeight={200}
isClearable={true}
version={'v2'}
placeholder={addStackCMSData?.stack_locale_description}
Expand Down
16 changes: 8 additions & 8 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ const LoadStacks = (props: LoadFileFormatProps) => {
newMigrationData?.destination_stack?.selectedOrg?.value
); //org id will always be there


//fetch all locales
const response = await getAllLocales(newMigrationData?.destination_stack?.selectedOrg?.value); //org id will always be there
const response = await getAllLocales(selectedOrganisation?.value); //org id will always be there
const rawMappedLocalesMapped =
validateObject(response?.data) && response?.data?.locales
? Object?.keys(response?.data?.locales)?.map((key) => ({
Expand All @@ -153,7 +154,6 @@ const LoadStacks = (props: LoadFileFormatProps) => {
created_at: key
}))
: [];

setAllLocales(rawMappedLocalesMapped);

const stackArray = validateArray(stackData?.data?.stacks)
Expand Down Expand Up @@ -193,6 +193,12 @@ const LoadStacks = (props: LoadFileFormatProps) => {

updateNewMigrationData(newMigrationDataObj);
};

/**** ALL USEEffects HERE ****/
useEffect(() => {
fetchData();
}, []);

const handleCreateNewStack = () => {
cbModal({
component: (props: LoadFileFormatProps) => (
Expand All @@ -216,12 +222,6 @@ const LoadStacks = (props: LoadFileFormatProps) => {
}
});
};
/**** ALL USEEffects HERE ****/

useEffect(() => {
fetchData();
}, []);

return (
<div className="">
<div className="action-summary-wrapper ">
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/DestinationStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ const DestinationStackComponent = ({
//Check for migration Status and lock.
// Status where Migration is to be Locked:
setIsMigrationLocked(
projectData.status === PROJECT_STATUS.INPROGRESS ||
projectData.status === PROJECT_STATUS.SUCCESS
projectData?.status === 2 ||
projectData?.status === 5
);
};
fetchCMSData();
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
version="v2"
error={isError}
/>
{isError && <p className='errorMessage'>Affix should not be more than 5 chars</p>}
</div>
<div className="col-12 pt-2">
<Button version="v2" disabled={!isCheckedBoxChecked} onClick={handleOnBlur}>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ const LegacyCMSComponent = ({ legacyCMSData, projectData }: LegacyCMSComponentPr
//Check for migration Status and lock.
// Status where Migration is to be Locked:
setIsMigrationLocked(
projectData.status === PROJECT_STATUS.INPROGRESS ||
projectData.status === PROJECT_STATUS.SUCCESS
projectData?.status === 2 ||
projectData?.status === 5
);
};

Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/LegacyCms/legacyCms.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../scss/variables';
@import '../../scss/variables';
.service_list {
text-align: center;
display: flex;
Expand Down Expand Up @@ -67,6 +67,10 @@
width: 100%;
align-items: center;
padding: 0 !important;
border: 1px solid #dde3ee;
border: 1px solid $color-brand-secondary-lightest;
border-radius: var(--TermCount, 5px);
}
.errorMessage {
color: $color-brand-warning-medium;
font-size: 12px;
}
2 changes: 1 addition & 1 deletion ui/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Home = () => {

return (
<div className="d-flex vh-100 align-items-center justify-content-center flex-column">
{heading && <Heading tagName="h1" text={heading} className="pb-2" />}
{heading && <Heading tagName="h1" text={heading} className="pb-2 large-font" />}
{description && parse(description)}

{cta && cta?.title && (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/RegionalLogin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const RegionalLogin = () => {
<div className="d-flex vh-100 align-items-center justify-content-center flex-column">
<div className="container mx-auto">
<div className="text-center">
{heading && <Heading tagName="h1" text={heading} className="pb-2" />}
{heading && <Heading tagName="h1" text={heading} className="pb-2 large-font" />}
{description && description != '' && (
<div className="textStone600 pt-3">{parse(description as string)}</div>
)}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/scss/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ p {
// overflow: hidden;
}
h1 {
font-size: 2.125rem;
font-weight: $font-weight-bold;
&.large-font {
font-size: 2.125rem;
font-weight: $font-weight-bold;
}
}
.pb-32 {
padding-bottom: $px-32;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/services/api/service.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface MigrationResponse {
prefix: string;
name: string;
description: string;
status: string;
status: number;
created_at: string;
updated_at: string;
destination_stack_id: string;
Expand All @@ -51,7 +51,7 @@ export const defaultMigrationResponse: MigrationResponse = {
former_owner_ids: [],
name: '',
description: '',
status: '',
status: 0,
created_at: '',
updated_at: '',
destination_stack_id: '',
Expand Down
3 changes: 3 additions & 0 deletions ui/src/utilities/constants.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ObjectType {
[key: string]: string;
}
16 changes: 10 additions & 6 deletions ui/src/utilities/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ObjectType } from './constants.interface'
export const BASE_API_URL = process.env.REACT_APP_BASE_API_URL;
export const assetsRelativeUrl = 'v3/assets';
export const WEBSITE_BASE_URL = process.env.REACT_APP_WEBSITE_BASE_URL;
Expand Down Expand Up @@ -62,12 +63,15 @@ export const UPLOAD_FILE_RELATIVE_URL = process.env.REACT_APP_UPLOAD_SERVER;

export const UPLOAD_FILE_URL = `${UPLOAD_FILE_RELATIVE_URL}upload`;

export const PROJECT_STATUS = {
DRAFT: 'Draft',
READY: 'Ready',
INPROGRESS: 'InProgress',
FAILED: 'Failed',
SUCCESS: 'Success'

export const PROJECT_STATUS:ObjectType = {
'0': 'Draft',
'1': 'Ready to test',
'2': 'Testing inprogress',
'3': 'Ready for migration',
'4': 'Migration inprogress',
'5': 'Migration successful',
'6': 'Migration terminated'
};

export const isOfflineCMSDataRequired = process.env.REACT_APP_OFFLINE_CMS
Expand Down