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 16 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
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/public/apps/home/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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 = () => {
Expand All @@ -15,7 +15,7 @@ export const HomeApp = () => {
<EuiPage restrictWidth style={{ width: '100%' }}>
<EuiPageBody>
<EuiPageContent panelPaddingSize="none" horizontalPosition="center">
<WorkpadLoader onClose={() => {}} />
<WorkpadManager onClose={() => {}} />
</EuiPageContent>
</EuiPageBody>
</EuiPage>
Expand Down
10 changes: 5 additions & 5 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 @@ -43,10 +43,10 @@ export const Toolbar = props => {
setTray(exp);
};

const workpadLoader = (
const workpadManager = (
<EuiOverlayMask>
<EuiModal onClose={done} className="canvasModal--fixedSize" maxWidth="1000px">
<WorkpadLoader onClose={done} />
<WorkpadManager onClose={done} />
<EuiModalFooter>
<EuiButton size="s" onClick={done}>
Dismiss
Expand All @@ -58,7 +58,7 @@ export const Toolbar = props => {

const trays = {
pageManager: <PageManager previousPage={previousPage} />,
workpadloader: workpadLoader,
workpadManager,
expression: !elementIsSelected ? null : <Expression done={done} />,
};

Expand All @@ -71,7 +71,7 @@ export const Toolbar = props => {
<EuiButtonEmpty
color="text"
iconType="grid"
onClick={() => showHideTray('workpadloader')}
onClick={() => showHideTray('workpadManager')}
>
{workpadName}
</EuiButtonEmpty>
Expand Down
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,16 +10,11 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiBasicTable,
EuiBetaBadge,
EuiButtonIcon,
EuiLink,
EuiPagination,
EuiSpacer,
EuiButton,
EuiToolTip,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiEmptyPrompt,
} from '@elastic/eui';
import { sortByOrder } from 'lodash';
Expand Down Expand Up @@ -279,7 +274,6 @@ export class WorkpadLoader extends React.PureComponent {

let deleteButton = (
<EuiButton
size="s"
color="danger"
iconType="trash"
onClick={this.openRemoveConfirm}
Expand All @@ -290,7 +284,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 @@ -344,62 +338,42 @@ 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="https://canvas.elastic.co" 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>Creating Workpad...</div>}

{!createPending && isLoading && <div>Fetching Workpads...</div>}
{!createPending && isLoading && <div>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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import {
EuiTabbedContent,
EuiModalHeader,
EuiModalHeaderTitle,
EuiModalBody,
EuiSpacer,
EuiFlexGroup,
EuiFlexItem,
EuiBetaBadge,
EuiLink,
} from '@elastic/eui';
import { WorkpadLoader } from '../workpad_loader';
import { WorkpadTemplates } from '../workpad_templates';

export const WorkpadManager = ({ onClose }) => {
const tabs = [
{
id: 'workpadLoader',
name: 'My Workpads',
content: (
<Fragment>
<EuiSpacer />
<WorkpadLoader onClose={onClose} />
</Fragment>
),
},
{
id: 'workpadTemplates',
name: 'Templates',
content: (
<Fragment>
<EuiSpacer />
<WorkpadTemplates onClose={onClose} />
</Fragment>
),
},
];
return (
<Fragment>
<EuiModalHeader className="canvasHomeApp__modalHeader">
<EuiFlexGroup alignItems="center" gutterSize="s">
<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."
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink href="https://canvas.elastic.co" target="_blank">
Docs
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
</EuiModalHeader>
<EuiModalBody>
<EuiTabbedContent tabs={tabs} initialSelectedTab={tabs[0]} />
</EuiModalBody>
</Fragment>
);
};

WorkpadManager.propTypes = {
onClose: PropTypes.func,
};
28 changes: 28 additions & 0 deletions x-pack/plugins/canvas/public/components/workpad_templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 PropTypes from 'prop-types';
import { compose, getContext, withHandlers } from 'recompose';
import * as workpadService from '../../lib/workpad_service';
import { notify } from '../../lib/notify';
import { getId } from '../../lib/get_id';
import { WorkpadTemplates as Component } from './workpad_templates';

export const WorkpadTemplates = compose(
getContext({
router: PropTypes.object,
}),
withHandlers({
// Clone workpad given an id
cloneWorkpad: props => workpad => {
workpad.id = getId('workpad');
return workpadService
.create(workpad)
.then(() => props.router.navigateTo('loadWorkpad', { id: workpad.id, page: 1 }))
.catch(err => notify.error(err, { title: `Couldn't clone workpad template` }));
},
})
)(Component);
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.
*/

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

export const templates = [themeDark, themeLight];
Copy link
Contributor

@rashidkpc rashidkpc Nov 16, 2018

Choose a reason for hiding this comment

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

Make this business a registry like we have for elements, functions, etc. That'll set us up for templates as plugins right quick.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading