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

Feat: Workpad Templates #23966

Merged
merged 28 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
736073a
Added workpad manager which contains workpad_loader and workpad_templ…
cqliu1 Oct 6, 2018
d85cc74
Fixed term filter in workpad_templates
cqliu1 Oct 6, 2018
389cc05
design changes
ryankeairns Oct 17, 2018
d6d5681
Removed console logs
cqliu1 Oct 6, 2018
4288492
case insensitive template search
cqliu1 Oct 17, 2018
36db1b9
Case insensitive tag order in popover
cqliu1 Oct 17, 2018
1797076
Merge branch 'master' into feat/workpad-templates
cqliu1 Oct 18, 2018
8d526c8
Merge branch 'master' into feat/workpad-templates
cqliu1 Oct 19, 2018
9b4e6f1
added descriptions and tags to sample data workpads
cqliu1 Oct 19, 2018
520f742
refine list of initial templates
ryankeairns Oct 22, 2018
2159cc8
Merge branch 'master' into feat/workpad-templates
cqliu1 Oct 23, 2018
6aec3b1
remove sample data templates, make buttons bigger
ryankeairns Oct 23, 2018
227ce5d
Merge branch 'master' into feat/workpad-templates
cqliu1 Oct 26, 2018
69ccf9a
Merge branch 'master' into feat/workpad-templates
cqliu1 Oct 26, 2018
a262458
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 12, 2018
e820fd5
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 14, 2018
499bbab
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 19, 2018
2b3bacb
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 20, 2018
b8d49d8
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 21, 2018
61626ee
Added template and tag registries
cqliu1 Nov 21, 2018
54ce70d
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 21, 2018
e0d452d
Fixed workpad loader resizing issue on home page
cqliu1 Nov 21, 2018
8bddc57
Merge branch 'master' into feat/workpad-templates
cqliu1 Nov 22, 2018
282eb42
Merge branch 'master' into feat/workpad-templates
cqliu1 Dec 7, 2018
fe2b098
Merge branch 'master' into feat/workpad-templates
cqliu1 Dec 7, 2018
c8796c9
Moved tags to ui folder
cqliu1 Dec 7, 2018
5c9f6a6
Fixed template class
cqliu1 Dec 7, 2018
6f0e0ce
Fixed properties in templates to match workpad
cqliu1 Dec 7, 2018
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: 2 additions & 0 deletions packages/kbn-interpreter/src/server/plugin_paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ export const pluginPaths = {
modelUIs: ['uis', 'models'],
viewUIs: ['uis', 'views'],
argumentUIs: ['uis', 'arguments'],
templates: ['templates'],
tagUIs: ['uis', 'tags'],
};
11 changes: 11 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

const themeDark = require('./theme_dark.json');
const themeLight = require('./theme_light.json');

// Registry expects a function that returns a spec object
export const templateSpecs = [themeDark, themeLight].map(template => () => template);
10 changes: 10 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/templates/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import 'babel-polyfill';
import { templateSpecs } from './index';

templateSpecs.forEach(canvas.register);
335 changes: 335 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/templates/theme_dark.json

Large diffs are not rendered by default.

342 changes: 342 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/templates/theme_light.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/uis/tags/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { presentation } from './presentation';

// Registry expects a function that returns a spec object
export const tagSpecs = [presentation];
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const presentation = () => ({ name: 'presentation', color: '#1EA593' });
10 changes: 10 additions & 0 deletions x-pack/plugins/canvas/canvas_plugin_src/uis/tags/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import 'babel-polyfill';
import { tagSpecs } from './index';

tagSpecs.forEach(canvas.register);
12 changes: 8 additions & 4 deletions x-pack/plugins/canvas/public/apps/home/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

