forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : markdown support for group description (datahub-project#9455)
- Loading branch information
1 parent
e58e2bf
commit b4fe451
Showing
4 changed files
with
261 additions
and
60 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
datahub-web-react/src/app/entity/group/EditGroupDescriptionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useState } from 'react'; | ||
import { Button, Modal, Form } from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
import { Editor } from '../shared/tabs/Documentation/components/editor/Editor'; | ||
import { ANTD_GRAY } from '../shared/constants'; | ||
|
||
type Props = { | ||
onClose: () => void; | ||
onSaveAboutMe: () => void; | ||
setStagedDescription: (des: string) => void; | ||
stagedDescription: string | undefined; | ||
}; | ||
const StyledEditor = styled(Editor)` | ||
border: 1px solid ${ANTD_GRAY[4]}; | ||
`; | ||
|
||
export default function EditGroupDescriptionModal({ | ||
onClose, | ||
onSaveAboutMe, | ||
setStagedDescription, | ||
stagedDescription, | ||
}: Props) { | ||
const [form] = Form.useForm(); | ||
const [aboutText,setAboutText] = useState(stagedDescription) | ||
|
||
function updateDescription(description: string) { | ||
setAboutText(aboutText) | ||
setStagedDescription(description); | ||
|
||
} | ||
|
||
const saveDescription = () => { | ||
onSaveAboutMe(); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
width={700} | ||
title="Edit Description" | ||
visible | ||
onCancel={onClose} | ||
footer={ | ||
<> | ||
<Button onClick={onClose} type="text"> | ||
Cancel | ||
</Button> | ||
<Button id="updateGroupButton" onClick={saveDescription} disabled={!stagedDescription}> | ||
Update | ||
</Button> | ||
</> | ||
} | ||
> | ||
<Form form={form} initialValues={{}} layout="vertical"> | ||
<Form.Item name="description" rules={[{ whitespace: true }, { min: 1, max: 500 }]} hasFeedback> | ||
<div> | ||
<StyledEditor content={aboutText} onChange={updateDescription} /> | ||
</div> | ||
</Form.Item> | ||
</Form> | ||
</Modal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.