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

[SIEM] [Case] Comments to case view #58315

Merged
merged 66 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
0984382
init commit, enable case by default and snake to camel on the FE
stephmilovic Feb 18, 2020
36a8cbc
fix sorting
stephmilovic Feb 18, 2020
a2576ea
add a couple tests
stephmilovic Feb 18, 2020
3414641
mock timezone
stephmilovic Feb 19, 2020
7d2818a
full_name to fullName and tests for case view
stephmilovic Feb 19, 2020
9de2163
update case
stephmilovic Feb 19, 2020
9bf863a
trying to fix time test
stephmilovic Feb 19, 2020
87933b5
attempt to fix test once more
stephmilovic Feb 19, 2020
4247111
comment out bad test
stephmilovic Feb 20, 2020
6764017
comment out bad test
stephmilovic Feb 20, 2020
4d5b84d
remove snapshot tests
stephmilovic Feb 20, 2020
b938feb
fix
stephmilovic Feb 20, 2020
fb158d1
rm thing
stephmilovic Feb 20, 2020
a51c776
simplify
stephmilovic Feb 20, 2020
1147b7d
Merge branch 'master' into case-cleanups
elasticmachine Feb 20, 2020
932a210
comments to case view
stephmilovic Feb 20, 2020
c589dce
fix up
stephmilovic Feb 21, 2020
473322d
Merge branch 'master' into case-cleanups
stephmilovic Feb 21, 2020
3da9bda
Merge branch 'master' into comments-to-case-view
stephmilovic Feb 21, 2020
5f6fed5
add comment work
stephmilovic Feb 21, 2020
e28d322
remove window.alert
stephmilovic Feb 21, 2020
0d68fde
suggested changes
stephmilovic Feb 21, 2020
388d77d
more fixes
stephmilovic Feb 21, 2020
fb92e30
better types
stephmilovic Feb 21, 2020
9df35a6
something fishy
stephmilovic Feb 21, 2020
b76038e
couple quick cleanups, lodash arg order incorrect on set
stephmilovic Feb 21, 2020
c2f680a
get changes from case-cleanups
stephmilovic Feb 21, 2020
bba7d6d
merge master, convertArrayToCamelCase
stephmilovic Feb 21, 2020
d672967
fix merge conflict
stephmilovic Feb 22, 2020
80961e0
md editor looking better and posting
stephmilovic Feb 22, 2020
f6cc595
verbiage change
stephmilovic Feb 23, 2020
d56b80f
more work in user action tree
stephmilovic Feb 23, 2020
f1b005d
placeholder for Add comment field
stephmilovic Feb 24, 2020
7df41ea
Merge branch 'master' into comments-to-case-view
stephmilovic Feb 24, 2020
39259b7
clean up user action tree
stephmilovic Feb 24, 2020
855ada6
good progress on comments, need to indicate loading for updating of f…
stephmilovic Feb 24, 2020
b1ae625
loading for each field, create page updates
stephmilovic Feb 25, 2020
85f2f93
loading for each field, create page updates
stephmilovic Feb 25, 2020
1bc1665
update styling of buttons on tags
stephmilovic Feb 25, 2020
cdf3c44
fix up title buttons
stephmilovic Feb 25, 2020
0eab8ca
cleanup mock data
stephmilovic Feb 25, 2020
927d485
Merge branch 'master' into comments-to-case-view
stephmilovic Feb 26, 2020
ea40f9e
test fixups
stephmilovic Feb 26, 2020
fbc4172
more test fix
stephmilovic Feb 26, 2020
119c9db
fix bug that prevented tags from being cleared
stephmilovic Feb 26, 2020
d6161c8
move markdown_editor to top level components
stephmilovic Feb 26, 2020
5981d2c
update translations
stephmilovic Feb 26, 2020
3afeb64
Merge branch 'master' into comments-to-case-view
stephmilovic Feb 27, 2020
ff43776
pr changes
stephmilovic Feb 27, 2020
74553a4
fix loading timing and clean ups
stephmilovic Feb 27, 2020
d49cf1c
link to const
stephmilovic Feb 27, 2020
bb82ba5
fix type err
stephmilovic Feb 27, 2020
313f490
fix md
stephmilovic Feb 27, 2020
312d34b
more pr changes
stephmilovic Feb 27, 2020
6713216
fix validation for markdown by using UseField
XavierM Feb 27, 2020
71e13d4
Merge branch 'comments-to-case-view' of github.com:stephmilovic/kiban…
XavierM Feb 27, 2020
cf73141
cleanup loading state issues
stephmilovic Feb 27, 2020
f68808e
resolve merge conflicts
stephmilovic Feb 28, 2020
e287002
refactor UserAction
XavierM Feb 28, 2020
4c7edfa
Merge branch 'master' of github.com:elastic/kibana into comments-to-c…
XavierM Feb 28, 2020
b0635b3
fix type + test
XavierM Feb 28, 2020
7de953a
Merge branch 'master' into comments-to-case-view
stephmilovic Feb 28, 2020
82c023f
rn file that shouldve been deleted
stephmilovic Feb 28, 2020
9703c98
fix merge conflicts
stephmilovic Mar 2, 2020
f0d4bec
Merge branch 'master' into comments-to-case-view
elasticmachine Mar 2, 2020
326191f
Merge branch 'master' into comments-to-case-view
elasticmachine Mar 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { useReducer } from 'react';
import { useReducer, useRef } from 'react';
import { useStateToaster } from '../../components/toasters';
import { errorToToaster } from '../../components/ml/api/error_to_toaster';
import * as i18n from './translations';
Expand All @@ -15,9 +15,8 @@ import { getTypedPayload } from './utils';

