-
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
Add bulk assign
action to tag management
#84177
Add bulk assign
action to tag management
#84177
Conversation
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. |
I was surprised of this behavior to be honest, but I don't have any control over it. As @ryankeairns explained:
This would need to be discussed upstream |
@alexfrancoeur the bug when navigating to SO management by selecting a tag with whitespaces is fixed by 385bab9 |
Created an EUI discuss item to follow up on that overflow menu behavior; to be tracked aside from this PR. |
ack: will do thorough in-depth code review tomorrow |
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.
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']; |
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.
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> = ({ |
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.
Since this component has a decent amount of logic, should we add unit tests or is this covered elsewhere?
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.
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?
x-pack/plugins/saved_objects_tagging/public/components/assign_flyout/open_assign_flyout.tsx
Outdated
Show resolved
Hide resolved
selectedTypes?: string[]; | ||
} | ||
|
||
export function parseQuery(query: Query): ParsedQuery { |
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.
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?
x-pack/plugins/saved_objects_tagging/public/management/bulk_actions/index.test.ts
Outdated
Show resolved
Hide resolved
// 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); | ||
} |
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.
Sounds like a smart decision 😄
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; | ||
} |
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 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! |
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 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.
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.
uniq
implementation removes all undefined values from the array, so worse case, missing search fields will be ignored.
x-pack/plugins/saved_objects_tagging/server/routes/assignments/update_tags_assignments.ts
Outdated
Show resolved
Hide resolved
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
* 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
* 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
Summary
Part of #81970
This PR adds the
assign
(per tag) andbulk_assign
(multiple tags) action to the tag management section.assign
andbulk_assign
actionsbulk_actions
Screenshots
Bulk action
Column action
Flyout
Filtering
Checklist