-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[RAM] Autocomplete #158454
Merged
XavierM
merged 90 commits into
elastic:main
from
guskovaue:RAM-158244-autocomplete-component-for-action-msg
Aug 31, 2023
Merged
[RAM] Autocomplete #158454
Changes from 85 commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
2fb53d4
v1 automomplete
guskovaue 33a479d
fix offset above message field
guskovaue 7e67df9
v2 automomplete
guskovaue 56d9391
rearrange functions in component
guskovaue 3bb8aae
first version of autocomplete
guskovaue daceebe
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue c22a5a8
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine b991478
temp
guskovaue d664d3e
fix algorithm for a case with a word in a middle
guskovaue 9511db3
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue a99d3a8
position of the auto-complete box
XavierM b7c26b5
use portal to simplify everything
XavierM 49bcab6
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 57d2913
add keyboard functionality
XavierM 0e8318b
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
XavierM d019e42
show in the list full version of suggestions
guskovaue 71b0ea1
make more beautiful
guskovaue d09da6a
highlight in the list written part
guskovaue df8af82
fix double words
guskovaue a82852c
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine fa4bfb7
fix outside click on autocomplete box
XavierM fb83c7a
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
XavierM cad56d1
calculate list height with matches
XavierM 12be197
hide list when you click in the text area
guskovaue 2873fd1
rewrite algorithm of filtering suggestions to include all possible op…
guskovaue b0f06f6
extract the function to lib file and write unit tests for it
guskovaue d75410f
stay focus on text area after picking a value
guskovaue 7be48e6
add a little bit unit tests
guskovaue 74f3317
wrap all handlers in useCallback
guskovaue 08daed9
add experimental flag
guskovaue 89ff260
return back add variable button
guskovaue 612fa4f
fix focus test
guskovaue 24096fe
fix the bug with editAction which move cursor to the end of testarea
guskovaue 38326a6
delete deprecated variables
guskovaue 1f1eaf5
fix warning disappeared bug
guskovaue c0ca732
fix unit test for email params tests
guskovaue c6d4542
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue 65d57ef
update limits for stackConnectors plugin
guskovaue 3e4b5cc
share new component in right way
guskovaue ce08155
use coloring instruments from eui
guskovaue 5524e1c
Revert "update limits for stackConnectors plugin"
guskovaue f0906d4
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue abec1df
beautifier
guskovaue 9dc1d82
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue c709927
add kibana react plugin
guskovaue be52216
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
kibanamachine 29f1618
do not directly export new component from taui
guskovaue 7f061f5
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue 0498441
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue 7fec97b
raise limit for slack connector plugin
guskovaue 21d9761
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue 82db434
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue 1267fa9
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
kibanamachine d229536
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 8d86b43
move autocomplete component from trigger-ui to alerts-ui-shared
guskovaue 49af14e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine c961071
move add message variables to alerts ui shares package
guskovaue f434159
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue af52b1b
delete not used file and fix translations
guskovaue 360be15
delete comments
guskovaue 5d3215e
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue d734a6f
delete not used imports
guskovaue 11d32eb
fix translations
guskovaue 116e372
delete not used imports
guskovaue 3667c51
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue fcbc1f9
get back old tar vertion
guskovaue 5ed84e4
delete trailing comma in json file
guskovaue bbae0fd
rewrite condition for text area in more elegant way
guskovaue 0702c3a
fix hook dependency and initial state
guskovaue af0e868
fix bug that menu goes up outside textarea
guskovaue 90b181d
Merge branch 'main' of github.com:elastic/kibana into pr/158454
XavierM 77b1606
cleanup
XavierM da83353
wrap style in useMemo
guskovaue d1bc817
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 58859e7
fix stack_connectors config
guskovaue ca19d59
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue 9265b39
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
XavierM 9c73fd5
fix warning
guskovaue 48f04b0
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue d39a461
put functions out of inline
guskovaue 130bd66
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 6e762f6
fix experimental flag
guskovaue 838f331
Merge branch 'RAM-158244-autocomplete-component-for-action-msg' of gi…
guskovaue 7de1556
fix exposes plugin config test
guskovaue aecb69a
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
guskovaue 4e57549
fix feature flag to be off at first + cleanup bug around scrolling
XavierM 31484a4
Merge branch 'main' of github.com:elastic/kibana into RAM-158244-auto…
XavierM c50a06b
fix path
XavierM 9550199
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
XavierM 3399f66
Merge branch 'main' into RAM-158244-autocomplete-component-for-action…
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import '@testing-library/jest-dom'; |
File renamed without changes.
7 changes: 4 additions & 3 deletions
7
...components/add_message_variables.test.tsx → .../src/add_message_variables/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23
...ic/application/components/translations.js → ...src/add_message_variables/translations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/kbn-alerts-ui-shared/src/add_message_variables/truncated_text.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { EuiText } from '@elastic/eui'; | ||
|
||
const LINE_CLAMP = 2; | ||
|
||
const styles = { | ||
truncatedText: css` | ||
text-overflow: ellipsis; | ||
display: -webkit-box; | ||
-webkit-line-clamp: ${LINE_CLAMP}; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
word-break: break-word; | ||
`, | ||
}; | ||
|
||
const TruncatedTextComponent: React.FC<{ text: string }> = ({ text }) => ( | ||
<EuiText size="xs" color="subdued" css={styles.truncatedText}> | ||
{text} | ||
</EuiText> | ||
); | ||
|
||
TruncatedTextComponent.displayName = 'TruncatedText'; | ||
|
||
export const TruncatedText = React.memo(TruncatedTextComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
x-pack/plugins/stack_connectors/common/experimental_features.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export type ExperimentalFeatures = typeof allowedExperimentalValues; | ||
|
||
/** | ||
* A list of allowed values that can be used in `xpack.stack_connectors.enableExperimental`. | ||
* This object is then used to validate and parse the value entered. | ||
*/ | ||
export const allowedExperimentalValues = Object.freeze({ | ||
isMustacheAutocompleteOff: false, | ||
}); | ||
|
||
type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>; | ||
type Mutable<T> = { -readonly [P in keyof T]: T[P] }; | ||
|
||
const InvalidExperimentalValue = class extends Error {}; | ||
const allowedKeys = Object.keys(allowedExperimentalValues) as Readonly<ExperimentalConfigKeys>; | ||
|
||
/** | ||
* Parses the string value used in `xpack.stack_connectors.enableExperimental` kibana configuration, | ||
* which should be a string of values delimited by a comma (`,`) | ||
* | ||
* @param configValue | ||
* @throws InvalidExperimentalValue | ||
*/ | ||
export const parseExperimentalConfigValue = (configValue: string[]): ExperimentalFeatures => { | ||
const enabledFeatures: Mutable<Partial<ExperimentalFeatures>> = {}; | ||
|
||
for (const value of configValue) { | ||
if (!isValidExperimentalValue(value)) { | ||
throw new InvalidExperimentalValue(`[${value}] is not valid.`); | ||
} | ||
// @ts-expect-error ts upgrade v4.7.4 | ||
enabledFeatures[value as keyof ExperimentalFeatures] = true; | ||
} | ||
|
||
return { | ||
...allowedExperimentalValues, | ||
...enabledFeatures, | ||
}; | ||
}; | ||
|
||
export const isValidExperimentalValue = (value: string): boolean => { | ||
return allowedKeys.includes(value as keyof ExperimentalFeatures); | ||
}; | ||
|
||
export const getExperimentalAllowedValues = (): string[] => [...allowedKeys]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface StackConnectorsConfigType { | ||
enableExperimental: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/stack_connectors/public/common/experimental_features_service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ExperimentalFeatures } from '../../common/experimental_features'; | ||
|
||
export class ExperimentalFeaturesService { | ||
private static experimentalFeatures?: ExperimentalFeatures; | ||
|
||
public static init({ experimentalFeatures }: { experimentalFeatures: ExperimentalFeatures }) { | ||
this.experimentalFeatures = experimentalFeatures; | ||
} | ||
|
||
public static get(): ExperimentalFeatures { | ||
if (!this.experimentalFeatures) { | ||
this.throwUninitializedError(); | ||
} | ||
|
||
return this.experimentalFeatures; | ||
} | ||
|
||
private static throwUninitializedError(): never { | ||
throw new Error( | ||
'Experimental features services not initialized - are you trying to import this module from outside of the stack connectors?' | ||
); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/stack_connectors/public/common/get_experimental_features.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
ExperimentalFeatures, | ||
isValidExperimentalValue, | ||
getExperimentalAllowedValues, | ||
} from '../../common/experimental_features'; | ||
import { ExperimentalFeaturesService } from './experimental_features_service'; | ||
|
||
const allowedExperimentalValueKeys = getExperimentalAllowedValues(); | ||
|
||
export const getIsExperimentalFeatureEnabled = (feature: keyof ExperimentalFeatures): boolean => { | ||
if (!isValidExperimentalValue(feature)) { | ||
throw new Error( | ||
`Invalid enable value ${feature}. Allowed values are: ${allowedExperimentalValueKeys.join( | ||
', ' | ||
)}` | ||
); | ||
} | ||
|
||
return ExperimentalFeaturesService.get()[feature]; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need this plugin?
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.
Tried to recall why I added it without success. Seems I do not need it. Removed.
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.
ERROR in ./public/connector_types/email/email_params.tsx
| │ Module not found: Error: import [@kbn/kibana-react-plugin/public] references a public export of the [kibanaReact] bundle, but that bundle is not in the "requiredPlugins" or "requiredBundles" list in the plugin manifest [/dev/shm/builds/kb-n2-16-spot-46e986621280fcc4/elastic/kibana-pull-request/kibana/x-pack/plugins/stack_connectors/kibana.jsonc]
| │ @ ./public/connector_types/email/email_params.tsx 13:0-60 35:6-15
| │ @ ./public/connector_types/email/email.tsx
| │ @ ./public/connector_types/email/index.ts
| │ @ ./public/connector_types/index.ts
| │ @ ./public/plugin.ts
| │ @ ./public/index.ts
Added back.