Skip to content

Commit

Permalink
Merge pull request elastic#12 from Elastic-AWP-Platform/add-loading-a…
Browse files Browse the repository at this point in the history
…nd-error-to-session-view

Add loading and error state to session view fetching through react query
  • Loading branch information
Jack authored Nov 22, 2021
2 parents 01677ae + 16ac6ad commit d43957d
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 198 deletions.
264 changes: 134 additions & 130 deletions x-pack/plugins/session_view/common/test/mock_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,19 @@
* 2.0.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { EventAction, ProcessEvent } from '../../public/hooks/use_process_tree';
import uuid from 'uuid';
import { EventAction, ProcessEvent } from '../../public/hooks/use_process_tree';

export const getStart = () => {
return [{
'@timestamp': 'Thu Oct 14 2021 12: 06: 48 GMT-0700 (Pacific Daylight Time)',
event: {
kind: 'event',
category: 'process',
action: EventAction.exec,
},
process: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,

user: {
id: '2',
name: 'kg',
},

parent: {
args: ['/bin/sshd'],
args_count: 1,
command_line: 'sshd',
entity_id: '4322',
executable: '/bin/sshd',
name: 'sshd',
interactive: true,
working_directory: '/',
pid: 2,
pgid: 2,
user: {
id: '0',
name: 'root',
},
return [
{
'@timestamp': 'Thu Oct 14 2021 12: 06: 48 GMT-0700 (Pacific Daylight Time)',
event: {
kind: 'event',
category: 'process',
action: EventAction.exec,
},
session: {
process: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
Expand All @@ -60,124 +28,160 @@ export const getStart = () => {
working_directory: '/home/kg',
pid: 3,
pgid: 2,

user: {
id: '2',
name: 'kg',
},
},
entry: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',

parent: {
args: ['/bin/sshd'],
args_count: 1,
command_line: 'sshd',
entity_id: '4322',
executable: '/bin/sshd',
name: 'sshd',
interactive: true,
working_directory: '/',
pid: 2,
pgid: 2,
user: {
id: '0',
name: 'root',
},
},
session: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
},
},
entry: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
},
},
},
},
}];
];
};

export const getEvent = () => {
const random = [
{
args: ['ls', '-l'],
command_line: 'ls -l',
name: 'ls'
name: 'ls',
},
{
args: ['pwd'],
command_line: 'pwd',
name: 'pwd'
name: 'pwd',
},
{
args: ['dir'],
command_line: 'dir',
name: 'dir'
}
]
name: 'dir',
},
];

const randomElement = random[Math.floor(Math.random() * random.length)];

return [{
'@timestamp': 'Thu Oct 14 2021 12: 06: 52 GMT-0700 (Pacific Daylight Time)',
event: {
kind: 'event',
category: 'process',
action: EventAction.exec,
},
process: {
args: randomElement.args,
args_count: 2,
command_line: randomElement.command_line,
entity_id: uuid.v4().toString(),
executable: '/bin/ls',
name: randomElement.name,
interactive: true,
working_directory: '/home/kg',
pid: 4,
pgid: 3,
user: {
id: '2',
name: 'kg',
return [
{
'@timestamp': 'Thu Oct 14 2021 12: 06: 52 GMT-0700 (Pacific Daylight Time)',
event: {
kind: 'event',
category: 'process',
action: EventAction.exec,
},
parent: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
process: {
args: randomElement.args,
args_count: 2,
command_line: randomElement.command_line,
entity_id: uuid.v4().toString(),
executable: '/bin/ls',
name: randomElement.name,
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
pid: 4,
pgid: 3,
user: {
id: '2',
name: 'kg',
},
},
session: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
parent: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
},
},
},
entry: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
session: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
},
},
entry: {
args: ['bash'],
args_count: 1,
command_line: 'bash',
entity_id: '4321',
executable: '/bin/bash',
name: 'bash',
interactive: true,
working_directory: '/home/kg',
pid: 3,
pgid: 2,
user: {
id: '2',
name: 'kg',
},
},
},
},
}];
];
};

export const getEnd = () => {
Expand Down Expand Up @@ -272,12 +276,12 @@ export const getEnd = () => {
working_directory: '/home/kg',
pid: 6,
pgid: 4,

user: {
id: '2',
name: 'kg',
},

parent: {
args: ['df'],
args_count: 1,
Expand Down Expand Up @@ -346,12 +350,12 @@ export const getEnd = () => {
working_directory: '/home/kg',
pid: 6,
pgid: 4,

user: {
id: '2',
name: 'kg',
},

parent: {
args: ['df'],
args_count: 1,
Expand Down Expand Up @@ -422,12 +426,12 @@ export const getEnd = () => {
pgid: 4,
end: 'Thu Oct 14 2021 12: 08: 56 GMT-0700 (Pacific Daylight Time)',
exit_code: 137,

user: {
id: '2',
name: 'kg',
},

parent: {
args: ['df'],
args_count: 1,
Expand Down Expand Up @@ -479,7 +483,7 @@ export const getEnd = () => {
},
},
];
}
};

export const mockData: ProcessEvent[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/session_view/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"githubTeam": "security-team"
},
"requiredPlugins": ["data"],
"requiredBundles": ["kibanaReact"],
"requiredBundles": ["kibanaReact", "esUiShared"],
"server": true,
"ui": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export const ProcessTree = ({
onProcessSelected={onProcessSelected}
/>
);
})
});
}
}
};

return (
<div ref={scrollerRef} css={styles.scroller}>
Expand Down
Loading

0 comments on commit d43957d

Please sign in to comment.