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

Add bulk assign action to tag management #84177

Merged
merged 49 commits into from
Dec 7, 2020

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Nov 24, 2020

Summary

Part of #81970

This PR adds the assign (per tag) and bulk_assign (multiple tags) action to the tag management section.

  • add the new assign and bulk_assign actions
  • extract the per-tag actions from the page/table component, for better isolation and consistency with the bulk_actions

Screenshots

Bulk action

Screenshot 2020-11-30 at 11 16 10

Column action

Screenshot 2020-11-30 at 11 16 26

Flyout

Screenshot 2020-11-30 at 11 17 20

Filtering

Screenshot 2020-11-30 at 11 17 35

Checklist

@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes v7.11.0 v8.0.0 labels Nov 25, 2020
@ryankeairns
Copy link
Contributor

@ryankeairns, am I correct in my assumptions above? If so, would it be worth it for me to write up an EUI issue to ask that we not show any isPrimary action in the popover menu unless the user is viewing from a smaller viewport size where those primary buttons are hidden?

I just posted and deleted a similar message :) A separate EUI dicuss item seems like a good approach as this is recommended behavior, per the docs, to include all links in the popover.

@pgayvallet
Copy link
Contributor Author

Do we need both an edit icon and a context menu item to edit a tag?

I was surprised of this behavior to be honest, but I don't have any control over it. As @ryankeairns explained:

The EUI docs suggest that any number of actions greater than two will result in this 'more actions' button. Per the docs, all links would then appear in the popover menu

This would need to be discussed upstream

@pgayvallet
Copy link
Contributor Author

@alexfrancoeur the bug when navigating to SO management by selecting a tag with whitespaces is fixed by 385bab9

@pgayvallet pgayvallet added Feature:Saved Object Tagging Saved Objects Tagging feature and removed Feature:Embedding Embedding content via iFrame labels Dec 1, 2020
@ryankeairns
Copy link
Contributor

Do we need both an edit icon and a context menu item to edit a tag?

I was surprised of this behavior to be honest, but I don't have any control over it. As @ryankeairns explained:

The EUI docs suggest that any number of actions greater than two will result in this 'more actions' button. Per the docs, all links would then appear in the popover menu

This would need to be discussed upstream

Created an EUI discuss item to follow up on that overflow menu behavior; to be tracked aside from this PR.
elastic/eui#4326

@joshdover
Copy link
Contributor

ack: will do thorough in-depth code review tomorrow

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Dec 3, 2020
@pgayvallet pgayvallet removed the Feature:Embedding Embedding content via iFrame label Dec 3, 2020
Copy link
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

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

The implementation here is super solid. Mostly small nits, nothing major to block this. Thanks Pierre! 🎉

/**
* The list of saved object types that are currently supporting tagging.
*/
export const taggableTypes = ['dashboard', 'visualization', 'map', 'lens'];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely a little out of the norm, but I'm willing to entertain the idea. The main con I see to this option is a poorer Dev XP. What would the consequences be of forgetting to add a type name to this array? Or what if a type changes its name? Another con is that external plugins wouldn't be able to integrate with this, but I don't think that's particularly important for this feature at this time.

Will this create any issues if the plugins that provide these SO types are disabled? For instance if xpack.maps.enabled: false is set.

return assignedCount === 0 ? 'none' : assignedCount === assignedTags.length ? 'full' : 'partial';
};

export const AssignFlyout: FC<AssignFlyoutProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this component has a decent amount of logic, should we add unit tests or is this covered elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, snapshot testing is imho very inefficient, and I basically assumed that the FTR coverage was enough. We would probably need to setup storybook for the plugin if we want to have proper UT coverage on the components?

selectedTypes?: string[];
}

