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

Context menu #76497

Merged
merged 53 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
136a484
feat: 🎸 add grouping to presentable interface
streamich Sep 2, 2020
25d53b7
feat: 🎸 add group to "Explore underlying" data action
streamich Sep 2, 2020
c96e962
refactor: 💡 return panel list and simplify context creation
streamich Sep 2, 2020
4c2e803
refactor: 💡 simplify context menu builder code
streamich Sep 2, 2020
29d0191
refactor: 💡 further simplify context menu builder code
streamich Sep 2, 2020
ca89a33
feat: 🎸 add grouping to context menu builder
streamich Sep 2, 2020
8122bd7
feat: 🎸 add icon to drilldowns group
streamich Sep 2, 2020
5be1ecb
fix: 🐛 sort in the other order
streamich Sep 2, 2020
1408967
feat: 🎸 group drilldown actions in edit mode
streamich Sep 2, 2020
07ab1d3
fix: 🐛 fix TypeScript error
streamich Sep 2, 2020
5dcd0b3
Merge branch 'master' into context-menu
elasticmachine Sep 3, 2020
911694c
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 7, 2020
091d17d
Merge remote-tracking branch 'origin/context-menu' into context-menu
streamich Sep 7, 2020
9e93a25
feat: 🎸 wrap long context menu list into a submenu
streamich Sep 7, 2020
14e3d31
feat: 🎸 improve context menu long list wrapping
streamich Sep 7, 2020
aba1e0a
feat: 🎸 display drilldowns panel at the bottom of main panel
streamich Sep 7, 2020
0090d21
feat: 🎸 add separator line for context menu
streamich Sep 7, 2020
5537f4b
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 8, 2020
b1f47a3
test: 💍 add basic context menu builder unit tests
streamich Sep 8, 2020
01fdb08
feat: 🎸 remove meta decoratiosn from generated menu
streamich Sep 8, 2020
83578af
test: 💍 add test subject attribute to "More" menu item
streamich Sep 8, 2020
b95d0c5
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 10, 2020
b9c6df2
chore: 🤖 remove separator line and add comment about EUI
streamich Sep 10, 2020
834cd45
test: 💍 update Jest snapshots
streamich Sep 10, 2020
eee9e9e
chore: 🤖 revert back change of showing both drilldown options
streamich Sep 10, 2020
ffef51f
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 14, 2020
f9c90c0
test: 💍 add context menu samples to example plugin
streamich Sep 14, 2020
ffc9202
feat: 🎸 collapse long groups into a sub-panel
streamich Sep 14, 2020
2cbf354
test: 💍 add context menu panel edit mode examples
streamich Sep 14, 2020
e396b68
test: 💍 fix OSS functional test
streamich Sep 14, 2020
a31908c
test: 💍 fix X-Pack functional tests
streamich Sep 14, 2020
c226aa8
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 15, 2020
374ce84
fix: 🐛 re-introduce item sorting by title
streamich Sep 15, 2020
5caddc7
test: 💍 allow explicitly opening more menu
streamich Sep 15, 2020
44012f0
test: 💍 try opening more panel in functional tests
streamich Sep 15, 2020
0f946f3
test: 💍 disable some tests
streamich Sep 16, 2020
9d886a1
chore: 🤖 remove unused code
streamich Sep 16, 2020
5a3fca2
test: 💍 use action test helper in unit tests
streamich Sep 16, 2020
245d84f
refactor: 💡 add helper utility to generate actions in examples
streamich Sep 16, 2020
5c5acd9
test: 💍 disable one more functional test
streamich Sep 16, 2020
d1a5121
test: 💍 improve how inspector is opened in functional tests
streamich Sep 16, 2020
0cb0a3a
test: 💍 enable functional test
streamich Sep 17, 2020
7cf1013
refactor: 💡 convert test suite to typescript
streamich Sep 17, 2020
f5dc160
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 17, 2020
98f147e
Merge remote-tracking branch 'upstream/master' into context-menu
streamich Sep 18, 2020
f99a4ea
test: 💍 move panel replace tests into a separate test suite
streamich Sep 18, 2020
3d50017
test: 💍 move panel cloning tests to a separate test suite
streamich Sep 18, 2020
704e9f5
test: 💍 set up dashboard context menu test suite
streamich Sep 18, 2020
68563c4
test: 💍 enable few panel context menu tests
streamich Sep 18, 2020
d201e6d
test: 💍 enable saved search panel tests
streamich Sep 18, 2020
4fbcc35
test: 💍 enable expanded panel context menu tests
streamich Sep 18, 2020
d16159f
test: 💍 remove render complete awaits
streamich Sep 18, 2020
766b83f
Merge branch 'master' into context-menu
elasticmachine Sep 21, 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
6 changes: 6 additions & 0 deletions examples/ui_actions_explorer/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { UiActionsStart, createAction } from '../../../src/plugins/ui_actions/pu
import { AppMountParameters, OverlayStart } from '../../../src/core/public';
import { HELLO_WORLD_TRIGGER_ID, ACTION_HELLO_WORLD } from '../../ui_action_examples/public';
import { TriggerContextExample } from './trigger_context_example';
import { ContextMenuExamples } from './context_menu_examples';

