Skip to content
Merged

Dev #218

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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/routes/org.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ router.get("/stacks/:searchText?", asyncRouter(orgController.getAllStacks));
*/
router.post(
"/stacks",
validator("project"),
validator("stack"),
asyncRouter(orgController.createStack)
);

Expand Down
2 changes: 2 additions & 0 deletions api/src/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import destinationStackValidator from "./destination-stack.validator.js";
import affixValidator from "./affix.validator.js";
import affixConfirmationValidator from "./affix-confirmation.validator.js";
import fileformatConfirmationValidator from "./fileformat-confirmation.validator.js";
import stackValidator from "./stack.validator.js";

/**
* Middleware function that validates the request based on the specified route.
Expand All @@ -26,6 +27,7 @@ export default (route: string = "") =>
affix: affixValidator,
affix_confirmation_validator: affixConfirmationValidator,
fileformat_confirmation_validator: fileformatConfirmationValidator,
stack: stackValidator
};

const validator = appValidators[route as keyof typeof appValidators];
Expand Down
46 changes: 46 additions & 0 deletions api/src/validators/stack.validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { checkSchema } from "express-validator";
import { VALIDATION_ERRORS } from "../constants/index.js";

/**
* Validates the stack data.
*
* @returns {Object} The validation schema for the stack data.
*/

export default checkSchema({
name: {
in: "body",
isString: {
errorMessage: VALIDATION_ERRORS.STRING_REQUIRED.replace("$", "Name"),
bail: true,
},
trim: true,
isLength: {
errorMessage: VALIDATION_ERRORS.LENGTH_LIMIT.replace("$", "Name"),
options: {
min: 1,
max: 255,
},
bail: true,
},
},
description: {
in: "body",
isString: {
errorMessage: VALIDATION_ERRORS.STRING_REQUIRED.replace(
"$",
"Description"
),
bail: true,
},
trim: true,
isLength: {
errorMessage: VALIDATION_ERRORS.LENGTH_LIMIT.replace("$", "Description"),
options: {
min: 1,
max: 512,
},
bail: true,
},
},
});
43 changes: 31 additions & 12 deletions ui/src/components/Common/SaveChangesModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@

// Libraries
import {
ModalBody,
ModalHeader,
ModalFooter,
ButtonGroup,
Button,
Paragraph
} from '@contentstack/venus-components';

interface Props {
closeModal: () => void;
isopen: any;
otherCmsTitle?: string;
saveContentType: () => void;
openContentType: () => void;
openContentType?: () => void;
changeStep?: () => void;
}

const SaveChangesModal = (props:Props) => {
const SaveChangesModal = (props: Props) => {
return(
<>
<ModalHeader title={'Save Changes'} closeModal={()=>{props?.closeModal(),props.isopen(false)}} className="text-capitalize" />
<ModalBody>
<div className='modal-data'>
<Paragraph tagName="p" text={`You have unsaved changes on this page. Please save the content type ${props?.otherCmsTitle || ''}.`} variant={"p1"}/>
</div>
<>
<ModalHeader
title={'Save Changes'}
closeModal={() => {
props?.closeModal();
props.isopen(false);
}}
className="text-capitalize"
/>
<ModalBody className="">
You have unsaved changes on content type <strong>{props?.otherCmsTitle || ''}</strong>. Save your changes if you don&apos;t want to lose them.
</ModalBody>
<ModalFooter>
<ButtonGroup>
<Button buttonType="secondary"version={"v2"} onClick={() => {props.closeModal(); props.isopen(false)}}>
<Button buttonType="light"version={"v2"} onClick={() => {props.closeModal(); props.isopen(false)}}>
Cancel
</Button>
<Button version={"v2"} onClick={() => { props.saveContentType(); props.closeModal(); props.openContentType() }}>Save</Button>
<Button buttonType="secondary"version={"v2"} onClick={() => {
props.closeModal();
props.openContentType?.();
props.isopen(false);
props?.changeStep?.();
}}
>
Don&apos;t Save
</Button>
<Button version={"v2"} onClick={() => {
props.saveContentType();
props.closeModal();
props.openContentType?.();
props?.changeStep?.();
}}>Save</Button>
</ButtonGroup>
</ModalFooter>
</>
Expand Down
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 @@ -91,6 +91,7 @@ export interface ContentTypesSchema {
data_type?: 'text' | 'number' | 'isodate' | 'json' | 'file' | 'reference' | 'group' | 'boolean' | 'link';
field_metadata?: FieldMetadata;
enum?: any;
schema?: ContentTypesSchema[]
}
// export interface ContentTypesSchema {
// [key: string]: ContentTypeField;
Expand Down
Loading