Skip to content

Commit d1148a5

Browse files
authored
[UI] Add comment management to the Version Details page (#4944)
* Auto format mappedqueryimpl * Fix kafkasql stapshotting * Code formatting * Added Comment management on the Version Details page (UI)
1 parent 7067870 commit d1148a5

File tree

8 files changed

+512
-37
lines changed

8 files changed

+512
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { FunctionComponent, useEffect, useState } from "react";
2+
import { Button, Form, FormGroup, Modal, TextArea } from "@patternfly/react-core";
3+
import { NewComment } from "@sdk/lib/generated-client/models";
4+
5+
6+
/**
7+
* Properties
8+
*/
9+
export type CreateCommentModalProps = {
10+
isOpen: boolean;
11+
onClose: () => void;
12+
onCreateComment: (value: NewComment) => void;
13+
};
14+
15+
export const CreateCommentModal: FunctionComponent<CreateCommentModalProps> = (props: CreateCommentModalProps) => {
16+
const [value, setValue] = useState<string>("");
17+
18+
const isValid: boolean = value !== undefined && value.trim().length > 0;
19+
20+
useEffect(() => {
21+
if (props.isOpen) {
22+
setValue("");
23+
}
24+
}, [props.isOpen]);
25+
26+
return (
27+
<Modal
28+
title="Add comment"
29+
variant="medium"
30+
isOpen={props.isOpen}
31+
onClose={props.onClose}
32+
className="add-comment pf-m-redhat-font"
33+
actions={[
34+
<Button key="add" variant="primary" data-testid="modal-btn-add" onClick={() => { props.onCreateComment({ value }); }} isDisabled={!isValid}>Add</Button>,
35+
<Button key="cancel" variant="link" data-testid="modal-btn-cancel" onClick={props.onClose}>Cancel</Button>
36+
]}
37+
>
38+
<Form>
39+
<FormGroup label="Comment" fieldId="form-comment" isRequired={true}>
40+
<TextArea
41+
style={{ height: "100px" }}
42+
isRequired={false}
43+
id="form-comment"
44+
data-testid="edit-metadata-modal-comment"
45+
name="form-comment"
46+
aria-describedby="form-comment-helper"
47+
value={value}
48+
placeholder="Enter a new comment"
49+
onChange={(evt, newValue) => setValue(newValue)}
50+
/>
51+
</FormGroup>
52+
</Form>
53+
</Modal>
54+
);
55+
56+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { FunctionComponent, useEffect, useState } from "react";
2+
import { Button, Form, FormGroup, Modal, TextArea } from "@patternfly/react-core";
3+
import { Comment, NewComment } from "@sdk/lib/generated-client/models";
4+
5+
6+
/**
7+
* Properties
8+
*/
9+
export type EditCommentModalProps = {
10+
comment: Comment;
11+
isOpen: boolean;
12+
onClose: () => void;
13+
onEditComment: (commentId: string, value: NewComment) => void;
14+
};
15+
16+
export const EditCommentModal: FunctionComponent<EditCommentModalProps> = (props: EditCommentModalProps) => {
17+
const [value, setValue] = useState<string>("");
18+
19+
const isValid: boolean = value !== undefined && value.trim().length > 0;
20+
21+
useEffect(() => {
22+
if (props.isOpen) {
23+
setValue(props.comment.value!);
24+
}
25+
}, [props.isOpen]);
26+
27+
return (
28+
<Modal
29+
title="Edit comment"
30+
variant="medium"
31+
isOpen={props.isOpen}
32+
onClose={props.onClose}
33+
className="edit-comment pf-m-redhat-font"
34+
actions={[
35+
<Button key="edit" variant="primary" data-testid="modal-btn-edit" onClick={() => {
36+
props.onEditComment(props.comment.commentId!, { value }); }} isDisabled={!isValid}>Edit</Button>,
37+
<Button key="cancel" variant="link" data-testid="modal-btn-cancel" onClick={props.onClose}>Cancel</Button>
38+
]}
39+
>
40+
<Form>
41+
<FormGroup label="Comment" fieldId="form-comment" isRequired={true}>
42+
<TextArea
43+
style={{ height: "100px" }}
44+
isRequired={false}
45+
id="form-comment"
46+
data-testid="edit-metadata-modal-comment"
47+
name="form-comment"
48+
aria-describedby="form-comment-helper"
49+
value={value}
50+
placeholder="Edit the comment"
51+
onChange={(evt, newValue) => setValue(newValue)}
52+
/>
53+
</FormGroup>
54+
</Form>
55+
</Modal>
56+
);
57+
58+
};

ui/ui-app/src/app/components/modals/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ export * from "./ChangeOwnerModal";
22
export * from "./ConfirmDeleteModal";
33
export * from "./CreateArtifactModal";
44
export * from "./CreateBranchModal";
5+
export * from "./CreateCommentModal";
56
export * from "./CreateGroupModal";
67
export * from "./CreateVersionModal";
8+
export * from "./EditCommentModal";
79
export * from "./EditMetaDataModal";
810
export * from "./InvalidContentModal";
911
export * from "./LabelsFormGroup";

0 commit comments

Comments
 (0)