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

[Embeddable Refactor] Create Decoupled Presentation Panel #172017

Merged
merged 50 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2ac2782
initialize presentation panel and presentation publishing packages
ThomThomson Nov 27, 2023
4fe15eb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 27, 2023
050712c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 27, 2023
4130eb2
Initialize readmes and add tests
ThomThomson Dec 1, 2023
67a679d
remove Dashboard from embeddable tests
ThomThomson Dec 1, 2023
af34cb7
Merge remote-tracking branch 'refs/remotes/origin/createPresentationP…
ThomThomson Dec 1, 2023
4041175
Fix & add jest tests
ThomThomson Dec 5, 2023
be1b357
remove accidental modifications, fix tsconfig
ThomThomson Dec 5, 2023
067b3fc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 5, 2023
f396fd1
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Dec 5, 2023
48a2238
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Dec 5, 2023
c2d7a88
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Dec 5, 2023
84e0e04
Merge remote-tracking branch 'refs/remotes/origin/createPresentationP…
ThomThomson Dec 6, 2023
e1aea30
fix jest tests & types
ThomThomson Dec 6, 2023
907b80d
fix test subjects
ThomThomson Dec 6, 2023
e5c6593
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 6, 2023
ebf90b1
revert class name changes, make drilldown notification responsive, fi…
ThomThomson Dec 7, 2023
0fcca6a
Merge remote-tracking branch 'refs/remotes/origin/createPresentationP…
ThomThomson Dec 7, 2023
83fc26b
fix more tests
ThomThomson Dec 8, 2023
a3d55e9
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Dec 8, 2023
9874b83
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 8, 2023
04cd8a4
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Jan 3, 2024
0ebe79f
Update translations
ThomThomson Jan 3, 2024
d95a171
change package naming convention
ThomThomson Jan 4, 2024
6c03cf7
add error handling and refactor presentation_panel. Try catch to avoi…
ThomThomson Jan 5, 2024
7322dc7
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Jan 8, 2024
31d7696
Finish merge
ThomThomson Jan 8, 2024
082df6e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jan 8, 2024
1427c5f
isolate publishing subject logic and rename methods
nreese Jan 9, 2024
1e85dce
fix imports
nreese Jan 9, 2024
180b11b
fix types and jest configs
ThomThomson Jan 9, 2024
ed614be
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jan 9, 2024
6ca5c7e
remove presentation_panel from security solution
ThomThomson Jan 9, 2024
0bb4f3e
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jan 9, 2024
ffd63bf
Merge pull request #19 from nreese/publishing_subject
ThomThomson Jan 9, 2024
9f8a53b
Remove presentation panel import from security solution test, fix mis…
ThomThomson Jan 9, 2024
9642523
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 9, 2024
208d407
publishing subject test (#21)
nreese Jan 10, 2024
827946f
fix prettier
ThomThomson Jan 10, 2024
bebc424
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 10, 2024
f216d45
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Jan 11, 2024
b9f6ca7
add panel title to add to library error
ThomThomson Jan 11, 2024
2d0162b
Fix types & jest tests, revert changes to filterableEmbeddable. Fix f…
ThomThomson Jan 12, 2024
3afa33e
revert changes to add to timeline test
ThomThomson Jan 12, 2024
9f98fdd
Merge branch 'main' into createPresentationPanel
mbondyra Jan 15, 2024
868b5a1
review feedback
ThomThomson Jan 16, 2024
215964b
Merge remote-tracking branch 'origin/createPresentationPanel' into cr…
ThomThomson Jan 16, 2024
b341128
Merge remote-tracking branch 'upstream/main' into createPresentationP…
ThomThomson Jan 16, 2024
d2eb105
Review feedback, fix i18n
ThomThomson Jan 17, 2024
ed734ba
undo lastValueFrom change, fix jest tests, apply review feedback
ThomThomson Jan 17, 2024
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
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ packages/kbn-plugin-generator @elastic/kibana-operations
packages/kbn-plugin-helpers @elastic/kibana-operations
examples/portable_dashboards_example @elastic/kibana-presentation
examples/preboot_example @elastic/kibana-security @elastic/kibana-core
packages/presentation/presentation_containers @elastic/kibana-presentation
packages/presentation/presentation_library @elastic/kibana-presentation
src/plugins/presentation_panel @elastic/kibana-presentation
packages/presentation/presentation_publishing @elastic/kibana-presentation
src/plugins/presentation_util @elastic/kibana-presentation
x-pack/plugins/profiling_data_access @elastic/obs-ux-infra_services-team
x-pack/plugins/profiling @elastic/obs-ux-infra_services-team
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"discover": ["src/plugins/discover", "packages/kbn-discover-utils"],
"savedSearch": "src/plugins/saved_search",
"embeddableApi": "src/plugins/embeddable",
"presentationPanel": "src/plugins/presentation_panel",
"embeddableExamples": "examples/embeddable_examples",
"esQuery": "packages/kbn-es-query/src",
"esUi": "src/plugins/es_ui_shared",
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ Content is fetched from the remote (https://feeds.elastic.co) once a day, with p
|Helps to globally configure the no data page components


|{kib-repo}blob/{branch}/src/plugins/presentation_panel/README.md[presentationPanel]
|The Presentation Panel is the point of contact between any React component and any registered UI actions. Components provided to the Presentation Panel should use an imperative handle to expose methods and state.


|{kib-repo}blob/{branch}/src/plugins/presentation_util/README.mdx[presentationUtil]
|The Presentation Utility Plugin is a set of common, shared components and toolkits for solutions within the Presentation space, (e.g. Dashboards, Canvas).

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
"@kbn/panel-loader": "link:packages/kbn-panel-loader",
"@kbn/portable-dashboards-example": "link:examples/portable_dashboards_example",
"@kbn/preboot-example-plugin": "link:examples/preboot_example",
"@kbn/presentation-containers": "link:packages/presentation/presentation_containers",
"@kbn/presentation-library": "link:packages/presentation/presentation_library",
"@kbn/presentation-panel-plugin": "link:src/plugins/presentation_panel",
"@kbn/presentation-publishing": "link:packages/presentation/presentation_publishing",
"@kbn/presentation-util-plugin": "link:src/plugins/presentation_util",
"@kbn/profiling-data-access-plugin": "link:x-pack/plugins/profiling_data_access",
"@kbn/profiling-plugin": "link:x-pack/plugins/profiling",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pageLoadAssetSize:
observabilityShared: 52256
osquery: 107090
painlessLab: 179748
presentationPanel: 55463
presentationUtil: 58834
profiling: 36694
remoteClusters: 51327
Expand Down
13 changes: 12 additions & 1 deletion packages/kbn-panel-loader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

import React from 'react';
import { EuiLoadingChart, EuiPanel } from '@elastic/eui';
import { css } from '@emotion/react';

export const PanelLoader = (props: { showShadow?: boolean; dataTestSubj?: string }) => {
return (
<EuiPanel
css={css`
z-index: auto;
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
min-height: $euiSizeL + 2px;
position: relative;
justify-content: center;
align-items: center;
`}
role="figure"
paddingSize="none"
hasShadow={props.showShadow ?? false}
className={'embPanel embPanel--loading embPanel-isLoading'}
data-test-subj={props.dataTestSubj}
>
<EuiLoadingChart size="l" mono />
Expand Down
3 changes: 3 additions & 0 deletions packages/presentation/presentation_containers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/presentation-containers

Contains interfaces and type guards which can be used to define and consume "containers" which are pages or elements which render multiple panels.
22 changes: 22 additions & 0 deletions packages/presentation/presentation_containers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

export {
apiCanDuplicatePanels,
apiCanExpandPanels,
useExpandedPanelId,
type CanDuplicatePanels,
type CanExpandPanels,
} from './interfaces/panel_management';
export {
apiIsPresentationContainer,
getContainerParentFromAPI,
type PanelPackage,
type PresentationContainer,
} from './interfaces/presentation_container';
export { tracksOverlays, type TracksOverlays } from './interfaces/tracks_overlays';
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 {
PublishingSubject,
useStateFromPublishingSubject,
} from '@kbn/presentation-publishing/publishing_subject';

export interface CanDuplicatePanels {
duplicatePanel: (panelId: string) => void;
}

export const apiCanDuplicatePanels = (
unknownApi: unknown | null
): unknownApi is CanDuplicatePanels => {
return Boolean((unknownApi as CanDuplicatePanels)?.duplicatePanel !== undefined);
};

export interface CanExpandPanels {
expandPanel: (panelId?: string) => void;
expandedPanelId: PublishingSubject<string | undefined>;
}

export const apiCanExpandPanels = (unknownApi: unknown | null): unknownApi is CanExpandPanels => {
return Boolean((unknownApi as CanExpandPanels)?.expandPanel !== undefined);
};

/**
* Gets this API's expanded panel state as a reactive variable which will cause re-renders on change.
*/
export const useExpandedPanelId = (api: Partial<CanExpandPanels> | undefined) =>
useStateFromPublishingSubject<string | undefined, CanExpandPanels['expandedPanelId']>(
apiCanExpandPanels(api) ? api.expandedPanelId : undefined
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { apiPublishesParentApi } from '@kbn/presentation-publishing';

export interface PanelPackage {
panelType: string;
initialState: unknown;
}
export interface PresentationContainer {
removePanel: (panelId: string) => void;
canRemovePanels?: () => boolean;
replacePanel: (idToRemove: string, newPanel: PanelPackage) => Promise<string>;
}

export const apiIsPresentationContainer = (
unknownApi: unknown | null
): unknownApi is PresentationContainer => {
return Boolean((unknownApi as PresentationContainer)?.removePanel !== undefined);
};

export const getContainerParentFromAPI = (
api: null | unknown
): PresentationContainer | undefined => {
const apiParent = apiPublishesParentApi(api) ? api.parentApi.value : null;
if (!apiParent) return undefined;
return apiIsPresentationContainer(apiParent) ? apiParent : undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
import { OverlayRef } from '@kbn/core-mount-utils-browser';

interface TracksOverlaysOptions {
/**
* If present, the panel with this ID will be focused when the overlay is opened. This can be used in tandem with a push
* flyout to edit a panel's settings in context
*/
focusedPanelId?: string;
}

interface TracksOverlays {
export interface TracksOverlays {
openOverlay: (ref: OverlayRef, options?: TracksOverlaysOptions) => void;
clearOverlays: () => void;
}

export const tracksOverlays = (root: unknown): root is TracksOverlays => {
return Boolean((root as TracksOverlays).openOverlay && (root as TracksOverlays).clearOverlays);
return Boolean(
root && (root as TracksOverlays).openOverlay && (root as TracksOverlays).clearOverlays
);
};
13 changes: 13 additions & 0 deletions packages/presentation/presentation_containers/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/packages/presentation/presentation_containers'],
};
5 changes: 5 additions & 0 deletions packages/presentation/presentation_containers/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/presentation-containers",
"owner": "@elastic/kibana-presentation"
}
6 changes: 6 additions & 0 deletions packages/presentation/presentation_containers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/presentation-containers",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
10 changes: 10 additions & 0 deletions packages/presentation/presentation_containers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node", "react"]
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["target/**/*"],
"kbn_references": ["@kbn/presentation-publishing", "@kbn/core-mount-utils-browser"]
}
3 changes: 3 additions & 0 deletions packages/presentation/presentation_library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/presentation-library

Contains interfaces and type guards to be used to mediate the relationship between panels / charts, and a content library.
13 changes: 13 additions & 0 deletions packages/presentation/presentation_library/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

export { type CanLinkToLibrary, apiCanLinkToLibrary } from './interfaces/can_link_to_library';
export {
type CanUnlinkFromLibrary,
apiCanUnlinkFromLibrary,
} from './interfaces/can_unlink_from_library';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*/

export interface CanLinkToLibrary {
canLinkToLibrary: () => Promise<boolean>;
linkToLibrary: () => Promise<void>;
}

export const apiCanLinkToLibrary = (api: unknown): api is CanLinkToLibrary =>
typeof (api as CanLinkToLibrary).canLinkToLibrary === 'function' &&
typeof (api as CanLinkToLibrary).linkToLibrary === 'function';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*/

export interface CanUnlinkFromLibrary {
canUnlinkFromLibrary: () => Promise<boolean>;
unlinkFromLibrary: () => Promise<void>;
}

export const apiCanUnlinkFromLibrary = (api: unknown): api is CanUnlinkFromLibrary =>
typeof (api as CanUnlinkFromLibrary).canUnlinkFromLibrary === 'function' &&
typeof (api as CanUnlinkFromLibrary).unlinkFromLibrary === 'function';
13 changes: 13 additions & 0 deletions packages/presentation/presentation_library/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/packages/presentation/presentation_library'],
};
5 changes: 5 additions & 0 deletions packages/presentation/presentation_library/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/presentation-library",
"owner": "@elastic/kibana-presentation"
}
6 changes: 6 additions & 0 deletions packages/presentation/presentation_library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/presentation-library",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
10 changes: 10 additions & 0 deletions packages/presentation/presentation_library/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node", "react"]
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["target/**/*"],
"kbn_references": []
}
3 changes: 3 additions & 0 deletions packages/presentation/presentation_publishing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/presentation-publishing

Contains interfaces and type guards to be used to publish and consume state of specific types.
Loading