import React from 'react';
import { EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui';
import { WorkpadLoader } from '../../components/workpad_loader';
import { WorkpadManager } from '../../components/workpad_manager';
import { setDocTitle } from '../../lib/doc_title';

export const HomeApp = () => {
setDocTitle('Canvas');
return (
<EuiPage restrictWidth style={{ width: '100%' }}>
<EuiPage className="canvasHomeApp" restrictWidth>
<EuiPageBody>
<EuiPageContent panelPaddingSize="none" horizontalPosition="center">
<WorkpadLoader onClose={() => {}} />
<EuiPageContent
className="canvasHomeApp__content"
panelPaddingSize="none"
horizontalPosition="center"
>
<WorkpadManager onClose={() => {}} />
</EuiPageContent>
</EuiPageBody>
</EuiPage>
Expand Down
11 changes: 9 additions & 2 deletions x-pack/plugins/canvas/public/apps/home/home_app.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.canvasHomeApp__modalHeader {
padding-right: 24px;
.canvasHomeApp {
width: 100%;

.canvasHomeApp__content {
width: 100%;
}
.canvasHomeApp__modalHeader {
padding-right: 24px;
}
}
4 changes: 4 additions & 0 deletions x-pack/plugins/canvas/public/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { getAppReady, getBasePath } from '../../state/selectors/app';
import { appReady, appError } from '../../state/actions/app';
import { loadPrivateBrowserFunctions } from '../../lib/load_private_browser_functions';
import { elementsRegistry } from '../../lib/elements_registry';
import { templatesRegistry } from '../../lib/templates_registry';
import { tagsRegistry } from '../../lib/tags_registry';
import { renderFunctionsRegistry } from '../../lib/render_functions_registry';
import {
argTypeRegistry,
Expand Down Expand Up @@ -44,6 +46,8 @@ const types = {
modelUIs: modelRegistry,
viewUIs: viewRegistry,
argumentUIs: argTypeRegistry,
templates: templatesRegistry,
tags: tagsRegistry,
};

const mapDispatchToProps = dispatch => ({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/public/components/toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export const Toolbar = compose(
},
}),
withState('tray', 'setTray', props => props.tray),
withState('showWorkpadLoader', 'setShowWorkpadLoader', false)
withState('showWorkpadManager', 'setShowWorkpadManager', false)
)(Component);
26 changes: 13 additions & 13 deletions x-pack/plugins/canvas/public/components/toolbar/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiButton,
} from '@elastic/eui';
import { Navbar } from '../navbar';
import { WorkpadLoader } from '../workpad_loader';
import { WorkpadManager } from '../workpad_manager';
import { PageManager } from '../page_manager';
import { Expression } from '../expression';
import { Tray } from './tray';
Expand All @@ -32,8 +32,8 @@ export const Toolbar = props => {
selectedPageNumber,
workpadName,
totalPages,
showWorkpadLoader,
setShowWorkpadLoader,
showWorkpadManager,
setShowWorkpadManager,
} = props;

const elementIsSelected = Boolean(selectedElement);
Expand All @@ -45,15 +45,15 @@ export const Toolbar = props => {
setTray(exp);
};

const closeWorkpadLoader = () => setShowWorkpadLoader(false);
const openWorkpadLoader = () => setShowWorkpadLoader(true);
const closeWorkpadManager = () => setShowWorkpadManager(false);
const openWorkpadManager = () => setShowWorkpadManager(true);

const workpadLoader = (
const workpadManager = (
<EuiOverlayMask>
<EuiModal onClose={closeWorkpadLoader} className="canvasModal--fixedSize" maxWidth="1000px">
<WorkpadLoader onClose={closeWorkpadLoader} />
<EuiModal onClose={closeWorkpadManager} className="canvasModal--fixedSize" maxWidth="1000px">
<WorkpadManager onClose={closeWorkpadManager} />
<EuiModalFooter>
<EuiButton size="s" onClick={closeWorkpadLoader}>
<EuiButton size="s" onClick={closeWorkpadManager}>
Dismiss
</EuiButton>
</EuiModalFooter>
Expand All @@ -72,7 +72,7 @@ export const Toolbar = props => {
<Navbar>
<EuiFlexGroup alignItems="center" gutterSize="none" className="canvasToolbar__controls">
<EuiFlexItem grow={false}>
<EuiButtonEmpty color="text" iconType="grid" onClick={() => openWorkpadLoader()}>
<EuiButtonEmpty color="text" iconType="grid" onClick={() => openWorkpadManager()}>
{workpadName}
</EuiButtonEmpty>
</EuiFlexItem>
Expand Down Expand Up @@ -116,7 +116,7 @@ export const Toolbar = props => {
</EuiFlexGroup>
</Navbar>

{showWorkpadLoader && workpadLoader}
{showWorkpadManager && workpadManager}
</div>
);
};
Expand All @@ -130,6 +130,6 @@ Toolbar.propTypes = {
selectedPageNumber: PropTypes.number.isRequired,
totalPages: PropTypes.number.isRequired,
selectedElement: PropTypes.object,
showWorkpadLoader: PropTypes.bool.isRequired,
setShowWorkpadLoader: PropTypes.func.isRequired,
showWorkpadManager: PropTypes.bool.isRequired,
setShowWorkpadManager: PropTypes.func.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ import PropTypes from 'prop-types';
import { EuiButton } from '@elastic/eui';

export const WorkpadCreate = ({ createPending, onCreate, ...rest }) => (
<EuiButton
{...rest}
iconType="plusInCircle"
size="s"
fill
onClick={onCreate}
isLoading={createPending}
>
<EuiButton {...rest} iconType="plusInCircle" fill onClick={onCreate} isLoading={createPending}>
Create workpad
</EuiButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
.canvasWorkpad__dropzoneTable .euiTable {
background-color: transparent;
}

.canvasWorkpad__dropzoneTable--tags {

.euiTableCellContent {
flex-wrap: wrap;
}

.euiHealth {
width: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiBasicTable,
EuiBetaBadge,
EuiButtonIcon,
EuiLink,
EuiPagination,
EuiSpacer,
EuiButton,
EuiToolTip,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiEmptyPrompt,
} from '@elastic/eui';
import { sortByOrder } from 'lodash';
import moment from 'moment';
import { documentationLinks } from '../../lib/documentation_links';
import { ConfirmModal } from '../confirm_modal';
import { Link } from '../link';
import { Paginate } from '../paginate';
Expand Down Expand Up @@ -282,7 +276,6 @@ export class WorkpadLoader extends React.PureComponent {

let deleteButton = (
<EuiButton
size="s"
color="danger"
iconType="trash"
onClick={this.openRemoveConfirm}
Expand All @@ -293,7 +286,7 @@ export class WorkpadLoader extends React.PureComponent {
);

const downloadButton = (
<EuiButton size="s" color="secondary" onClick={this.downloadWorkpads} iconType="sortDown">
<EuiButton color="secondary" onClick={this.downloadWorkpads} iconType="sortDown">
{`Download (${selectedWorkpads.length})`}
</EuiButton>
);
Expand Down Expand Up @@ -347,62 +340,43 @@ export class WorkpadLoader extends React.PureComponent {
<Paginate rows={sortedWorkpads}>
{pagination => (
<Fragment>
<EuiModalHeader className="canvasHomeApp__modalHeader">
<div style={{ width: '100%' }}>
<EuiFlexGroup alignItems="center" gutterSize="m">
<EuiFlexItem grow={false}>
<EuiModalHeaderTitle>Canvas workpads</EuiModalHeaderTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiBetaBadge
label="Beta"
tooltipContent="Canvas is still in beta. Please help us improve by reporting issues or bugs in the Kibana repo."
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={2}>
<EuiFlexGroup gutterSize="s">
{selectedWorkpads.length > 0 && (
<Fragment>
<EuiFlexItem grow={false}>{downloadButton}</EuiFlexItem>
<EuiFlexItem grow={false}>{deleteButton}</EuiFlexItem>
</Fragment>
)}
<EuiFlexItem grow={1}>
<WorkpadSearch
onChange={text => {
pagination.setPage(0);
this.props.findWorkpads(text);
}}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink href={documentationLinks.canvas} target="_blank">
Docs
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="l" />
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={2}>
<EuiFlexGroup gutterSize="s">
{selectedWorkpads.length > 0 && (
<Fragment>
<EuiFlexItem grow={false}>{downloadButton}</EuiFlexItem>
<EuiFlexItem grow={false}>{deleteButton}</EuiFlexItem>
</Fragment>
)}
<EuiFlexItem grow={1}>
<WorkpadSearch
onChange={text => {
pagination.setPage(0);
this.props.findWorkpads(text);
}}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={2}>
<EuiFlexGroup gutterSize="s" justifyContent="flexEnd" wrap>
<EuiFlexItem grow={false}>{uploadButton}</EuiFlexItem>
<EuiFlexItem grow={false}>{createButton}</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexItem>
<EuiFlexItem grow={2}>
<EuiFlexGroup gutterSize="s" justifyContent="flexEnd" wrap>
<EuiFlexItem grow={false}>{uploadButton}</EuiFlexItem>
<EuiFlexItem grow={false}>{createButton}</EuiFlexItem>
</EuiFlexGroup>
</div>
</EuiModalHeader>
<EuiModalBody>
{createPending && <div>Creating Workpad...</div>}
</EuiFlexItem>
</EuiFlexGroup>

<EuiSpacer />

{createPending && <div style={{ width: '100%' }}>Creating Workpad...</div>}

{!createPending && isLoading && <div>Fetching Workpads...</div>}
{!createPending &&
isLoading && <div style={{ width: '100%' }}>Fetching Workpads...</div>}

{!createPending && !isLoading && this.renderWorkpadTable(pagination)}
{!createPending && !isLoading && this.renderWorkpadTable(pagination)}

{confirmModal}
</EuiModalBody>
{confirmModal}
</Fragment>
)}
</Paginate>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.canvasWorkpad__upload--compressed {

&.euiFilePicker--compressed.euiFilePicker {

.euiFilePicker__prompt {
height: $euiSizeXXL;
padding: $euiSizeM;
padding-left: $euiSizeXXL;
}
.euiFilePicker__icon {
top: $euiSizeM;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class WorkpadSearch extends React.PureComponent {
render() {
return (
<EuiFieldSearch
compressed
placeholder="Find workpad"
value={this.state.searchText}
onChange={this.setSearchText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const WorkpadUpload = ({ onUpload, ...rest }) => (
<EuiFilePicker
{...rest}
compressed
className="canvasWorkpad__upload--compressed"
initialPromptText="Import workpad JSON file"
onChange={([file]) => uploadWorkpad(file, onUpload)}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { WorkpadManager } from './workpad_manager';
Loading