export function parseQuery(query: Query): ParsedQuery {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the naming here is a bit misleading since the parsing is actually done prior to calling this function. Maybe selectedTypesFromQuery would be more appropriate?

Comment on lines +112 to +117
// if we failed to fetch any object, just halt and throw an error
const firstObjWithError = objects.find((obj) => !!obj.error);
if (firstObjWithError) {
const firstError = firstObjWithError.error!;
throw new AssignmentError(firstError.message, firstError.statusCode);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a smart decision 😄

Comment on lines +38 to +49
export class AssignmentService {
private readonly soClient: SavedObjectsClientContract;
private readonly typeRegistry: ISavedObjectTypeRegistry;
private readonly authorization?: SecurityPluginSetup['authz'];
private readonly request: KibanaRequest;

constructor({ client, typeRegistry, authorization, request }: AssignmentServiceOptions) {
this.soClient = client;
this.typeRegistry = typeRegistry;
this.authorization = authorization;
this.request = request;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that unless we anticipate having a non-scoped version, AssignmentService is fine for brevity's sake.


const searchFields = uniq(
assignableTypes.map(
(name) => this.typeRegistry.getType(name)?.management!.defaultSearchField!
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we validate elsewhere that these types all have this defined? If not, this could be a easy-to-create bug that wouldn't easily be caught.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uniq implementation removes all undefined values from the array, so worse case, missing search fields will be ignored.

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Dec 3, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
savedObjectsTagging 66 99 +33

Async chunks

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

id before after diff
savedObjectsTagging 81.7KB 115.6KB +33.9KB

Distributable file count

id before after diff
default 46897 47675 +778

Page load bundle

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

id before after diff
savedObjectsTagging 44.7KB 48.8KB +4.1KB
Unknown metric groups

async chunk count

id before after diff
savedObjectsTagging 3 4 +1

History

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

@pgayvallet pgayvallet merged commit 446390d into elastic:master Dec 7, 2020
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Dec 7, 2020
* initial draft

* move components to their own files

* create services folder and move tags package

* add assignment service

* fix some types

* prepare assign tag route

* move server-side tag client under the `services` folder

* add security check, move a lot of stuff.

* design improvements

* display tags in flyout

* improve button and add notification on save

* add action on tag rows

* fix types

* fix mock import paths

* add lens to the list of assignable types

* update generated doc

* add base functional tests

* move api to internal

* add api/security test suites

* add / use get_assignable_types API

* fix feature control tests

* fix assignable types propagation

* rename actions folder to bulk_actions

* extract actions to their own module

* add common / server unit tests

* add client-side assign tests

* add some tests and tsdoc

* typo

* add getActions test

* revert width change

* fix typo in API

* various minor improvements

* typo

* tsdoc on flyout page object

* close flyout when leaving the page

* fix bug when redirecting to SO management with a tag having whitespaces in its name

* check for dupes in toAdd and toRemove

* add lazy load to assign modal opener

* add lazy load to edit/create modals

* check if at least one assign or unassign tag id is specified

* grammar

* add explicit type existence check
pgayvallet added a commit that referenced this pull request Dec 7, 2020
* Add `bulk assign` action to tag management (#84177)

* initial draft

* move components to their own files

* create services folder and move tags package

* add assignment service

* fix some types

* prepare assign tag route

* move server-side tag client under the `services` folder

* add security check, move a lot of stuff.

* design improvements

* display tags in flyout

* improve button and add notification on save

* add action on tag rows

* fix types

* fix mock import paths

* add lens to the list of assignable types

* update generated doc

* add base functional tests

* move api to internal

* add api/security test suites

* add / use get_assignable_types API

* fix feature control tests

* fix assignable types propagation

* rename actions folder to bulk_actions

* extract actions to their own module

* add common / server unit tests

* add client-side assign tests

* add some tests and tsdoc

* typo

* add getActions test

* revert width change

* fix typo in API

* various minor improvements

* typo

* tsdoc on flyout page object

* close flyout when leaving the page

* fix bug when redirecting to SO management with a tag having whitespaces in its name

* check for dupes in toAdd and toRemove

* add lazy load to assign modal opener

* add lazy load to edit/create modals

* check if at least one assign or unassign tag id is specified

* grammar

* add explicit type existence check

* fix mappings for 7.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Embedding Embedding content via iFrame Feature:Saved Object Tagging Saved Objects Tagging feature release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants