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

[SecuritySolution] Security Solution Dashboard edit mode #159486

Merged
merged 142 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
92bae1c
add to library
angorayc Jun 12, 2023
b3f7f76
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jun 19, 2023
13b9323
add edit mode
angorayc Jun 19, 2023
c3a1e5c
actions
angorayc Jun 20, 2023
49b90f1
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Jun 20, 2023
359158d
export top nav
angorayc Jun 20, 2023
02353fc
dashboard top nav styling
angorayc Jun 22, 2023
debeedd
styling
angorayc Jun 22, 2023
0c15e35
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jun 22, 2023
4a1ea0a
styling
angorayc Jun 22, 2023
28b1ff0
types
angorayc Jun 22, 2023
875b411
set view mode on container load
angorayc Jun 22, 2023
8beb62e
allow no sticky top nav
angorayc Jun 22, 2023
2444f9a
Merge branch 'main' into edit-mode
angorayc Jun 22, 2023
6ffcd0c
lint
angorayc Jun 22, 2023
3769910
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Jun 23, 2023
92ffcf4
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jun 28, 2023
854196f
add originatingApp and originatingPath
angorayc Jun 29, 2023
91f0f0a
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jun 30, 2023
b61e354
add getStateTransfer
angorayc Jun 30, 2023
27ce42e
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jul 18, 2023
af6c770
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jul 18, 2023
6b7bac5
fix missing tool bar
angorayc Jul 20, 2023
73359e2
add from lens editor
angorayc Jul 20, 2023
99ee686
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Jul 26, 2023
d888c16
creation options
angorayc Aug 3, 2023
95310b6
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 7, 2023
f5d671c
check is managed dashboard
angorayc Aug 8, 2023
e68b150
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 9, 2023
363cbc3
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 9, 2023
59a727d
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 10, 2023
315de70
dashboard creation
angorayc Aug 10, 2023
a4d75d8
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 21, 2023
7947e20
useDashboardRenderer hook
angorayc Aug 21, 2023
a6311ef
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 23, 2023
d52c958
unit tests
angorayc Aug 24, 2023
64289cc
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Aug 24, 2023
9e0a48b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 24, 2023
ff3b6c9
unit tests
angorayc Aug 24, 2023
a99c548
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Aug 24, 2023
2513569
Merge branch 'main' into edit-mode
angorayc Aug 24, 2023
670a129
update limits
angorayc Aug 26, 2023
89bee44
Merge branch 'main' into edit-mode
angorayc Aug 29, 2023
e3c90d0
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 1, 2023
a6ec841
rm add to library actions
angorayc Sep 1, 2023
5f3fdde
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 1, 2023
7bd943e
dashboard updated title
angorayc Sep 1, 2023
77f3f3e
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 1, 2023
d7a57aa
dashboard updated title
angorayc Sep 1, 2023
e51a31d
fix update from settings
angorayc Sep 1, 2023
cad4508
revert actions change
angorayc Sep 1, 2023
64baad8
unit tests
angorayc Sep 1, 2023
6889ed3
unit tests
angorayc Sep 4, 2023
b50cc51
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 4, 2023
2176061
fix breadcrumbs
angorayc Sep 4, 2023
b223193
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 4, 2023
72a222f
Merge branch 'main' into edit-mode
angorayc Sep 4, 2023
814d44e
unit tests
angorayc Sep 5, 2023
f75afdb
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 5, 2023
af66475
Merge branch 'main' into edit-mode
angorayc Sep 6, 2023
b53836d
update bundle size
angorayc Sep 7, 2023
5b0d8ac
Merge branch 'main' into edit-mode
angorayc Sep 7, 2023
431aef1
Merge branch 'main' into edit-mode
angorayc Sep 7, 2023
166aa08
Merge branch 'main' into edit-mode
angorayc Sep 7, 2023
bfe13da
Merge branch 'main' into edit-mode
angorayc Sep 7, 2023
c2394c2
serverless breadcrumb
angorayc Sep 7, 2023
4142d0b
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 7, 2023
39bc769
Merge branch 'main' into edit-mode
angorayc Sep 8, 2023
f3ad2df
fix flaky cypress tests
angorayc Sep 8, 2023
1fb58e5
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 8, 2023
ea44fc5
Merge branch 'main' into edit-mode
angorayc Sep 8, 2023
4dda0c6
dashboard tags
angorayc Sep 13, 2023
b71ca7d
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 13, 2023
c380c3b
update css
angorayc Sep 13, 2023
61c8b57
fix return from map
angorayc Sep 13, 2023
33d31dd
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 13, 2023
b710595
rm originalApp and originalPath from DashboardTopNav
angorayc Sep 13, 2023
88eb719
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 13, 2023
51218f5
Merge branch 'main' into edit-mode
angorayc Sep 14, 2023
7e9f488
Merge branch 'main' into edit-mode
angorayc Sep 18, 2023
417bc2f
Merge branch 'main' into edit-mode
angorayc Sep 18, 2023
1be6482
add badges and remove align right
angorayc Sep 19, 2023
2fa6ebb
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 19, 2023
68ce921
Merge branch 'main' into edit-mode
angorayc Sep 21, 2023
fb81162
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 21, 2023
cff552b
i18n
angorayc Sep 21, 2023
1ff57f4
i18n
angorayc Sep 21, 2023
fc62f31
fix tags
angorayc Sep 21, 2023
81991a1
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 21, 2023
b09ca64
Merge branch 'main' into edit-mode
angorayc Sep 22, 2023
cad9a11
Merge branch 'main' into edit-mode
angorayc Sep 22, 2023
9786e0c
Merge branch 'main' into edit-mode
angorayc Sep 22, 2023
61d31d3
Merge branch 'main' into edit-mode
angorayc Sep 25, 2023
c9d61f0
get managed info from dashboard state
angorayc Sep 25, 2023
0008540
align managed tag behaviour with kibana dashboard
angorayc Sep 25, 2023
86bc355
revert unnecessary changes
angorayc Sep 26, 2023
f5afe7c
align dashboard tool bar styles with kibana dashboard
angorayc Sep 26, 2023
82aa6f4
revert style changes
angorayc Sep 26, 2023
b1a6085
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 27, 2023
2d10a03
fix header actions
angorayc Sep 27, 2023
57d1743
fix create Lens from empty panel
angorayc Sep 27, 2023
17b5171
unit tests
angorayc Sep 27, 2023
f4e579c
Merge branch 'main' into edit-mode
angorayc Sep 27, 2023
54e9958
clean up DashboardEmbedSettings
angorayc Sep 29, 2023
e79290a
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 29, 2023
8de11cd
fix tool bar
angorayc Sep 29, 2023
89b5987
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 29, 2023
e901852
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 29, 2023
dfd70c0
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 29, 2023
de3cbdb
remove unused import
angorayc Sep 29, 2023
5dd3ce1
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 29, 2023
3a6cb1d
remove originateApp from top nav
angorayc Sep 29, 2023
2d461d8
Merge branch 'main' into edit-mode
angorayc Sep 29, 2023
eebbd69
hide reset change from actions
angorayc Sep 29, 2023
f8d9cfc
hide reset change from actions
angorayc Sep 29, 2023
9032024
types
angorayc Sep 29, 2023
3402568
Update x-pack/plugins/security_solution/public/dashboards/components/…
angorayc Sep 29, 2023
f4af650
review
angorayc Sep 29, 2023
61a2f32
Merge branch 'edit-mode' of github.com:angorayc/kibana into edit-mode
angorayc Sep 29, 2023
6b06b87
review
angorayc Sep 29, 2023
8c660ca
Merge branch 'main' of github.com:elastic/kibana into edit-mode
angorayc Sep 29, 2023
a779e84
review changes
angorayc Sep 29, 2023
9660eed
Update x-pack/plugins/security_solution/public/dashboards/components/…
angorayc Sep 29, 2023
78b2587
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 29, 2023
82b7438
remove unused import
angorayc Sep 29, 2023
4ca438d
review
angorayc Sep 29, 2023
05ec497
fix unit tests
angorayc Sep 29, 2023
237a1aa
fix types
angorayc Sep 29, 2023
738b4e9
rename embeddable container context to embeddable app context. Use it…
ThomThomson Sep 29, 2023
528600a
Merge remote-tracking branch 'angorayc/edit-mode' into edit-mode
ThomThomson Sep 29, 2023
3b863c1
Merge pull request #4 from ThomThomson/security/edit-mode/appContext
angorayc Sep 29, 2023
017927c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 29, 2023
5fb8252
add forceHideUnifiedSearch
angorayc Sep 29, 2023
5ae45d6
fix tests
angorayc Sep 29, 2023
a368344
fix types
angorayc Sep 29, 2023
2da03b1
Merge branch 'main' into edit-mode
angorayc Oct 1, 2023
3348b38
unit tests
angorayc Oct 2, 2023
2c8113e
review
angorayc Oct 2, 2023
e9cc346
revert dashboard container renderer
angorayc Oct 2, 2023
0083b75
remove ref
angorayc Oct 2, 2023
61bf111
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 2, 2023
6716411
Merge branch 'main' into edit-mode
kibanamachine Oct 2, 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
10 changes: 6 additions & 4 deletions src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import { DashboardAPI, DashboardRenderer } from '..';
import { type DashboardEmbedSettings } from './types';
import { DASHBOARD_APP_ID } from '../dashboard_constants';
import { pluginServices } from '../services/plugin_services';
import { DashboardTopNav } from './top_nav/dashboard_top_nav';
import { AwaitingDashboardAPI } from '../dashboard_container';
import { DashboardRedirect } from '../dashboard_container/types';
import { useDashboardMountContext } from './hooks/dashboard_mount_context';
import { useDashboardOutcomeValidation } from './hooks/use_dashboard_outcome_validation';
import { loadDashboardHistoryLocationState } from './locator/load_dashboard_history_location_state';
import type { DashboardCreationOptions } from '../dashboard_container/embeddable/dashboard_container_factory';
import { DashboardTopNav } from '../dashboard_top_nav';

