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

Added stubbed bottom bar… #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
width: 100%;
position: fixed;
top: 0;
z-index: 10;
z-index: $euiZHeader;
}

.chrHeaderWrapper ~ .app-wrapper:not(.hidden-chrome) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/public/chrome/ui/header/header_wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import React, { FunctionComponent, useState } from 'react';
import classnames from 'classnames';
import { Header, HeaderProps } from './';

const IS_LOCKED_KEY = 'core.chrome.isLocked';
export const IS_NAV_LOCKED_KEY = 'core.chrome.isLocked';

export const HeaderWrapper: FunctionComponent<HeaderProps> = props => {
const initialIsLocked = localStorage.getItem(IS_LOCKED_KEY);
const initialIsLocked = localStorage.getItem(IS_NAV_LOCKED_KEY);
const [isLocked, setIsLocked] = useState(initialIsLocked === 'true');
const setIsLockedStored = (locked: boolean) => {
localStorage.setItem(IS_LOCKED_KEY, `${locked}`);
localStorage.setItem(IS_NAV_LOCKED_KEY, `${locked}`);
setIsLocked(locked);
};
const className = classnames(
Expand Down
16 changes: 16 additions & 0 deletions x-pack/legacy/plugins/lens/public/app_plugin/_app.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import '@elastic/eui/src/components/header/variables';
@import '@elastic/eui/src/components/nav_drawer/variables';

.lnsApp {
position: absolute;
top: 0;
Expand All @@ -10,6 +13,10 @@
overflow: hidden;
}

.lnsApp-bottomBarShowing {
padding-bottom: $euiSizeL * 2;
}

.lnsApp__header {
padding: $euiSize;
border-bottom: $euiBorderThin;
Expand All @@ -21,3 +28,12 @@
flex-direction: column;
flex-grow: 1;
}

.lnsApp__bottomBar {
left: $euiNavDrawerWidthCollapsed;
z-index: $euiZHeader + 10;
}

.lnsApp__bottomBar-navIsLockedOpen {
left: $euiNavDrawerWidthExpanded;
}
139 changes: 96 additions & 43 deletions x-pack/legacy/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@

import _ from 'lodash';
import React, { useState, useEffect, useCallback, useRef } from 'react';
import classNames from 'classnames';
import { I18nProvider } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import {
EuiLink,
EuiFlexGroup,
EuiFlexItem,
EuiBottomBar,
EuiButton,
EuiButtonEmpty,
EuiPopover,
EuiFormRow,
EuiFieldText,
} from '@elastic/eui';
import { Storage } from 'ui/storage';
import { CoreStart } from 'src/core/public';
import { Query } from '../../../../../../src/legacy/core_plugins/data/public';
Expand Down Expand Up @@ -64,10 +75,13 @@ export function App({
docStorage: SavedObjectStore;
redirectTo: (id?: string) => void;
}) {
const chromeNavIsLockedOpen = localStorage.getItem('core.chrome.isLocked');
const timeDefaults = core.uiSettings.get('timepicker:timeDefaults');
const language =
store.get('kibana.userQueryLanguage') || core.uiSettings.get('search:queryLanguage');

const [isTitlePopoverOpen, setIsTitlePopoverOpen] = useState(false);

const [state, setState] = useState<State>({
isLoading: !!docId,
isDirty: false,
Expand Down Expand Up @@ -152,6 +166,14 @@ export function App({
[]
);

const classes = classNames('lnsApp', {
'lnsApp-bottomBarShowing': isSaveable,
});

const bottomBarClasses = classNames('lnsApp__bottomBar', {
'lnsApp__bottomBar-navIsLockedOpen': chromeNavIsLockedOpen === 'true',
});

return (
<I18nProvider>
<KibanaContextProvider
Expand All @@ -162,49 +184,8 @@ export function App({
http: core.http,
}}
>
<div className="lnsApp">
<div className={classes}>
<div className="lnsApp__header">
<nav>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiLink
data-test-subj="lnsApp_saveButton"
onClick={() => {
if (isSaveable && lastKnownDocRef.current) {
docStorage
.save(lastKnownDocRef.current)
.then(({ id }) => {
// Prevents unnecessary network request and disables save button
const newDoc = { ...lastKnownDocRef.current!, id };
setState({
...state,
isDirty: false,
persistedDoc: newDoc,
});
if (docId !== id) {
redirectTo(id);
}
})
.catch(reason => {
core.notifications.toasts.addDanger(
i18n.translate('xpack.lens.editorFrame.docSavingError', {
defaultMessage: 'Error saving document {reason}',
values: { reason },
})
);
});
}
}}
color={isSaveable ? 'primary' : 'subdued'}
disabled={!isSaveable}
>
{i18n.translate('xpack.lens.editorFrame.save', {
defaultMessage: 'Save',
})}
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
</nav>
<QueryBarTopRow
data-test-subj="lnsApp_queryBar"
screenTitle={'lens'}
Expand Down Expand Up @@ -267,6 +248,78 @@ export function App({
/>
)}
</div>

{isSaveable && (
<EuiBottomBar className={bottomBarClasses} paddingSize="s">
<EuiFlexGroup gutterSize="s" justifyContent="spaceBetween" alignItems="center">
<EuiFlexItem grow={false}>
<EuiPopover
button={
<EuiButtonEmpty
color="ghost"
size="s"
iconType="pencil"
iconSide="right"
onClick={() => setIsTitlePopoverOpen(!isTitlePopoverOpen)}
>
Untitled
</EuiButtonEmpty>
}
isOpen={isTitlePopoverOpen}
closePopover={() => setIsTitlePopoverOpen(false)}
panelPaddingSize="s"
ownFocus
>
<div>
<EuiFormRow display="rowCompressed" label="Visualization name">
<EuiFieldText compressed />
</EuiFormRow>
</div>
</EuiPopover>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="lnsApp_saveButton"
color="primary"
fill
size="s"
iconType="save"
disabled={!isSaveable}
onClick={() => {
if (isSaveable && lastKnownDocRef.current) {
docStorage
.save(lastKnownDocRef.current)
.then(({ id }) => {
// Prevents unnecessary network request and disables save button
const newDoc = { ...lastKnownDocRef.current!, id };
setState({
...state,
isDirty: false,
persistedDoc: newDoc,
});
if (docId !== id) {
redirectTo(id);
}
})
.catch(reason => {
core.notifications.toasts.addDanger(
i18n.translate('xpack.lens.editorFrame.docSavingError', {
defaultMessage: 'Error saving document {reason}',
values: { reason },
})
);
});
}
}}
>
{i18n.translate('xpack.lens.editorFrame.save', {
defaultMessage: 'Save changes',
})}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiBottomBar>
)}
</KibanaContextProvider>
</I18nProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ describe('editor_frame', () => {
query: { query: '', language: 'lucene' },
filters: [],
},
title: 'New visualization',
title: 'Untitled',
type: 'lens',
visualizationType: 'testVis',
},
Expand All @@ -1521,7 +1521,7 @@ describe('editor_frame', () => {
query: { query: '', language: 'lucene' },
filters: [],
},
title: 'New visualization',
title: 'Untitled',
type: 'lens',
visualizationType: 'testVis',
},
Expand Down Expand Up @@ -1578,7 +1578,7 @@ describe('editor_frame', () => {
query: { query: 'new query', language: 'lucene' },
filters: [],
},
title: 'New visualization',
title: 'Untitled',
type: 'lens',
visualizationType: 'testVis',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const getInitialState = (props: EditorFrameProps): EditorFrameState => {
}

return {
title: i18n.translate('xpack.lens.chartTitle', { defaultMessage: 'New visualization' }),
title: i18n.translate('xpack.lens.chartTitle', { defaultMessage: 'Untitled' }),
datasourceStates,
activeDatasourceId: getInitialDatasourceId(props),
visualization: {
Expand Down