Skip to content

Commit

Permalink
feat(ui): Support markdown for incident descriptions (datahub-project…
Browse files Browse the repository at this point in the history
…#11759)

Co-authored-by: John Joyce <john@ip-192-168-1-200.us-west-2.compute.internal>
  • Loading branch information
jjoyce0510 and John Joyce authored Oct 30, 2024
1 parent cf3b08f commit 5c0377a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import React, { useState } from 'react';
import { message, Modal, Button, Form, Input, Typography, Select } from 'antd';
import { useApolloClient } from '@apollo/client';
import TextArea from 'antd/lib/input/TextArea';
import styled from 'styled-components';
import analytics, { EventType, EntityActionType } from '../../../../../analytics';
import { useEntityData } from '../../../EntityContext';
import { EntityType, IncidentSourceType, IncidentState, IncidentType } from '../../../../../../types.generated';
import { INCIDENT_DISPLAY_TYPES, PAGE_SIZE, addActiveIncidentToCache } from '../incidentUtils';
import { useRaiseIncidentMutation } from '../../../../../../graphql/mutations.generated';
import handleGraphQLError from '../../../../../shared/handleGraphQLError';
import { useUserContext } from '../../../../../context/useUserContext';
import { Editor } from '../../Documentation/components/editor/Editor';
import { ANTD_GRAY } from '../../../constants';

const StyledEditor = styled(Editor)`
border: 1px solid ${ANTD_GRAY[4.5]};
`;

type AddIncidentProps = {
open: boolean;
Expand Down Expand Up @@ -112,6 +118,7 @@ export const AddIncidentModal = ({ open, onClose, refetch }: AddIncidentProps) =
open={open}
destroyOnClose
onCancel={handleClose}
width={600}
footer={[
<Button type="text" onClick={handleClose}>
Cancel
Expand Down Expand Up @@ -174,7 +181,17 @@ export const AddIncidentModal = ({ open, onClose, refetch }: AddIncidentProps) =
},
]}
>
<TextArea placeholder="Provide some additional details" />
<StyledEditor
doNotFocus
className="add-incident-description"
onKeyDown={(e) => {
// Preventing the modal from closing when the Enter key is pressed
if (e.key === 'Enter') {
e.preventDefault();
e.stopPropagation();
}
}}
/>
</Form.Item>
</Form>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useUpdateIncidentStatusMutation } from '../../../../../../graphql/mutat
import { ResolveIncidentModal } from './ResolveIncidentModal';
import handleGraphQLError from '../../../../../shared/handleGraphQLError';
import { MenuItemStyle } from '../../../../view/menu/item/styledComponent';
import MarkdownViewer from '../../../components/legacy/MarkdownViewer';

type Props = {
incident: any;
Expand Down Expand Up @@ -227,7 +228,7 @@ export default function IncidentListItem({ incident, refetch }: Props) {
</TitleContainer>
<DescriptionContainer>
<IncidentDescriptionLabel>Description</IncidentDescriptionLabel>
<IncidentDescriptionText>{incident?.description}</IncidentDescriptionText>
<MarkdownViewer source={incident?.description} />
{incident.status.state === IncidentState.Resolved ? (
<>
<IncidentDescriptionLabel>Resolution Note</IncidentDescriptionLabel>
Expand Down

0 comments on commit 5c0377a

Please sign in to comment.