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
port advanced watcher to react #34188
Changes from all commits
ac28faa
f632ecf
be37bc2
ee129d7
cf53835
6e30c19
ff1cfd5
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,30 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const WATCH_TAB_ID_EDIT = 'watchEditTab'; | ||
export const WATCH_TAB_ID_SIMULATE = 'watchSimulateTab'; | ||
|
||
interface WatchTab { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export const WATCH_TABS: WatchTab[] = [ | ||
{ | ||
id: WATCH_TAB_ID_EDIT, | ||
name: i18n.translate('xpack.watcher.sections.watchEdit.json.editTabLabel', { | ||
defaultMessage: 'Edit', | ||
}), | ||
}, | ||
{ | ||
id: WATCH_TAB_ID_SIMULATE, | ||
name: i18n.translate('xpack.watcher.sections.watchEdit.json.simulateTabLabel', { | ||
defaultMessage: 'Simulate', | ||
}), | ||
}, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface ExecutedWatchResults { | ||
id: string; | ||
watchId: string; | ||
details: any; | ||
startTime: Date; | ||
watchStatus: { | ||
state: string; | ||
actionStatuses: Array<{ state: string; lastExecutionReason: string }>; | ||
}; | ||
} | ||
|
||
export interface ExecutedWatchDetails { | ||
triggerData: { | ||
triggeredTime: Date; | ||
scheduledTime: Date; | ||
}; | ||
ignoreCondition: boolean; | ||
alternativeInput: any; | ||
actionModes: { | ||
[key: string]: string; | ||
}; | ||
recordExecution: boolean; | ||
upstreamJson: any; | ||
} | ||
|
||
export interface BaseWatch { | ||
id: string; | ||
type: string; | ||
isNew: boolean; | ||
name: string; | ||
isSystemWatch: boolean; | ||
watchStatus: any; | ||
watchErrors: any; | ||
typeName: string; | ||
displayName: string; | ||
upstreamJson: any; | ||
resetActions: () => void; | ||
createAction: (type: string, actionProps: {}) => void; | ||
validate: () => { warning: { message: string } }; | ||
actions: [ | ||
{ | ||
id: string; | ||
type: string; | ||
} | ||
]; | ||
watch: { | ||
actions: { | ||
[key: string]: { [key: string]: any }; | ||
}; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
|
||
export const ConfirmWatchesModal = ({ | ||
modalOptions, | ||
callback, | ||
}: { | ||
modalOptions: { message: string } | null; | ||
callback: (isConfirmed?: boolean) => void; | ||
}) => { | ||
if (!modalOptions) { | ||
return null; | ||
} | ||
return ( | ||
<EuiOverlayMask> | ||
<EuiConfirmModal | ||
buttonColor="danger" | ||
title={i18n.translate('xpack.watcher.sections.watchEdit.json.saveConfirmModal.title', { | ||
defaultMessage: 'Confirm save', | ||
})} | ||
onCancel={() => callback()} | ||
onConfirm={() => { | ||
callback(true); | ||
}} | ||
cancelButtonText={i18n.translate( | ||
'xpack.watcher.sections.watchEdit.json.saveConfirmModal.cancelButtonLabel', | ||
{ defaultMessage: 'Cancel' } | ||
)} | ||
confirmButtonText={i18n.translate( | ||
'xpack.watcher.sections.watchEdit.json.saveConfirmModal.saveButtonLabel', | ||
{ defaultMessage: 'Save' } | ||
)} | ||
> | ||
{modalOptions.message} | ||
</EuiConfirmModal> | ||
</EuiOverlayMask> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,20 @@ declare module 'plugins/watcher/models/watch' { | |
declare module 'plugins/watcher/models/watch/threshold_watch' { | ||
export const ThresholdWatch: any; | ||
} | ||
declare module 'plugins/watcher/models/watch/json_watch' { | ||
export const JsonWatch: any; | ||
} | ||
|
||
declare module 'plugins/watcher/models/execute_details/execute_details' { | ||
export const ExecuteDetails: any; | ||
} | ||
|
||
declare module 'plugins/watcher/models/watch_history_item' { | ||
export const WatchHistoryItem: any; | ||
} | ||
|
||
// TODO: Remove once typescript definitions are in EUI | ||
declare module '@elastic/eui' { | ||
export const EuiCodeEditor: React.SFC<any>; | ||
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. wondering why these are needed. I didn't need to add any eui types for my stuff (maybe I'm missing something) 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. I think it's only for certain eui components. see: https://github.com/elastic/kibana/blob/master/TYPESCRIPT.md#how-to-fix-common-typescript-errors this may not be the correct place to put it. let me know what you think. |
||
export const EuiDescribedFormGroup: React.SFC<any>; | ||
} |
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.
we should probably just move all the models to TS, but we can do that in another PR.
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 can work on that next