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

[Shareable saved objects] Add Spaces column to TableListView component #170359

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9355fd6
Add Spaces column to TableListViewTable component
nickpeihl Nov 1, 2023
88741fb
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 1, 2023
f9f0940
Add Spaces column to Annotations, Graph, Maps, Visualize lists
nickpeihl Nov 1, 2023
40cbf70
Merge remote-tracking branch 'refs/remotes/origin/spaces-tablelist' i…
nickpeihl Nov 1, 2023
9772e65
Add Spaces column to Dashboard listing
nickpeihl Nov 2, 2023
6fecfef
PoC: Disable delete for shared items
nickpeihl Nov 3, 2023
91f1d26
Merge branch 'shareable-dashboards' into spaces-tablelist
nickpeihl Nov 7, 2023
5985e12
Allow unshare from current space
nickpeihl Nov 7, 2023
96295d4
Add Spaces column to Add from library flyout
nickpeihl Nov 7, 2023
61291a5
Add Spaces column to Open Search Panel
nickpeihl Nov 7, 2023
488d64c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 7, 2023
0f6d24c
Use default cursor style for spaces list
nickpeihl Nov 7, 2023
8e5a3f6
Merge remote-tracking branch 'refs/remotes/origin/spaces-tablelist' i…
nickpeihl Nov 7, 2023
9cfc22d
Merge remote-tracking branch 'upstream/shareable-dashboards' into spa…
nickpeihl Nov 8, 2023
eb35f80
Fix types on test
nickpeihl Nov 8, 2023
ad4bb62
Make Files shareable in File Management
nickpeihl Nov 8, 2023
59c9cbe
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Nov 8, 2023
b0f05f5
Add Spaces column test to savedobjectfinder
nickpeihl Nov 9, 2023
97913d3
Fix hook usage error
nickpeihl Nov 9, 2023
f253234
Update Annotations snapshot
nickpeihl Nov 9, 2023
594388f
Merge remote-tracking branch 'refs/remotes/origin/spaces-tablelist' i…
nickpeihl Nov 9, 2023
8911612
Revert "PoC: Disable delete for shared items"
nickpeihl Nov 9, 2023
47e60e1
Disable Spaces column in Serverless
nickpeihl Nov 9, 2023
bcc4bcb
Merge branch 'shareable-dashboards' into spaces-tablelist
nickpeihl Nov 13, 2023
fa86e8a
Fix dashboard backup service
nickpeihl Nov 14, 2023
7c7e65f
Fix namespace type in annotation group
nickpeihl Nov 14, 2023
def3db8
Add namespaces to Graph table listing
nickpeihl Nov 14, 2023
6b62c44
Merge remote-tracking branch 'refs/remotes/origin/spaces-tablelist' i…
nickpeihl Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/content_management_examples/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"kibanaReact",
"savedObjectsTaggingOss"
],
"optionalPlugins": [
"spaces"
],
"requiredBundles": ["savedObjectsFinder"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { FinderApp } from './finder';

export const renderApp = (
core: CoreStart,
{ contentManagement, savedObjectsTaggingOss }: StartDeps,
{ contentManagement, savedObjectsTaggingOss, spaces }: StartDeps,
{ element, history }: AppMountParameters
) => {
ReactDOM.render(
Expand Down Expand Up @@ -69,6 +69,7 @@ export const renderApp = (
contentClient={contentManagement.client}
core={core}
savedObjectsTagging={savedObjectsTaggingOss}
spaces={spaces}
/>
</Route>
<Route path="/finder">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import React from 'react';
import React, { FC, useMemo } from 'react';
import { SpacesContextProps, SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { ContentClientProvider, type ContentClient } from '@kbn/content-management-plugin/public';
import { TableListViewKibanaProvider } from '@kbn/content-management-table-list-view-table';
import type { CoreStart } from '@kbn/core/public';
Expand All @@ -15,23 +16,37 @@ import { FormattedRelative, I18nProvider } from '@kbn/i18n-react';
import { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-tagging-oss-plugin/public';
import { MSearchTable } from './msearch_table';

const getEmptyFunctionComponent: FC<SpacesContextProps> = ({ children }) => <>{children}</>;

export const MSearchApp = (props: {
contentClient: ContentClient;
core: CoreStart;
savedObjectsTagging: SavedObjectTaggingOssPluginStart;
spaces?: SpacesPluginStart;
}) => {
const SpacesContextWrapper = useMemo(
() =>
props.spaces
? props.spaces.ui.components.getSpacesContextProvider
: getEmptyFunctionComponent,
[props.spaces]
);

return (
<ContentClientProvider contentClient={props.contentClient}>
<I18nProvider>
<TableListViewKibanaProvider
core={props.core}
toMountPoint={toMountPoint}
FormattedRelative={FormattedRelative}
savedObjectsTagging={props.savedObjectsTagging.getTaggingApi()}
>
<MSearchTable />
</TableListViewKibanaProvider>
</I18nProvider>
</ContentClientProvider>
<SpacesContextWrapper>
<ContentClientProvider contentClient={props.contentClient}>
<I18nProvider>
<TableListViewKibanaProvider
core={props.core}
toMountPoint={toMountPoint}
FormattedRelative={FormattedRelative}
savedObjectsTagging={props.savedObjectsTagging.getTaggingApi()}
spacesApi={props.spaces}
>
<MSearchTable />
</TableListViewKibanaProvider>
</I18nProvider>
</ContentClientProvider>
</SpacesContextWrapper>
);
};
2 changes: 2 additions & 0 deletions examples/content_management_examples/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ContentManagementPublicSetup,
ContentManagementPublicStart,
} from '@kbn/content-management-plugin/public';
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
import { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-tagging-oss-plugin/public';

Expand All @@ -21,4 +22,5 @@ export interface SetupDeps {
export interface StartDeps {
contentManagement: ContentManagementPublicStart;
savedObjectsTaggingOss: SavedObjectTaggingOssPluginStart;
spaces?: SpacesPluginStart;
}
1 change: 1 addition & 0 deletions examples/content_management_examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"@kbn/content-management-table-list-view",
"@kbn/shared-ux-router",
"@kbn/saved-objects-finder-plugin",
"@kbn/spaces-plugin",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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, { FC, useState } from 'react';

import type { Capabilities } from '@kbn/core/public';
import type { SpacesApi, ShareToSpaceFlyoutProps } from '@kbn/spaces-plugin/public';

interface Props {
spacesApi: SpacesApi;
capabilities: Capabilities | undefined;
spaceIds: string[];
type: string;
noun: string;
id: string;
title: string;
refresh(): void;
}

export const SpacesList: FC<Props> = ({
spacesApi,
capabilities,
type,
noun,
spaceIds,
id,
title,
refresh,
}) => {
const [showFlyout, setShowFlyout] = useState(false);

function onClose() {
setShowFlyout(false);
}

// TODO Check the namespaceType and disable column if not multiple
// See src/plugins/saved_objects_management/public/services/columns/share_saved_objects_to_space_column.tsx

// TODO Disable for Serverless

const LazySpaceList = spacesApi.ui.components.getSpaceList;
const LazyShareToSpaceFlyout = spacesApi.ui.components.getShareToSpaceFlyout;

const shareToSpaceFlyoutProps: ShareToSpaceFlyoutProps = {
savedObjectTarget: {
type,
namespaces: spaceIds,
id,
title,
noun,
},
behaviorContext: 'outside-space',
onUpdate: refresh,
onClose,
};

const canAssignSpaces = !capabilities || !!capabilities.savedObjectsManagement.shareIntoSpace;
const clickProperties = canAssignSpaces
? { cursorStyle: 'pointer', listOnClick: () => setShowFlyout(true) }
: { cursorStyle: 'not-allowed' };
return (
<>
<LazySpaceList
namespaces={spaceIds}
displayLimit={8}
behaviorContext="outside-space"
{...clickProperties}
/>
{showFlyout && <LazyShareToSpaceFlyout {...shareToSpaceFlyoutProps} />}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React, { FC, useContext, useMemo, useCallback } from 'react';
import type { Observable } from 'rxjs';
import type { FormattedRelative } from '@kbn/i18n-react';
import type { SpacesApi } from '@kbn/spaces-plugin/public';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
import type { OverlayFlyoutOpenOptions } from '@kbn/core-overlays-browser';
import { RedirectAppLinksKibanaProvider } from '@kbn/shared-ux-link-redirect-app';
Expand Down Expand Up @@ -56,6 +57,7 @@ export interface Services {
/** Handler to retrieve the list of available tags */
getTagList: () => Tag[];
TagList: FC<TagListProps>;
spacesApi?: SpacesApi;
/** Predicate function to indicate if some of the saved object references are tags */
itemHasTags: (references: SavedObjectsReference[]) => boolean;
/** Handler to return the url to navigate to the kibana tags management */
Expand Down Expand Up @@ -155,6 +157,7 @@ export interface TableListViewKibanaDependencies {
getTagIdsFromReferences: (references: SavedObjectsReference[]) => string[];
};
};
spacesApi?: SpacesApi;
/** The <FormattedRelative /> component from the @kbn/i18n-react package */
FormattedRelative: typeof FormattedRelative;
}
Expand All @@ -166,7 +169,7 @@ export const TableListViewKibanaProvider: FC<TableListViewKibanaDependencies> =
children,
...services
}) => {
const { core, toMountPoint, savedObjectsTagging, FormattedRelative } = services;
const { core, toMountPoint, savedObjectsTagging, spacesApi, FormattedRelative } = services;

const searchQueryParser = useMemo(() => {
if (savedObjectsTagging) {
Expand Down Expand Up @@ -245,6 +248,7 @@ export const TableListViewKibanaProvider: FC<TableListViewKibanaDependencies> =
itemHasTags={itemHasTags}
getTagIdsFromReferences={getTagIdsFromReferences}
getTagManagementUrl={() => core.http.basePath.prepend(TAG_MANAGEMENT_APP_URL)}
spacesApi={spacesApi}
>
{children}
</TableListViewProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: 'item-1',
namespaces: ['default'],
type: 'dashboard',
updatedAt: '2020-01-01T00:00:00Z',
attributes: {
Expand Down Expand Up @@ -188,6 +189,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: twoDaysAgo.toISOString(),
type: 'dashboard',
attributes: {
Expand All @@ -198,6 +200,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
// This is the latest updated and should come first in the table
updatedAt: yesterday.toISOString(),
type: 'dashboard',
Expand Down Expand Up @@ -330,6 +333,7 @@ describe('TableListView', () => {

const hits: UserContentCommonSchema[] = [...Array(totalItems)].map((_, i) => ({
id: `item${i}`,
namespaces: ['default'],
type: 'dashboard',
updatedAt,
attributes: {
Expand Down Expand Up @@ -438,6 +442,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: twoDaysAgo.toISOString(), // first asc, last desc
type: 'dashboard',
attributes: {
Expand All @@ -447,6 +452,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
updatedAt: yesterday.toISOString(), // first desc, last asc
type: 'dashboard',
attributes: {
Expand Down Expand Up @@ -639,6 +645,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: new Date(new Date().setDate(new Date().getDate() - 1)).toISOString(),
attributes: {
title: 'Item 1',
Expand All @@ -649,6 +656,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
updatedAt: new Date(new Date().setDate(new Date().getDate() - 2)).toISOString(),
attributes: {
title: 'Item 2',
Expand Down Expand Up @@ -697,6 +705,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: new Date(new Date().setDate(new Date().getDate() - 1)).toISOString(),
type: 'dashboard',
attributes: {
Expand All @@ -710,6 +719,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
updatedAt: new Date(new Date().setDate(new Date().getDate() - 2)).toISOString(),
type: 'dashboard',
attributes: {
Expand Down Expand Up @@ -890,6 +900,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: 'item-1',
namespaces: ['default'],
type: 'dashboard',
updatedAt,
attributes: {
Expand All @@ -899,6 +910,7 @@ describe('TableListView', () => {
},
{
id: 'item-2',
namespaces: ['default'],
type: 'dashboard',
updatedAt,
attributes: {
Expand Down Expand Up @@ -1075,6 +1087,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: yesterday.toISOString(),
type: 'dashboard',
attributes: {
Expand All @@ -1085,6 +1098,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
updatedAt: twoDaysAgo.toISOString(),
type: 'dashboard',
attributes: {
Expand Down Expand Up @@ -1344,6 +1358,7 @@ describe('TableListView', () => {
const hits: UserContentCommonSchema[] = [
{
id: '123',
namespaces: ['default'],
updatedAt: twoDaysAgo.toISOString(),
type: 'dashboard',
attributes: {
Expand All @@ -1354,6 +1369,7 @@ describe('TableListView', () => {
},
{
id: '456',
namespaces: ['default'],
updatedAt: yesterday.toISOString(),
type: 'dashboard',
attributes: {
Expand Down Expand Up @@ -1467,6 +1483,7 @@ describe('TableList', () => {
const originalHits: UserContentCommonSchema[] = [
{
id: `item`,
namespaces: ['default'],
type: 'dashboard',
updatedAt: 'original timestamp',
attributes: {
Expand All @@ -1491,6 +1508,7 @@ describe('TableList', () => {
const hits: UserContentCommonSchema[] = [
{
id: `item`,
namespaces: ['default'],
type: 'dashboard',
updatedAt: 'updated timestamp',
attributes: {
Expand Down
Loading