interface CommetUpdateState {
data: Comment[];
isLoading: boolean;
isLoadingIds: string[];
isError: boolean;
isLoadingCommentId: string | null;
}

interface CommentUpdate {
Expand All @@ -35,9 +34,8 @@ const dataFetchReducer = (state: CommetUpdateState, action: Action): CommetUpdat
case FETCH_INIT:
return {
...state,
isLoading: true,
isLoadingIds: [...state.isLoadingIds, getTypedPayload<string>(action.payload)],
isError: false,
isLoadingCommentId: getTypedPayload<string>(action.payload),
};

case FETCH_SUCCESS:
Expand All @@ -48,16 +46,16 @@ const dataFetchReducer = (state: CommetUpdateState, action: Action): CommetUpdat
state.data[foundIndex] = { ...state.data[foundIndex], ...updatePayload.update };
return {
...state,
isLoading: false,
isLoadingCommentId: null,
isLoadingIds: state.isLoadingIds.filter(id => updatePayload.commentId !== id),
isError: false,
data: [...state.data],
};
case FETCH_FAILURE:
return {
...state,
isLoading: false,
isLoadingCommentId: null,
isLoadingIds: state.isLoadingIds.filter(
id => getTypedPayload<string>(action.payload) !== id
),
isError: true,
};
default:
Expand All @@ -69,14 +67,14 @@ export const useUpdateComment = (
comments: Comment[]
): [CommetUpdateState, (commentId: string, commentUpdate: string) => void] => {
const [state, dispatch] = useReducer(dataFetchReducer, {
isLoading: false,
isLoadingCommentId: null,
isLoadingIds: [],
isError: false,
data: comments,
});
const dispatchUpdateComment = useRef<(commentId: string, commentUpdate: string) => void>();
const [, dispatchToaster] = useStateToaster();

const dispatchUpdateComment = async (commentId: string, commentUpdate: string) => {
dispatchUpdateComment.current = async (commentId: string, commentUpdate: string) => {
dispatch({ type: FETCH_INIT, payload: commentId });
try {
const currentComment = state.data.find(comment => comment.commentId === commentId) ?? {
Expand All @@ -86,9 +84,9 @@ export const useUpdateComment = (
dispatch({ type: FETCH_SUCCESS, payload: { update: response, commentId } });
} catch (error) {
errorToToaster({ title: i18n.ERROR_TITLE, error, dispatchToaster });
dispatch({ type: FETCH_FAILURE });
dispatch({ type: FETCH_FAILURE, payload: commentId });
}
};

return [state, dispatchUpdateComment];
return [state, dispatchUpdateComment.current];
};
Loading