interface Props {
uiActionsApi: UiActionsStart;
Expand Down Expand Up @@ -109,7 +110,12 @@ const ActionsExplorer = ({ uiActionsApi, openModal }: Props) => {
</EuiText>

<EuiSpacer />

<TriggerContextExample uiActionsApi={uiActionsApi} />

<EuiSpacer />

<ContextMenuExamples />
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { EuiCode, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { PanelView } from './panel_view';
import { PanelViewWithSharing } from './panel_view_with_sharing';
import { PanelViewWithSharingLong } from './panel_view_with_sharing_long';
import { PanelEdit } from './panel_edit';
import { PanelEditWithDrilldowns } from './panel_edit_with_drilldowns';
import { PanelEditWithDrilldownsAndContextActions } from './panel_edit_with_drilldowns_and_context_actions';

export const ContextMenuExamples: React.FC = () => {
return (
<EuiText>
<h1>Context menu examples</h1>
<p>
Below examples show how context menu panels look with varying number of actions and how the
actions can be grouped into different panels using <EuiCode>grouping</EuiCode> field.
</p>

<EuiFlexGroup>
<EuiFlexItem>
<PanelView />
</EuiFlexItem>
<EuiFlexItem>
<PanelViewWithSharing />
</EuiFlexItem>
<EuiFlexItem>
<PanelViewWithSharingLong />
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexGroup>
<EuiFlexItem>
<PanelEdit />
</EuiFlexItem>
<EuiFlexItem>
<PanelEditWithDrilldowns />
</EuiFlexItem>
<EuiFlexItem>
<PanelEditWithDrilldownsAndContextActions />
</EuiFlexItem>
</EuiFlexGroup>
</EuiText>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export * from './context_menu_examples';
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from 'react';
import { EuiButton, EuiContextMenu, EuiPopover } from '@elastic/eui';
import useAsync from 'react-use/lib/useAsync';
import { buildContextMenuForActions } from '../../../../src/plugins/ui_actions/public';
import { sampleAction } from './util';

export const PanelEdit: React.FC = () => {
const [open, setOpen] = React.useState(false);

const context = {};
const trigger: any = 'TEST_TRIGGER';
const actions = [
sampleAction('test-1', 100, 'Edit visualization', 'pencil'),
sampleAction('test-2', 99, 'Clone panel', 'partial'),
sampleAction('test-3', 98, 'Edit panel title', 'pencil'),
sampleAction('test-4', 97, 'Customize time range', 'calendar'),
sampleAction('test-5', 96, 'Inspect', 'inspect'),
sampleAction('test-6', 95, 'Full screen', 'fullScreen'),
sampleAction('test-7', 94, 'Replace panel', 'submodule'),
sampleAction('test-8', 93, 'Delete from dashboard', 'trash'),
];

const panels = useAsync(() =>
buildContextMenuForActions({
actions: actions.map((action) => ({ action, context, trigger })),
})
);

return (
<EuiPopover
button={<EuiButton onClick={() => setOpen((x) => !x)}>Edit mode</EuiButton>}
isOpen={open}
panelPaddingSize="none"
anchorPosition="downLeft"
closePopover={() => setOpen(false)}
>
<EuiContextMenu initialPanelId={'mainMenu'} panels={panels.value} />
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from 'react';
import { EuiButton, EuiContextMenu, EuiPopover } from '@elastic/eui';
import useAsync from 'react-use/lib/useAsync';
import { buildContextMenuForActions, Action } from '../../../../src/plugins/ui_actions/public';
import { sampleAction } from './util';

export const PanelEditWithDrilldowns: React.FC = () => {
const [open, setOpen] = React.useState(false);

const context = {};
const trigger: any = 'TEST_TRIGGER';
const grouping: Action['grouping'] = [
{
id: 'drilldowns',
getDisplayName: () => 'Drilldowns',
getIconType: () => 'popout',
order: 20,
},
];
const actions = [
sampleAction('test-1', 100, 'Edit visualization', 'pencil'),
sampleAction('test-2', 99, 'Clone panel', 'partial'),
sampleAction('test-3', 98, 'Edit panel title', 'pencil'),
sampleAction('test-4', 97, 'Customize time range', 'calendar'),
sampleAction('test-5', 96, 'Inspect', 'inspect'),
sampleAction('test-6', 95, 'Full screen', 'fullScreen'),
sampleAction('test-7', 94, 'Replace panel', 'submodule'),
sampleAction('test-8', 93, 'Delete from dashboard', 'trash'),

sampleAction('test-9', 10, 'Create drilldown', 'plusInCircle', grouping),
sampleAction('test-10', 9, 'Manage drilldowns', 'list', grouping),
];

const panels = useAsync(() =>
buildContextMenuForActions({
actions: actions.map((action) => ({ action, context, trigger })),
})
);

return (
<EuiPopover
button={<EuiButton onClick={() => setOpen((x) => !x)}>Edit mode with drilldowns</EuiButton>}
isOpen={open}
panelPaddingSize="none"
anchorPosition="downLeft"
closePopover={() => setOpen(false)}
>
<EuiContextMenu initialPanelId={'mainMenu'} panels={panels.value} />
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from 'react';
import { EuiButton, EuiContextMenu, EuiPopover } from '@elastic/eui';
import useAsync from 'react-use/lib/useAsync';
import { buildContextMenuForActions, Action } from '../../../../src/plugins/ui_actions/public';
import { sampleAction } from './util';

export const PanelEditWithDrilldownsAndContextActions: React.FC = () => {
const [open, setOpen] = React.useState(false);

const context = {};
const trigger: any = 'TEST_TRIGGER';
const drilldownGrouping: Action['grouping'] = [
{
id: 'drilldowns',
getDisplayName: () => 'Drilldowns',
getIconType: () => 'popout',
order: 20,
},
];
const customActionGrouping: Action['grouping'] = [
{
id: 'actions',
getDisplayName: () => 'Custom actions',
getIconType: () => 'cloudStormy',
order: 20,
},
];
const actions = [
sampleAction('test-1', 100, 'Edit visualization', 'pencil'),
sampleAction('test-2', 99, 'Clone panel', 'partial'),
sampleAction('test-3', 98, 'Edit panel title', 'pencil'),
sampleAction('test-4', 97, 'Customize time range', 'calendar'),
sampleAction('test-5', 96, 'Inspect', 'inspect'),
sampleAction('test-6', 95, 'Full screen', 'fullScreen'),
sampleAction('test-7', 94, 'Replace panel', 'submodule'),
sampleAction('test-8', 93, 'Delete from dashboard', 'trash'),

sampleAction('test-9', 10, 'Create drilldown', 'plusInCircle', drilldownGrouping),
sampleAction('test-10', 9, 'Manage drilldowns', 'list', drilldownGrouping),

sampleAction('test-11', 10, 'Go to Sales dashboard', 'dashboardApp', customActionGrouping),
sampleAction('test-12', 9, 'Go to Traffic dashboard', 'dashboardApp', customActionGrouping),
sampleAction('test-13', 8, 'Custom actions', 'cloudStormy', customActionGrouping),
sampleAction('test-14', 7, 'View in Salesforce', 'link', customActionGrouping),
];

const panels = useAsync(() =>
buildContextMenuForActions({
actions: actions.map((action) => ({ action, context, trigger })),
})
);

return (
<EuiPopover
button={
<EuiButton onClick={() => setOpen((x) => !x)}>
Edit mode with drilldowns and custom actions
</EuiButton>
}
isOpen={open}
panelPaddingSize="none"
anchorPosition="downLeft"
closePopover={() => setOpen(false)}
>
<EuiContextMenu initialPanelId={'mainMenu'} panels={panels.value} />
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from 'react';
import { EuiButton, EuiContextMenu, EuiPopover } from '@elastic/eui';
import useAsync from 'react-use/lib/useAsync';
import { buildContextMenuForActions } from '../../../../src/plugins/ui_actions/public';
import { sampleAction } from './util';

export const PanelView: React.FC = () => {
const [open, setOpen] = React.useState(false);

const context = {};
const trigger: any = 'TEST_TRIGGER';
const actions = [
sampleAction('test-1', 100, 'Explore underlying data', 'discoverApp'),
sampleAction('test-2', 99, 'Customize time range', 'calendar'),
sampleAction('test-3', 98, 'Inspect', 'inspect'),
sampleAction('test-4', 97, 'Full screen', 'fullScreen'),
];

const panels = useAsync(() =>
buildContextMenuForActions({
actions: actions.map((action) => ({ action, context, trigger })),
})
);

return (
<EuiPopover
button={<EuiButton onClick={() => setOpen((x) => !x)}>View mode</EuiButton>}
isOpen={open}
panelPaddingSize="none"
anchorPosition="downLeft"
closePopover={() => setOpen(false)}
>
<EuiContextMenu initialPanelId={'mainMenu'} panels={panels.value} />
</EuiPopover>
);
};
Loading