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

[Dashboard] Deangularize navbar, attempt nr. 2 #61611

Merged
merged 64 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
03336a7
Attempt at deangularization, nr.2
Mar 27, 2020
797c0fc
Remove padding in fullscreen
Mar 27, 2020
33ea01c
Fixing failing functional test
Mar 30, 2020
9b4a28c
Fixing remaining functional test
Mar 31, 2020
ca84abc
Fixing typescript errors
Apr 1, 2020
687f193
Fixing filter bar not being visible in fullscreen
Apr 3, 2020
ef77d2e
Fixing filter bar not being visible in fullscreen
Apr 3, 2020
fb33274
Rebasing against master
Apr 7, 2020
9026945
Fixing a small leftover
Apr 7, 2020
477f4d1
Fix order of functions
Apr 7, 2020
a081dd2
Fixing linting error
Apr 7, 2020
198affa
Merge branch 'master' into deangularize-navbar-2
elasticmachine Apr 7, 2020
c106db9
Merge branch 'master' into deangularize-navbar-2
elasticmachine Apr 10, 2020
ff6504f
Merge branch 'master' into deangularize-navbar-2
elasticmachine Apr 12, 2020
778358f
Changing noPadding to a custom class
Apr 14, 2020
6844e0d
Use filterManagers to handle filters
Apr 14, 2020
38fd2ca
Rename class
Apr 14, 2020
5a90798
Attempt at deangularization, nr.2
Mar 27, 2020
271c193
Remove padding in fullscreen
Mar 27, 2020
46b8486
Fixing failing functional test
Mar 30, 2020
556b2e1
Fixing remaining functional test
Mar 31, 2020
e69dcce
Fixing typescript errors
Apr 1, 2020
8f96c19
Fixing filter bar not being visible in fullscreen
Apr 3, 2020
d1a0467
Fixing filter bar not being visible in fullscreen
Apr 3, 2020
debf3fa
Rebasing against master
Apr 7, 2020
bee3768
Fixing a small leftover
Apr 7, 2020
1894e58
Fix order of functions
Apr 7, 2020
5033678
Fixing linting error
Apr 7, 2020
8acefd6
[APM] Agent config select box doesn't work on IE (#63236)
cauemarcondes Apr 10, 2020
b0f2ba6
Use globe icon for "ext" span type on service map (#63205)
smith Apr 10, 2020
910e2b8
Move shared vislib components into Charts plugin (#62957)
DianaDerevyankina Apr 10, 2020
19fc959
Make uptime alert flyout test a little more resilient (#62702)
brianseeders Apr 10, 2020
bc26037
[SIEM] [Cases] Unit tests for case UI components (#63005)
stephmilovic Apr 10, 2020
1e66805
Endpoint: Remove unused `lib` module (#63248)
Apr 10, 2020
b38b2cb
[Lens] Fix error in query from generated suggestion (#63018)
Apr 10, 2020
a4ac154
Resolver/node svg 2 html (#62958)
bkimmel Apr 10, 2020
734513c
[Reporting] convert all server unit tests to TypeScript (#62873)
tsullivan Apr 10, 2020
b5f8664
[SIEM] Link ML Rule card CTA to license_management (#63210)
rylnd Apr 10, 2020
ae22596
Correctly type ILM's optional dependencies as optional (#63255)
cjcenizal Apr 10, 2020
192ad72
[Telemetry] use prod keys (#63263)
Bamieh Apr 10, 2020
64cf730
update chromedriver dependency to 81.0.0 (#63266)
dmlemeshko Apr 10, 2020
05c55ec
task/mac-eventing-form (#62999)
parkiino Apr 10, 2020
39c491e
bc6 rule import april 9 (#63152)
randomuserid Apr 10, 2020
9e5fb5e
Added UI for pre-configured connectors. (#63074)
YulNaumenko Apr 10, 2020
5eb6610
TaskManager tasks scheduled without attempting to run (#62078)
kobelb Apr 10, 2020
96e4749
Changed alerting wrong param name for help xpack.encrypted_saved_obje…
YulNaumenko Apr 11, 2020
c63933a
fix ScopedHistory.createHref to prepend location with scoped history …
pgayvallet Apr 11, 2020
adf38e0
fixing custom link popover size and hiding scroll (#63240)
cauemarcondes Apr 11, 2020
4827dbf
Changing noPadding to a custom class
Apr 14, 2020
8161d30
Use filterManagers to handle filters
Apr 14, 2020
a2abe6d
Rename class
Apr 14, 2020
537131c
Applying some changes
Apr 16, 2020
9bb8355
UseDefaultBehaviors in dashboard app controller
Apr 16, 2020
bca426e
Merge branch 'master' into deangularize-navbar-2
Apr 16, 2020
1be9803
Merge branch 'master' into deangularize-navbar-2
Apr 16, 2020
2edfa15
Reverting search_bar code changes
Apr 16, 2020
8076ed2
Removing some stuff that was causing functional tests to fail
Apr 17, 2020
6b09cee
Merge branch 'master' into deangularize-navbar-2
Apr 17, 2020
5b00872
Removing refresh dashboard container which was causing errors during …
Apr 17, 2020
1b5ac60
Do not destroy dashboardContainer
Apr 18, 2020
f1b5312
Merge branch 'master' into deangularize-navbar-2
elasticmachine Apr 19, 2020
ea48a46
Adding updateSavedQueryId method
Apr 20, 2020
6a751f4
Merge branch 'deangularize-navbar-2' of https://github.com/majagrubic…
Apr 20, 2020
359149c
Merge branch 'master' into deangularize-navbar-2
Apr 20, 2020
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
16 changes: 1 addition & 15 deletions src/plugins/dashboard/public/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ import { EmbeddableStart } from '../../../embeddable/public';
import { NavigationPublicPluginStart as NavigationStart } from '../../../navigation/public';
import { DataPublicPluginStart } from '../../../data/public';
import { SharePluginStart } from '../../../share/public';
import {
KibanaLegacyStart,
configureAppAngularModule,
createTopNavDirective,
createTopNavHelper,
} from '../../../kibana_legacy/public';
import { KibanaLegacyStart, configureAppAngularModule } from '../../../kibana_legacy/public';
import { SavedObjectLoader } from '../../../saved_objects/public';

export interface RenderDeps {
Expand Down Expand Up @@ -114,13 +109,11 @@ function mountDashboardApp(appBasePath: string, element: HTMLElement) {

function createLocalAngularModule(core: AppMountContext['core'], navigation: NavigationStart) {
createLocalI18nModule();
createLocalTopNavModule(navigation);
createLocalIconModule();

const dashboardAngularModule = angular.module(moduleName, [
...thirdPartyAngularDependencies,
'app/dashboard/I18n',
'app/dashboard/TopNav',
'app/dashboard/icon',
]);
return dashboardAngularModule;
Expand All @@ -132,13 +125,6 @@ function createLocalIconModule() {
.directive('icon', reactDirective => reactDirective(EuiIcon));
}

function createLocalTopNavModule(navigation: NavigationStart) {
angular
.module('app/dashboard/TopNav', ['react'])
.directive('kbnTopNav', createTopNavDirective)
.directive('kbnTopNavHelper', createTopNavHelper(navigation.ui));
}

function createLocalI18nModule() {
angular
.module('app/dashboard/I18n', [])
Expand Down
47 changes: 1 addition & 46 deletions src/plugins/dashboard/public/application/dashboard_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,7 @@
class="app-container dshAppContainer"
ng-class="{'dshAppContainer--withMargins': model.useMargins}"
>
<!-- Local nav. -->
<kbn-top-nav
ng-show="isVisible"
app-name="'dashboard'"
config="topNavMenu"

show-search-bar="isVisible"
show-filter-bar="showFilterBar()"
show-save-query="showSaveQuery"

query="model.query"
saved-query="savedQuery"
screen-title="screenTitle"
on-query-submit="updateQueryAndFetch"
index-patterns="indexPatterns"
filters="model.filters"
on-filters-updated="onFiltersUpdated"
date-range-from="model.timeRange.from"
date-range-to="model.timeRange.to"
is-refresh-paused="model.refreshInterval.pause"
refresh-interval="model.refreshInterval.value"
on-saved="onQuerySaved"
on-saved-query-updated="onSavedQueryUpdated"
on-clear-saved-query="onClearSavedQuery"
on-refresh-change="onRefreshChange">
</kbn-top-nav>

<!--
The top nav is hidden in embed mode but the filter bar must still be present so
we show the filter bar on its own here if the chrome is not visible.
-->
<kbn-top-nav
ng-if="showFilterBar() && !isVisible"

app-name="'dashboard'"
show-search-bar="true"
show-filter-bar="true"
show-save-query="false"
show-date-picker="false"

filters="model.filters"
index-patterns="indexPatterns"
on-filters-updated="onFiltersUpdated"
>
</kbn-top-nav>

<div id="dashboardChrome"></div>
<h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
<div id="dashboardViewport"></div>

Expand Down
12 changes: 0 additions & 12 deletions src/plugins/dashboard/public/application/dashboard_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { SavedObjectDashboard } from '../saved_dashboards';
export interface DashboardAppScope extends ng.IScope {
dash: SavedObjectDashboard;
appState: DashboardAppState;
screenTitle: string;
model: {
query: Query;
filters: Filter[];
Expand All @@ -54,21 +53,10 @@ export interface DashboardAppScope extends ng.IScope {
getShouldShowEditHelp: () => boolean;
getShouldShowViewHelp: () => boolean;
updateQueryAndFetch: ({ query, dateRange }: { query: Query; dateRange?: TimeRange }) => void;
onRefreshChange: ({
isPaused,
refreshInterval,
}: {
isPaused: boolean;
refreshInterval: any;
}) => void;
onFiltersUpdated: (filters: Filter[]) => void;
onCancelApplyFilters: () => void;
onApplyFilters: (filters: Filter[]) => void;
onQuerySaved: (savedQuery: SavedQuery) => void;
majagrubic marked this conversation as resolved.
Show resolved Hide resolved
onSavedQueryUpdated: (savedQuery: SavedQuery) => void;
onClearSavedQuery: () => void;
topNavMenu: any;
showFilterBar: () => boolean;
showAddPanel: any;
showSaveQuery: boolean;
kbnTopNav: any;
Expand Down
105 changes: 58 additions & 47 deletions src/plugins/dashboard/public/application/dashboard_app_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ import _, { uniq } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EUI_MODAL_CANCEL_BUTTON } from '@elastic/eui';
import React from 'react';
import ReactDOM from 'react-dom';
import angular from 'angular';

import { Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { History } from 'history';
import { SavedObjectSaveOpts } from 'src/plugins/saved_objects/public';
import { NavigationPublicPluginStart as NavigationStart } from 'src/plugins/navigation/public';
import { TimeRange } from 'src/plugins/data/public';
import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen';

import {
Expand Down Expand Up @@ -87,6 +90,7 @@ export interface DashboardAppControllerDependencies extends RenderDeps {
dashboardConfig: KibanaLegacyStart['dashboardConfig'];
history: History;
kbnUrlStateStorage: IKbnUrlStateStorage;
navigation: NavigationStart;
}

export class DashboardAppController {
Expand Down Expand Up @@ -123,10 +127,13 @@ export class DashboardAppController {
history,
kbnUrlStateStorage,
usageCollection,
navigation,
}: DashboardAppControllerDependencies) {
const filterManager = queryService.filterManager;
const queryFilter = filterManager;
const timefilter = queryService.timefilter.timefilter;
let showSearchBar = true;
let showQueryBar = true;

let lastReloadRequestTime = 0;
const dash = ($scope.dash = $route.current.locals.dash);
Expand Down Expand Up @@ -243,6 +250,9 @@ export class DashboardAppController {
}
};

const showFilterBar = () =>
$scope.model.filters.length > 0 || !dashboardStateManager.getFullScreenMode();

const getEmptyScreenProps = (
shouldShowEditHelp: boolean,
isEmptyInReadOnlyMode: boolean
Expand Down Expand Up @@ -310,7 +320,6 @@ export class DashboardAppController {
refreshInterval: timefilter.getRefreshInterval(),
};
$scope.panels = dashboardStateManager.getPanels();
$scope.screenTitle = dashboardStateManager.getTitle();
};

updateState();
Expand Down Expand Up @@ -515,49 +524,12 @@ export class DashboardAppController {
}
};

$scope.onRefreshChange = function({ isPaused, refreshInterval }) {
timefilter.setRefreshInterval({
pause: isPaused,
value: refreshInterval ? refreshInterval : $scope.model.refreshInterval.value,
});
};

$scope.onFiltersUpdated = filters => {
// The filters will automatically be set when the queryFilter emits an update event (see below)
queryFilter.setFilters(filters);
};

$scope.onQuerySaved = savedQuery => {
$scope.onQuerySaved = (savedQuery: SavedQuery) => {
$scope.savedQuery = savedQuery;
};

$scope.onSavedQueryUpdated = savedQuery => {
$scope.savedQuery = { ...savedQuery };
};

$scope.onClearSavedQuery = () => {
delete $scope.savedQuery;
dashboardStateManager.setSavedQueryId(undefined);
dashboardStateManager.applyFilters(
{
query: '',
language:
localStorage.get('kibana.userQueryLanguage') || uiSettings.get('search:queryLanguage'),
},
queryFilter.getGlobalFilters()
);
// Making this method sync broke the updates.
// Temporary fix, until we fix the complex state in this file.
setTimeout(() => {
queryFilter.setFilters(queryFilter.getGlobalFilters());
}, 0);
};

const updateStateFromSavedQuery = (savedQuery: SavedQuery) => {
const savedQueryFilters = savedQuery.attributes.filters || [];
const globalFilters = queryFilter.getGlobalFilters();
const allFilters = [...globalFilters, ...savedQueryFilters];

const allFilters = filterManager.getFilters();
dashboardStateManager.applyFilters(savedQuery.attributes.query, allFilters);
if (savedQuery.attributes.timefilter) {
timefilter.setTime({
Expand Down Expand Up @@ -616,6 +588,36 @@ export class DashboardAppController {
}
);

const getNavBarProps = () => {
const isFullScreenMode = dashboardStateManager.getFullScreenMode();
const screenTitle = dashboardStateManager.getTitle();
return {
appName: 'dashboard',
config: $scope.isVisible ? $scope.topNavMenu : undefined,
className: isFullScreenMode ? 'kbnTopNavMenu-isFullScreen' : undefined,
lizozom marked this conversation as resolved.
Show resolved Hide resolved
screenTitle,
showSearchBar,
showQueryBar,
showFilterBar: showFilterBar(),
indexPatterns: $scope.indexPatterns,
showSaveQuery: $scope.showSaveQuery,
query: $scope.model.query,
savedQuery: $scope.savedQuery,
useDefaultBehaviors: true,
onQuerySubmit: (payload: { dateRange: TimeRange; query?: Query }): void => {
if (!payload.query) {
$scope.updateQueryAndFetch({ query: $scope.model.query, dateRange: payload.dateRange });
} else {
$scope.updateQueryAndFetch({ query: payload.query, dateRange: payload.dateRange });
}
},
};
};
const dashboardNavBar = document.getElementById('dashboardChrome');
const updateNavBar = () => {
ReactDOM.render(<navigation.ui.TopNavMenu {...getNavBarProps()} />, dashboardNavBar);
};

$scope.timefilterSubscriptions$ = new Subscription();

$scope.timefilterSubscriptions$.add(
Expand Down Expand Up @@ -707,6 +709,8 @@ export class DashboardAppController {
revertChangesAndExitEditMode();
}
});

updateNavBar();
};

/**
Expand Down Expand Up @@ -761,9 +765,6 @@ export class DashboardAppController {
});
}

$scope.showFilterBar = () =>
$scope.model.filters.length > 0 || !dashboardStateManager.getFullScreenMode();

$scope.showAddPanel = () => {
dashboardStateManager.setFullScreenMode(false);
/*
Expand All @@ -785,7 +786,11 @@ export class DashboardAppController {
const navActions: {
[key: string]: NavAction;
} = {};
navActions[TopNavIds.FULL_SCREEN] = () => dashboardStateManager.setFullScreenMode(true);
navActions[TopNavIds.FULL_SCREEN] = () => {
dashboardStateManager.setFullScreenMode(true);
showQueryBar = false;
updateNavBar();
};
navActions[TopNavIds.EXIT_EDIT_MODE] = () => onChangeViewMode(ViewMode.VIEW);
navActions[TopNavIds.ENTER_EDIT_MODE] = () => onChangeViewMode(ViewMode.EDIT);
navActions[TopNavIds.SAVE] = () => {
Expand Down Expand Up @@ -858,6 +863,7 @@ export class DashboardAppController {
if ((response as { error: Error }).error) {
dashboardStateManager.setTitle(currentTitle);
}
updateNavBar();
return response;
});
};
Expand Down Expand Up @@ -939,6 +945,9 @@ export class DashboardAppController {
const visibleSubscription = chrome.getIsVisible$().subscribe(isVisible => {
$scope.$evalAsync(() => {
$scope.isVisible = isVisible;
showSearchBar = isVisible || showFilterBar();
showQueryBar = !dashboardStateManager.getFullScreenMode() && isVisible;
updateNavBar();
});
});

Expand All @@ -949,6 +958,11 @@ export class DashboardAppController {
navActions,
dashboardConfig.getHideWriteControls()
);
updateNavBar();
});

$scope.$watch('indexPatterns', () => {
updateNavBar();
});

$scope.$on('$destroy', () => {
Expand All @@ -965,9 +979,6 @@ export class DashboardAppController {
if (outputSubscription) {
outputSubscription.unsubscribe();
}
if (dashboardContainer) {
dashboardContainer.destroy();
Copy link
Contributor

@Dosant Dosant Apr 22, 2020

Choose a reason for hiding this comment

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

@majagrubic, sorry for following up on merged pr.
I wonder if this was moved somewhere or called somewhere else implicitly?

Otherwise it seems like moving between dashboards or navigating between dashboard / discover / visualize without full page reload would cause memory leaks and probably other undesired effects, since subscriptions within container are not cleaned up?

Copy link
Contributor

Choose a reason for hiding this comment

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

I put up this tiny pr: #64154
hope this should address underlying issue. Will see if tests pass 🙏

}
});
}
}
4 changes: 4 additions & 0 deletions src/plugins/navigation/public/top_nav_menu/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
padding: 0 $euiSizeS;
}
}

.kbnTopNavMenu-isFullScreen {
padding: 0;
}
}
13 changes: 13 additions & 0 deletions src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,17 @@ describe('TopNavMenu', () => {
expect(component.find(TOP_NAV_ITEM_SELECTOR).length).toBe(0);
expect(component.find(SEARCH_BAR_SELECTOR).length).toBe(1);
});

it('Should render with a class name', () => {
const component = shallowWithIntl(
<TopNavMenu
appName={'test'}
showSearchBar={true}
data={dataShim as any}
className={'myCoolClass'}
/>
);
expect(component.find('.kbnTopNavMenu').length).toBe(1);
expect(component.find('.myCoolClass').length).toBeTruthy();
});
});
Loading