Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui) Add documentation to term/node creation modal #6294

Conversation

chriscollins3456
Copy link
Collaborator

When creating Terms and Nodes, now allow users to input their desired documentation so they don't have to immediately do and add it afterwords. All the backend/graphql stuff is already in place for this so it's just adding this piece to the modal.

Here we are:
image

When clicking add documentation:
image

After adding it, it now says "Edit Documentation" which you can click to see your documentation or edit it
image

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Oct 26, 2022
@github-actions
Copy link

github-actions bot commented Oct 26, 2022

Unit Test Results (build & test)

599 tests  ±0   595 ✔️ ±0   12m 1s ⏱️ -8s
149 suites ±0       4 💤 ±0 
149 files   ±0       0 ±0 

Results for commit 100fef5. ± Comparison against base commit 228c10d.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@aditya-radhakrishnan aditya-radhakrishnan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the Edit Description text to be blue?

@chriscollins3456
Copy link
Collaborator Author

Do we want the Edit Description text to be blue?

@aditya-radhakrishnan I thought it was nice in order to make it pop and make it clear that it's user input (not just more form info). What were you thinking?

const [createButtonDisabled, setCreateButtonDisabled] = useState(true);
const refetch = useRefetch();

const [createGlossaryTermMutation] = useCreateGlossaryTermMutation();
const [createGlossaryNodeMutation] = useCreateGlossaryNodeMutation();

const sanitizedDocumentation = DOMPurify.sanitize(documentation);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool! what is this DOMPurify thing doing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's protecting against something like a XSS attack by preventing us from sending back and rendering unsafe html! DOMPurify has a built in list of do-not-allow tags and what not so that users can't try to submit a <script>{do_something}</script> that could then get rendered and be no bueno. So we sanitize markdown before sending to the backend, but just as importantly, before rendering the markdown on the page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm realizing now that I don't really need this sanitization here though, as I'm no longer rendering this rich text in the modal like I was before (when I demo'd) so I can remove! however I still want it before sending to backend. and we use this bad boy elsewhere when we actually render rich text

Copy link
Collaborator

@jjoyce0510 jjoyce0510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chriscollins3456 chriscollins3456 merged commit 37ac31c into datahub-project:master Oct 28, 2022
cccs-tom pushed a commit to CybercentreCanada/datahub that referenced this pull request Nov 18, 2022
cccs-tom pushed a commit to CybercentreCanada/datahub that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants