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

Account for presence of top banner when EuiDataGrid and Canvas are full screen #111038

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
6 changes: 6 additions & 0 deletions src/core/public/rendering/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@

&.kbnBody--hasHeaderBanner {
@include kbnAffordForHeader($kbnHeaderOffsetWithBanner);

// Prevents banners from covering full screen data grids
.euiDataGrid--fullScreen {
height: calc(100vh - #{$kbnHeaderBannerHeight});
top: $kbnHeaderBannerHeight;
}
}
&.kbnBody--chromeHidden {
@include kbnAffordForHeader(0);
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/canvas/common/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ export const CANVAS_EMBEDDABLE_CLASSNAME = `canvasEmbeddable`;
export const CONTEXT_MENU_TOP_BORDER_CLASSNAME = 'canvasContextMenu--topBorder';
export const API_ROUTE_FUNCTIONS = `${API_ROUTE}/fns`;
export const ESSQL_SEARCH_STRATEGY = 'essql';
export const HEADER_BANNER_HEIGHT = 32;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: This is number can easily get out sync between the JS and Sass versions. I'd highly suggest moving it a constant that lives within the actual banner service and imported by Canvas. Then in both places (JS & CSS), add a comment that mentions where it's counterpart lives. Something like:

Suggested change
export const HEADER_BANNER_HEIGHT = 32;
export const HEADER_BANNER_HEIGHT = 32; // This value also declared in Sass file `.../path/to/_bases.css`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pgayvallet: Thoughts on Caroline's suggestion above to move the banner height to live in the banner service? Sounds good to me, but would likely need your guidance on how best to implement.

Copy link
Contributor

@pgayvallet pgayvallet Sep 9, 2021

Choose a reason for hiding this comment

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

It definitely makes sense, but I think this can be done by my team as a follow-up (if that's fine with you). I created #111688

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. In the mean time, I'll add those suggested comments in the current variable locations.

7 changes: 7 additions & 0 deletions x-pack/plugins/canvas/public/components/workpad/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, { useContext, useCallback } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { pure, compose, withState, withProps, getContext, withHandlers } from 'recompose';
import useObservable from 'react-use/lib/useObservable';
import { transitionsRegistry } from '../../lib/transitions_registry';
import { fetchAllRenderables } from '../../state/actions/elements';
import { setZoomScale } from '../../state/actions/transient';
Expand All @@ -22,6 +23,7 @@ import { zoomHandlerCreators } from '../../lib/app_handler_creators';
import { trackCanvasUiMetric, METRIC_TYPE } from '../../lib/ui_metric';
import { LAUNCHED_FULLSCREEN, LAUNCHED_FULLSCREEN_AUTOPLAY } from '../../../common/lib/constants';
import { WorkpadRoutingContext } from '../../routes/workpad';
import { usePlatformService } from '../../services';
import { Workpad as WorkpadComponent } from './workpad';

const mapStateToProps = (state) => {
Expand Down Expand Up @@ -57,6 +59,10 @@ const AddContexts = (props) => {
WorkpadRoutingContext
);

const platformService = usePlatformService();

const hasHeaderBanner = useObservable(platformService.hasHeaderBanner$());

const setFullscreenWithEffect = useCallback(
(fullscreen) => {
setFullscreen(fullscreen);
Expand All @@ -79,6 +85,7 @@ const AddContexts = (props) => {
isFullscreen={isFullscreen}
undoHistory={undo}
redoHistory={redo}
hasHeaderBanner={hasHeaderBanner}
/>
);
};
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/canvas/public/components/workpad/workpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Style from 'style-it';
import { WorkpadPage } from '../workpad_page';
import { Fullscreen } from '../fullscreen';
import { isTextInput } from '../../lib/is_text_input';
import { WORKPAD_CANVAS_BUFFER } from '../../../common/lib/constants';
import { HEADER_BANNER_HEIGHT, WORKPAD_CANVAS_BUFFER } from '../../../common/lib/constants';

export class Workpad extends React.PureComponent {
static propTypes = {
Expand All @@ -37,6 +37,7 @@ export class Workpad extends React.PureComponent {
zoomIn: PropTypes.func.isRequired,
zoomOut: PropTypes.func.isRequired,
resetZoom: PropTypes.func.isRequired,
hasHeaderBanner: PropTypes.bool,
};

_toggleFullscreen = () => {
Expand Down Expand Up @@ -80,13 +81,16 @@ export class Workpad extends React.PureComponent {
registerLayout,
unregisterLayout,
zoomScale,
hasHeaderBanner = false,
} = this.props;

const bufferStyle = {
height: isFullscreen ? height : (height + 2 * WORKPAD_CANVAS_BUFFER) * zoomScale,
width: isFullscreen ? width : (width + 2 * WORKPAD_CANVAS_BUFFER) * zoomScale,
};

const headerBannerOffset = hasHeaderBanner ? HEADER_BANNER_HEIGHT : 0;

return (
<div className="canvasWorkpad__buffer" style={bufferStyle}>
<div
Expand All @@ -104,14 +108,19 @@ export class Workpad extends React.PureComponent {

<Fullscreen>
{({ isFullscreen, windowSize }) => {
const scale = Math.min(windowSize.height / height, windowSize.width / width);
const scale = Math.min(
(windowSize.height - headerBannerOffset) / height,
windowSize.width / width
);

const fsStyle = isFullscreen
? {
transform: `scale3d(${scale}, ${scale}, 1)`,
WebkitTransform: `scale3d(${scale}, ${scale}, 1)`,
msTransform: `scale3d(${scale}, ${scale}, 1)`,
height: windowSize.height < height ? 'auto' : height,
width: windowSize.width < width ? 'auto' : width,
top: hasHeaderBanner ? `${headerBannerOffset / 2}px` : undefined,
}
: {};

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/canvas/public/services/kibana/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const platformServiceFactory: CanvaPlatformServiceFactory = ({ coreStart,
// though we don't do this. So this cast may be the best option.
getHasWriteAccess: () => coreStart.application.capabilities.canvas.save as boolean,
getUISetting: coreStart.uiSettings.get.bind(coreStart.uiSettings),
hasHeaderBanner$: coreStart.chrome.hasHeaderBanner$,
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
setRecentlyAccessed: coreStart.chrome.recentlyAccessed.add,
setFullscreen: coreStart.chrome.setIsVisible,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/canvas/public/services/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { Observable } from 'rxjs';
import {
SavedObjectsStart,
SavedObjectsClientContract,
Expand All @@ -22,6 +23,7 @@ export interface CanvasPlatformService {
getKibanaVersion: () => string;
getHasWriteAccess: () => boolean;
getUISetting: (key: string, defaultValue?: any) => any;
hasHeaderBanner$: () => Observable<boolean>;
setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void;
setRecentlyAccessed: (link: string, label: string, id: string) => void;
setFullscreen: ChromeStart['setIsVisible'];
Expand Down