Skip to content

Commit

Permalink
[Saved Objects Tagging] Visually hide tags in Saved Objects Management (
Browse files Browse the repository at this point in the history
#197423)

## Summary

This PR visually hides objects with `tag` type from `Saved Objects
Management` table while still allowing them to be exportable.

Closes: #147786
  • Loading branch information
kowalczyk-krzysztof authored Oct 24, 2024
1 parent 512bfcc commit e0ef5b3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const convertType = (type: string): SavedObjectManagementTypeInfo => ({
namespaceType: 'single',
});

const allowedTypes = ['index-pattern', 'visualization', 'dashboard', 'search'].map(convertType);
const allowedTypes = ['index-pattern', 'visualization', 'dashboard', 'search', 'tag'].map(
convertType
);

const allSavedObjects = [
{
Expand Down Expand Up @@ -82,6 +84,13 @@ const allSavedObjects = [
title: `MyViz`,
},
},
{
id: '5',
type: 'tag',
attributes: {
title: `HelloWorldTag`,
},
},
];

describe('SavedObjectsTable', () => {
Expand Down Expand Up @@ -129,6 +138,7 @@ describe('SavedObjectsTable', () => {
visualization: 0,
dashboard: 0,
search: 0,
tag: 0,
});

defaultProps = {
Expand All @@ -148,7 +158,7 @@ describe('SavedObjectsTable', () => {
};

findObjectsMock.mockImplementation(() => ({
total: 4,
total: 5,
saved_objects: [
{
id: '1',
Expand Down Expand Up @@ -199,6 +209,14 @@ describe('SavedObjectsTable', () => {
},
},
},
{
id: '5',
type: 'tag',
meta: {
title: `HelloWorldTag`,
icon: 'tag',
},
},
],
}));
});
Expand Down Expand Up @@ -451,7 +469,7 @@ describe('SavedObjectsTable', () => {
component.update();

await component.instance().getRelationships('search', '1');
const savedObjectTypes = ['index-pattern', 'visualization', 'dashboard', 'search'];
const savedObjectTypes = ['index-pattern', 'visualization', 'dashboard', 'search', 'tag'];
expect(getRelationshipsMock).toHaveBeenCalledWith(http, 'search', '1', savedObjectTypes);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,10 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
onSelectionChange: this.onSelectionChanged,
};

const filterOptions = allowedTypes.map((type) => ({
const filtersWithoutTags = allowedTypes.filter((t) => t.name !== 'tag');
const itemsWithoutTags = savedObjects.filter((t) => t.type !== 'tag');

const filterOptions = filtersWithoutTags.map((type) => ({
value: type.displayName,
name: type.displayName,
view: `${type.displayName} (${savedObjectCounts[type.name] || 0})`,
Expand Down Expand Up @@ -733,7 +736,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
pageIndex={page}
pageSize={perPage}
sort={sort}
items={savedObjects}
items={itemsWithoutTags}
totalItemCount={filteredItemCount}
isSearching={isSearching}
onShowRelationships={this.onShowRelationships}
Expand Down

0 comments on commit e0ef5b3

Please sign in to comment.