export interface DashboardAppProps {
history: History;
Expand Down Expand Up @@ -192,9 +192,11 @@ export function DashboardApp({
{!showNoDataPage && (
<>
{dashboardAPI && (
<DashboardAPIContext.Provider value={dashboardAPI}>
<DashboardTopNav redirectTo={redirectTo} embedSettings={embedSettings} />
</DashboardAPIContext.Provider>
<DashboardTopNav
redirectTo={redirectTo}
embedSettings={embedSettings}
dashboardContainer={dashboardAPI}
/>
)}

{getLegacyConflictWarning?.()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export async function mountApp({ core, element, appUnMounted, mountContext }: Da
): DashboardEmbedSettings | undefined => {
return {
forceShowTopNavMenu: routeParams[dashboardUrlParams.showTopMenu] === 'true',
forceShowQueryInput: routeParams[dashboardUrlParams.showQueryInput] === 'true',
forceShowDatePicker: routeParams[dashboardUrlParams.showTimeFilter] === 'true',
showQueryInput: routeParams[dashboardUrlParams.showQueryInput] === 'true',
showDatePicker: routeParams[dashboardUrlParams.showTimeFilter] === 'true',
forceHideFilterBar: routeParams[dashboardUrlParams.hideFilterBar] === 'true',
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import { css } from '@emotion/react';
import React, { useCallback } from 'react';
import { css, SerializedStyles } from '@emotion/react';
import React, { useCallback, useMemo } from 'react';
import { METRIC_TYPE } from '@kbn/analytics';
import { useEuiTheme } from '@elastic/eui';

Expand All @@ -23,7 +23,15 @@ import { ControlsToolbarButton } from './controls_toolbar_button';
import { DASHBOARD_APP_ID, DASHBOARD_UI_METRIC_ID } from '../../dashboard_constants';
import { dashboardReplacePanelActionStrings } from '../../dashboard_actions/_dashboard_actions_strings';

export function DashboardEditingToolbar() {
export function DashboardEditingToolbar({
wrapperCss,
originatingApp = DASHBOARD_APP_ID,
originatingPath,
}: {
wrapperCss?: SerializedStyles;
originatingApp?: string;
originatingPath?: string;
}) {
const {
usageCollection,
data: { search },
Expand Down Expand Up @@ -69,12 +77,13 @@ export function DashboardEditingToolbar() {
stateTransferService.navigateToEditor(appId, {
path,
state: {
originatingApp: DASHBOARD_APP_ID,
originatingApp,
originatingPath,
searchSessionId: search.session.getSessionId(),
},
});
},
[stateTransferService, search.session, trackUiMetric]
[stateTransferService, originatingApp, originatingPath, search.session, trackUiMetric]
);

const createNewEmbeddable = useCallback(
Expand Down Expand Up @@ -117,12 +126,17 @@ export function DashboardEditingToolbar() {
extraButtons.push(<ControlsToolbarButton controlGroup={dashboard.controlGroup} />);
}

const wrapperStyles = useMemo(
() =>
css({
padding: `0 ${euiTheme.size.s} ${euiTheme.size.s} ${euiTheme.size.s}`,
...(wrapperCss ?? {}),
}),
[euiTheme.size.s, wrapperCss]
);

return (
<div
css={css`
padding: 0 ${euiTheme.size.s} ${euiTheme.size.s} ${euiTheme.size.s};
`}
>
<div css={wrapperStyles}>
<Toolbar>
{{
primaryButton: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export const useDashboardMenuItems = ({
redirectTo,
isLabsShown,
setIsLabsShown,
showFullScreenButton = true,
}: {
redirectTo: DashboardRedirect;
isLabsShown: boolean;
setIsLabsShown: Dispatch<SetStateAction<boolean>>;
showFullScreenButton?: boolean;
}) => {
const [isSaveInProgress, setIsSaveInProgress] = useState(false);

Expand Down Expand Up @@ -263,18 +265,30 @@ export const useDashboardMenuItems = ({
*/
const viewModeTopNavConfig = useMemo(() => {
const labsMenuItem = isLabsEnabled ? [menuItems.labs] : [];
const fullScreenMenuItem = showFullScreenButton ? [menuItems.fullScreen] : [];
angorayc marked this conversation as resolved.
Show resolved Hide resolved
const shareMenuItem = share ? [menuItems.share] : [];
const cloneMenuItem = showWriteControls ? [menuItems.clone] : [];
const editMenuItem = showWriteControls ? [menuItems.edit] : [];
return [
...labsMenuItem,
menuItems.fullScreen,
...fullScreenMenuItem,
...shareMenuItem,
...cloneMenuItem,
resetChangesMenuItem,
...editMenuItem,
];
}, [menuItems, share, showWriteControls, resetChangesMenuItem, isLabsEnabled]);
}, [
isLabsEnabled,
menuItems.labs,
menuItems.fullScreen,
menuItems.share,
menuItems.clone,
menuItems.edit,
showFullScreenButton,
share,
showWriteControls,
resetChangesMenuItem,
]);

const editModeTopNavConfig = useMemo(() => {
const labsMenuItem = isLabsEnabled ? [menuItems.labs] : [];
Expand Down
13 changes: 11 additions & 2 deletions src/plugins/dashboard/public/dashboard_app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
* Side Public License, v 1.
*/

import { SerializedStyles } from '@emotion/react';
import { AppMountParameters, ScopedHistory } from '@kbn/core-application-browser';

export interface DashboardEmbedSettings {
forceHideDatePicker?: boolean;
forceHideFilterBar?: boolean;
forceHideQueryInput?: boolean;
forceShowTopNavMenu?: boolean;
forceShowQueryInput?: boolean;
forceShowDatePicker?: boolean;
showQueryInput?: boolean;
showDatePicker?: boolean;
showBorderBottom?: boolean;
showBackgroundColor?: boolean;
showFullScreenButton?: boolean;
editingToolBarCss?: SerializedStyles;
topNavMenuAlignRight?: boolean;
showStickyTopNav?: boolean;
}

export interface DashboardMountContextProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@

@mixin getBackgroundColor($showBackgroundColor: true) {
@if $showBackgroundColor {
background: $euiPageBackgroundColor;
angorayc marked this conversation as resolved.
Show resolved Hide resolved

} @else {
background: transparent;
}
}

.kbnBody {
.dashboardTopNav {
width: 100%;
position: sticky;
z-index: $euiZLevel2;
background: $euiPageBackgroundColor;

@include getBackgroundColor($showBackgroundColor: true);

&-right {
text-align: right;
}

&.dashboardTopNav-noBackgroundColor {
@include getBackgroundColor($showBackgroundColor: false);
}

&.dashboardTopNav-noSticky {
position: static;
}
}

&.kbnBody--noHeaderBanner {
Expand All @@ -23,4 +46,4 @@
top: $kbnHeaderBannerHeight;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 from 'react';
import { DashboardAPIContext } from '../dashboard_app/dashboard_app';
import { DashboardContainer } from '../dashboard_container';
import {
InternalDashboardTopNav,
InternalDashboardTopNavProps,
} from './internal_dashboard_top_nav';
export interface DashboardTopNavProps extends InternalDashboardTopNavProps {
dashboardContainer: DashboardContainer;
}

export const DashboardTopNavWithContext = (props: DashboardTopNavProps) => (
<DashboardAPIContext.Provider value={props.dashboardContainer}>
<InternalDashboardTopNav {...props} />
</DashboardAPIContext.Provider>
);

// eslint-disable-next-line import/no-default-export
export default DashboardTopNavWithContext;
29 changes: 29 additions & 0 deletions src/plugins/dashboard/public/dashboard_top_nav/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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, { Suspense } from 'react';
import { servicesReady } from '../plugin';
import { DashboardTopNavProps } from './dashboard_top_nav_with_context';

const LazyDashboardTopNav = React.lazy(() =>
(async () => {
const modulePromise = import('./dashboard_top_nav_with_context');
const [module] = await Promise.all([modulePromise, servicesReady]);

return {
default: module.DashboardTopNavWithContext,
};
})().then((module) => module)
);

export const DashboardTopNav = (props: DashboardTopNavProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice call exporting the top nav + its lazy wrapper like this 🔥

return (
<Suspense fallback={<div />}>
<LazyDashboardTopNav {...props} />
</Suspense>
);
};
Loading