-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[SECURITY_SOLUTION][ENDPOINT] Create Trusted Apps UI Flow #77076
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
Changes from all commits
51f96f7
db38e71
83d7a95
036b315
a0e4cb6
383c94f
dc838d0
a14a256
3c425c3
c3055fc
e545eec
5265092
f1ec25d
b6ad9a1
a0db8ad
03d2a36
b04d51e
f054c66
f566037
583d933
1525426
3802b03
121970e
85b97e7
367bf94
db518a9
f291aad
dae9d71
3d9b128
406b474
1d3856e
d1bc53e
ea70142
9d5982d
7e59185
9cec20a
8a7e235
0daa736
0bd7ac1
2244329
1546f90
abe027e
c5dd93e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { | ||
| TrustedAppCreatePending, | ||
| TrustedAppsListPageState, | ||
| TrustedAppCreateFailure, | ||
| TrustedAppCreateSuccess, | ||
| } from './trusted_apps_list_page_state'; | ||
| import { | ||
| Immutable, | ||
| NewTrustedApp, | ||
| WindowsConditionEntry, | ||
| } from '../../../../../common/endpoint/types'; | ||
| import { TRUSTED_APPS_SUPPORTED_OS_TYPES } from '../../../../../common/endpoint/constants'; | ||
|
|
||
| type CreateViewPossibleStates = | ||
| | TrustedAppsListPageState['createView'] | ||
| | Immutable<TrustedAppsListPageState['createView']>; | ||
|
|
||
| export const isTrustedAppCreatePendingState = ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this related to what bohdan was talking about before about having selectors return types?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes :) Type guards are a runtime (executable code) function whose purpose is to ensure we are working with the correct type. In TS, it helps tell it that if this function evaluates to |
||
| data: CreateViewPossibleStates | ||
| ): data is TrustedAppCreatePending => { | ||
| return data?.type === 'pending'; | ||
| }; | ||
|
|
||
| export const isTrustedAppCreateSuccessState = ( | ||
| data: CreateViewPossibleStates | ||
| ): data is TrustedAppCreateSuccess => { | ||
| return data?.type === 'success'; | ||
| }; | ||
|
|
||
| export const isTrustedAppCreateFailureState = ( | ||
| data: CreateViewPossibleStates | ||
| ): data is TrustedAppCreateFailure => { | ||
| return data?.type === 'failure'; | ||
| }; | ||
|
|
||
| export const isWindowsTrustedApp = <T extends NewTrustedApp = NewTrustedApp>( | ||
| trustedApp: T | ||
| ): trustedApp is T & { os: 'windows' } => { | ||
| return trustedApp.os === 'windows'; | ||
| }; | ||
|
|
||
| export const isWindowsTrustedAppCondition = (condition: { | ||
| field: string; | ||
| }): condition is WindowsConditionEntry => { | ||
| return condition.field === 'process.code_signature' || true; | ||
| }; | ||
|
|
||
| export const isTrustedAppSupportedOs = (os: string): os is NewTrustedApp['os'] => | ||
| TRUSTED_APPS_SUPPORTED_OS_TYPES.includes(os); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way to group these states similar to the List resource. I know it's not entirely the same since we're creating a resource as opposed to loading it.