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

[RAM] Autocomplete #158454

Merged

Conversation

guskovaue
Copy link
Contributor

@guskovaue guskovaue commented May 25, 2023

Summary

Solves this issue: #161763

This PR introduces autocomplete for mustache variables for email connector(next PR will add it to all connectors) under the feature flag.

We decided keep old solution with button with all searchable options as well.

How to test:
Create an email connector in kibana.yml:

xpack.actions.preconfigured:
maildev:
name: 'email: maildev'
actionTypeId: '.email'
config:
from: 'guskova@example.com'
host: 'localhost'
port: '1025'

How it should work:
You start writing in Message window {{ and mustache variable name. And you should see autocomplete popup with all possible options to choose. When you click somewhere else, popup should disappeared.

Screen.Recording.2023-07-12.at.16.45.51.mov

e options to choose. When you click somewhere else, popup should disappeared.

@guskovaue guskovaue self-assigned this Jun 14, 2023
guskovaue and others added 25 commits June 19, 2023 15:06
…thub.com:guskovaue/kibana into RAM-158244-autocomplete-component-for-action-msg
…thub.com:guskovaue/kibana into RAM-158244-autocomplete-component-for-action-msg
…thub.com:guskovaue/kibana into RAM-158244-autocomplete-component-for-action-msg
Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it locally, works as expected. I left a few comments regarding the experiment flag, as that is currently not working as expected. Once that is done then I think this is ready to merge.

}
}, [editAction, index, inputTargetValue, isListOpen, paramsProperty])}
onClick={useCallback(() => closeList(), [closeList])}
onScroll={useCallback(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to have the on scroll listen on the window, since I noticed if i scrolled the outer div, the list doesn't close

  useEffect(() => {
    window.addEventListener('scroll', closeList, { passive: true, capture: true });
    return () => {
      window.removeEventListener('scroll', closeList. { capture: true });
    };
  }, [closeList]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've try to fix it fast. Did not work, because when our main logic will be broken and autocomplete will work with bugs.
I've created separate task for that: #165204.
For this PR think that it's fine to keep it like this, because we have similar behaviour in different places in rule form.
Are you ok with that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were able to figure it out check the last commit

* 2.0.
*/

import { schema, TypeOf } from '@kbn/config-schema';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I tried this again and noticed 2 issues:

  1. We need to tell the stack_connectors server to expose the enabled experiments to the frontend. To do this, in x-pack/plugins/stack_connectors/server/index.ts, we need to add
export const config: PluginConfigDescriptor<ConfigSchema> = {
  exposeToBrowser: {
    enableExperimental: true,
  },
  schema: configSchema,
};

to the exported config

  1. So experiment flags are a toggle (either we set them or remove them). So this means isMustacheAutocompleteon should default to false (assuming we want autocomplete to be the default state, as we can only add the experiment flag to kibana.yml, not somehow take it away). This means that the experiment should actually be isMustacheAutocompleteOff, which defaults to false. Then if we want to turn off the new autocomplete we can add the experiment flag (which then turns it off).

So in line 15 of x-pack/plugins/stack_connectors/common/experimental_features.ts, this needs to default to false, you will notice a type error in line 39, which is expected, we have an issue to fix this so in the meantime add the // @ts-expect-error ts upgrade v4.7.4 to the line above it.

Then where ever you were using the flag to determine which component to render, you will need to swap the logic around.

@guskovaue
Copy link
Contributor Author

@JiaweiWu Are these fixes what you meant for feature flag? fix experimental flag

@guskovaue guskovaue requested a review from a team as a code owner August 30, 2023 13:28
Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in test/plugin_functional/test_suites/core_plugins/rendering.ts LGTM

@XavierM XavierM enabled auto-merge (squash) August 30, 2023 20:23
propertyPath: string;
}) => {
if (!actionVariablesList) return [];
const allSuggestions: string[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit use Set to avoid check includes

Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@XavierM XavierM added v8.11.0 Feature:Alerting/RulesManagement Issues related to the Rules Management UX and removed v8.10.0 labels Aug 31, 2023
@XavierM
Copy link
Contributor

XavierM commented Aug 31, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observability 425 433 +8
securitySolution 4490 4498 +8
stackConnectors 204 236 +32
total +48

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/alerts-ui-shared 7 9 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 1.0MB 1023.2KB -4.1KB
securitySolution 12.6MB 12.6MB +3.2KB
stackConnectors 450.2KB 468.0KB +17.8KB
triggersActionsUi 1.4MB 1.4MB -6.8KB
total +10.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
observability 99.4KB 99.5KB +22.0B
stackConnectors 35.2KB 36.5KB +1.3KB
triggersActionsUi 89.3KB 91.5KB +2.2KB
total +3.5KB
Unknown metric groups

API count

id before after diff
@kbn/alerts-ui-shared 8 10 +2

async chunk count

id before after diff
observability 11 12 +1

ESLint disabled line counts

id before after diff
@kbn/alerts-ui-shared 2 3 +1
stackConnectors 93 94 +1
total +2

Total ESLint disabled count

id before after diff
@kbn/alerts-ui-shared 2 3 +1
stackConnectors 98 99 +1
total +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @guskovaue

@XavierM XavierM merged commit 0af40a3 into elastic:main Aug 31, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 31, 2023
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Aug 31, 2023
## Summary

Solves this issue: elastic#161763

This PR introduces autocomplete for mustache variables for email
connector(next PR will add it to all connectors) under the feature flag.

We decided keep old solution with button with all searchable options as
well.

How to test:
Create an email connector in kibana.yml:

xpack.actions.preconfigured:
  maildev:
    name: 'email: maildev'
    actionTypeId: '.email'
    config:
      from: 'guskova@example.com'
      host: 'localhost'
      port: '1025'

How it should work:
You start writing in Message window {{ and mustache variable name. And
you should see autocomplete popup with all possible options to choose.
When you click somewhere else, popup should disappeared.


https://github.com/elastic/kibana/assets/26089545/061016a6-b8ca-497b-9bed-b8b012d31a95

e options to choose. When you click somewhere else, popup should
disappeared.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.11.0
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

9 participants