Skip to content

Commit

Permalink
[SIEM] [Cases] Fix comments and user (#61642) (#61669)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Mar 28, 2020
1 parent 51b9f96 commit 2d02d23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export const UserActionTree = React.memo(
);

const handleSaveComment = useCallback(
(id: string, content: string) => {
({ id, version }: { id: string; version: string }, content: string) => {
handleManageMarkdownEditId(id);
patchComment({
caseId: caseData.id,
commentId: id,
commentUpdate: content,
fetchUserActions,
version: caseData.version,
version,
updateCase,
});
},
Expand Down Expand Up @@ -178,7 +178,7 @@ export const UserActionTree = React.memo(
markdown={MarkdownDescription}
onEdit={handleManageMarkdownEditId.bind(null, DESCRIPTION_ID)}
onQuote={handleManageQuote.bind(null, caseData.description)}
userName={caseData.createdBy.username}
username={caseData.createdBy.username}
/>

{caseUserActions.map((action, index) => {
Expand All @@ -203,13 +203,16 @@ export const UserActionTree = React.memo(
content={comment.comment}
isEditable={manageMarkdownEditIds.includes(comment.id)}
onChangeEditable={handleManageMarkdownEditId}
onSaveContent={handleSaveComment.bind(null, comment.id)}
onSaveContent={handleSaveComment.bind(null, {
id: comment.id,
version: comment.version,
})}
/>
}
onEdit={handleManageMarkdownEditId.bind(null, comment.id)}
onQuote={handleManageQuote.bind(null, comment.comment)}
outlineComment={handleOutlineComment}
userName={comment.createdBy.username}
username={comment.createdBy.username}
updatedAt={comment.updatedAt}
/>
);
Expand Down Expand Up @@ -245,7 +248,7 @@ export const UserActionTree = React.memo(
index === lastIndexPushToService &&
index < caseUserActions.length - 1
}
userName={action.actionBy.username}
username={action.actionBy.username}
/>
);
}
Expand All @@ -265,7 +268,7 @@ export const UserActionTree = React.memo(
isLoading={isLoadingIds.includes(NEW_ID)}
fullName={currentUser != null ? currentUser.fullName : ''}
markdown={MarkdownNewComment}
userName={currentUser != null ? currentUser.username : ''}
username={currentUser != null ? currentUser.username : ''}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ interface UserActionItemProps {
labelQuoteAction?: string;
labelTitle?: JSX.Element;
linkId?: string | null;
fullName: string;
fullName?: string | null;
markdown?: React.ReactNode;
onEdit?: (id: string) => void;
onQuote?: (id: string) => void;
userName: string;
username: string;
updatedAt?: string | null;
outlineComment?: (id: string) => void;
showBottomFooter?: boolean;
Expand Down Expand Up @@ -125,15 +125,15 @@ export const UserActionItem = ({
outlineComment,
showBottomFooter,
showTopFooter,
userName,
username,
updatedAt,
}: UserActionItemProps) => (
<UserActionItemContainer gutterSize={'none'} direction="column">
<EuiFlexItem>
<EuiFlexGroup gutterSize={'none'}>
<EuiFlexItem data-test-subj={`user-action-${id}-avatar`} grow={false}>
{fullName.length > 0 || userName.length > 0 ? (
<UserActionAvatar name={fullName ?? userName} />
{(fullName && fullName.length > 0) || username.length > 0 ? (
<UserActionAvatar name={fullName ?? username} />
) : (
<EuiLoadingSpinner className="userAction_loadingAvatar" />
)}
Expand All @@ -154,7 +154,7 @@ export const UserActionItem = ({
labelQuoteAction={labelQuoteAction}
labelTitle={labelTitle ?? <></>}
linkId={linkId}
userName={userName}
username={username}
updatedAt={updatedAt}
onEdit={onEdit}
onQuote={onQuote}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface UserActionTitleProps {
labelTitle: JSX.Element;
linkId?: string | null;
updatedAt?: string | null;
userName: string;
username: string;
onEdit?: (id: string) => void;
onQuote?: (id: string) => void;
outlineComment?: (id: string) => void;
Expand All @@ -48,7 +48,7 @@ export const UserActionTitle = ({
labelQuoteAction,
labelTitle,
linkId,
userName,
username,
updatedAt,
onEdit,
onQuote,
Expand Down Expand Up @@ -105,7 +105,7 @@ export const UserActionTitle = ({
<EuiFlexItem grow={false}>
<EuiFlexGroup alignItems="baseline" gutterSize="xs" component="span">
<EuiFlexItem grow={false}>
<strong>{userName}</strong>
<strong>{username}</strong>
</EuiFlexItem>
<EuiFlexItem grow={false}>{labelTitle}</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down

0 comments on commit 2d02d23

Please sign in to comment.