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

Feature Controls #31652

Merged
merged 154 commits into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
c38b429
Restructure user profile for granular app privs (#23750)
legrego Nov 5, 2018
5b4af95
Introducing uiCapabilities, removing config providers & user profile …
legrego Nov 14, 2018
1f336e5
GAP - Actions Restructured and Extensible (#25347)
kobelb Nov 16, 2018
aeac093
update snapshot
legrego Nov 26, 2018
4a0f760
UI/API changes to facilitate disabling features within spaces (#24235)
legrego Nov 29, 2018
e032111
Merge branch 'master' into granular-app-privileges
legrego Dec 3, 2018
fd14b08
GAP: Security disables UI capabilities (#25809)
kobelb Dec 3, 2018
4ff1975
GAP - Role API Structure (#26740)
kobelb Dec 6, 2018
2883c23
Merge branch 'master' into granular-app-privileges
legrego Dec 7, 2018
b113f58
Merge branch 'master' into granular-app-privileges
legrego Dec 10, 2018
90aebc3
Merge branch 'master' into granular-app-privileges
legrego Dec 11, 2018
17c0019
update tests
legrego Dec 11, 2018
93c503a
[GAP] - Support infra features (#26955)
legrego Dec 11, 2018
806a0c6
Merge branch 'master' into granular-app-privileges
legrego Dec 11, 2018
6fed0a5
Merge branch 'granular-app-privileges' of github.com:elastic/kibana i…
legrego Dec 12, 2018
3d43e21
Merge branch 'master' into granular-app-privileges
legrego Dec 14, 2018
0001887
Merge branch 'master' into granular-app-privileges
legrego Dec 14, 2018
b7b5880
[GAP] - Enables xpack_main to populate UI Capabilities (#27031)
legrego Dec 14, 2018
ab7a79b
Merge branch 'master' into granular-app-privileges
legrego Dec 19, 2018
a075c0f
Hide write controls for the visualization application (#26536)
legrego Dec 19, 2018
dad3430
Hide write controls for the timelion application (#26537)
legrego Dec 19, 2018
4df3899
blacklist feature ids (#27493)
legrego Dec 20, 2018
cdb5fc6
Merge branch 'master' into granular-app-privileges
legrego Dec 20, 2018
1f8faa5
[GAP] - Support management links (#27055)
legrego Dec 20, 2018
7fcfc13
Merge branch 'master' into granular-app-privileges
legrego Jan 3, 2019
2503995
Enables the feature catalogue registry to be controlled via uiCapabil…
legrego Jan 5, 2019
8a32e9a
Merge branch 'master' into granular-app-privileges
legrego Jan 7, 2019
41a341f
fix merge
legrego Jan 7, 2019
d6f376d
update snapshots
legrego Jan 7, 2019
579a7ab
GAP - Discover and NavLinks Functional Testing (#27414)
kobelb Jan 8, 2019
fae8393
Space Management - accessibility & i18n improvements (#28195)
legrego Jan 8, 2019
045e55e
Feature Controls - spaces - functional tests (#28213)
legrego Jan 8, 2019
b4907dd
Fc/run ui capability tests (#28362)
kobelb Jan 9, 2019
6ab8a0c
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Jan 10, 2019
e8aa9f9
Feature Controls - The new new role API (#28441)
kobelb Jan 11, 2019
194e3f3
Feature Controls - Discover Save Button Test #28500 (#28501)
kobelb Jan 11, 2019
130c5a6
Reload when adjusting visible features within the users active space …
legrego Jan 11, 2019
25ad621
Merge branch 'master' into granular-app-privileges
legrego Jan 15, 2019
7475e05
Merge branch 'granular-app-privileges' of github.com:elastic/kibana i…
legrego Jan 15, 2019
df78f53
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Jan 18, 2019
df8de34
Throwing error if we register a feature after getAll is called (#29030)
kobelb Jan 22, 2019
05cd396
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Jan 22, 2019
4f139d6
Fixing merge conflict
kobelb Jan 22, 2019
a4ade89
Feature Controls - Fixing fallout of removing the legacy fallback (#2…
kobelb Jan 23, 2019
149b16d
[Feature Controls] - Fix a11y for customize feature section (#29174)
legrego Jan 23, 2019
d403b18
Feature Controls: Fixing k7's new "nav links" (#29198)
kobelb Jan 24, 2019
e8ffcbb
Feature Controls - Dashboard (#29139)
kobelb Jan 25, 2019
60b428c
[FC] - Move management and catalogue entries out of privilege definit…
legrego Jan 25, 2019
10e3159
Merge branch 'master' into granular-app-privileges
legrego Jan 29, 2019
e90cfd1
[GAP] - Role Management UI (#26840)
legrego Jan 30, 2019
5f3b4a4
[Feature Controls, Spaces] - Don't load bundles for hidden apps (#29617)
legrego Jan 30, 2019
c6026bb
[Feature Controls] - Copy Edits (#29651)
legrego Jan 31, 2019
4142e8a
[Feature Controls] - Rename-a-thon (#29709)
legrego Jan 31, 2019
08637fe
Merge branch 'master' into granular-app-privileges
legrego Feb 1, 2019
4154432
Merge branch 'granular-app-privileges' of github.com:elastic/kibana i…
legrego Feb 1, 2019
0918ad8
Merge branch 'master' into granular-app-privileges
legrego Feb 4, 2019
a0dfc58
post-merge cleanup
legrego Feb 4, 2019
5a87fb7
[Feature Controls] - fixes from recent merge from master (#29826)
legrego Feb 4, 2019
d46df1e
Feature Controls: Adding privileges tooltip for Dev Tools (#30008)
kobelb Feb 5, 2019
a63306e
[Feature Controls] - Fix displayed space base privilege (#30133)
legrego Feb 5, 2019
c147926
Feature Controls: Adding read privileges for advanced settings and in…
kobelb Feb 5, 2019
9eb7bed
Feature Controls - spaces not a security mechanism warning (#29853)
kobelb Feb 6, 2019
c865ecc
Merge branch 'master' into granular-app-privileges
legrego Feb 6, 2019
ec1cc82
Merge branch 'granular-app-privileges' of github.com:elastic/kibana i…
legrego Feb 6, 2019
f072873
Merge branch 'master' into granular-app-privileges
legrego Feb 7, 2019
a5d45fe
[Feature Controls] - Fixes from merging from master (8.0) (#30267)
legrego Feb 7, 2019
3cd1485
Fc/functional test move (#29835)
kobelb Feb 7, 2019
9c98c44
[Feature Controls] - Readonly view for Advanced Settings using UICapa…
legrego Feb 7, 2019
27f9cef
Merge branch 'master' into granular-app-privileges
legrego Feb 8, 2019
20c49e9
Feature Controls: No Wildcards (#30169)
kobelb Feb 8, 2019
7f156c4
[Feature Controls] - Readonly mode for Canvas using UICapabilities (#…
legrego Feb 8, 2019
881622a
[Feature Controls] - Readonly mode for Maps using UICapabilities (#30…
legrego Feb 8, 2019
d38e8ed
Add typings for x-pack/test to support .html imports (#30570)
kobelb Feb 8, 2019
c04cf14
[Feature Controls] - Readonly mode for Timelion using UICapabilities …
legrego Feb 8, 2019
e630c8d
remove stray debug code
legrego Feb 9, 2019
9da1edc
Merge branch 'master' into granular-app-privileges
legrego Feb 11, 2019
ef2958d
[Feature Controls] - Updates from src/ui move to src/legacy/ui (#30678)
legrego Feb 12, 2019
d51cfc5
Feature Controls: Adding read/write privileges for all applications (…
kobelb Feb 13, 2019
175a895
[Feature Controls] - Readonly mode for Visualize using UICapabilities…
legrego Feb 13, 2019
204fee2
[Feature Controls] - Adds missing uptime icon (#30716)
legrego Feb 13, 2019
d15ff82
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Feb 14, 2019
81d0d4a
Feature Controls - Fix branch (#31135)
kobelb Feb 14, 2019
5479aaa
Feature Controls - Graph (#30762)
kobelb Feb 14, 2019
d177c4f
[Feature Controls] - Fixes page width for spaces management screen (#…
legrego Feb 14, 2019
d121324
Feature Controls - Dev Tools (#30712)
kobelb Feb 14, 2019
9a5b05b
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Feb 20, 2019
381d6aa
Feature Controls- Fix Merge Conflicts (#31651)
kobelb Feb 21, 2019
6224dc2
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Feb 22, 2019
f38ebc2
Feature Controls - No more route defaults for dashboards (#31767)
kobelb Feb 22, 2019
84c0fe6
Feature Controls - Only allowing features to register all and read pr…
kobelb Feb 25, 2019
1724855
Feature Controls - Saved Object Management (#31332)
kobelb Feb 25, 2019
bfa35ba
Feature Controls - UI capability API integration tests with fixture p…
kobelb Mar 1, 2019
ae244ac
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 1, 2019
9d71808
Fixing typescript issues, we can't import EUI on the server
kobelb Mar 2, 2019
d5c1482
Fixing eslint error
kobelb Mar 4, 2019
6a43007
Updating Jest snapshots, fixing chrome mock
kobelb Mar 4, 2019
244dc2a
Fixing dashboard listing test
kobelb Mar 4, 2019
62bb17a
Adding missing await and forcing logout for graph functional tests
kobelb Mar 4, 2019
7ae25d8
Putting i18n string back
kobelb Mar 4, 2019
ad78b2f
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 6, 2019
76ce0ce
Fixing type script issue
kobelb Mar 7, 2019
82377a3
Fixing canvas assert because of merge
kobelb Mar 7, 2019
74d5df2
Fixing saved object api error assertations
kobelb Mar 7, 2019
e8c582e
user-action is now a saved object type
kobelb Mar 7, 2019
ec338d1
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 8, 2019
20fb327
Fixing typescript error
kobelb Mar 8, 2019
bb76d20
Fixing saved object actions as a result of the merge
kobelb Mar 8, 2019
e79d63b
Feature Controls - Infrastructure and Logging (#31843)
kobelb Mar 11, 2019
a09786c
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 12, 2019
6e70996
Updating jest snapshots
kobelb Mar 12, 2019
43ab5fc
Feature Controls - Short URLs (#32418)
kobelb Mar 14, 2019
d02086f
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 15, 2019
3a4459f
Fixing snapshots, mocking chrome.getInjected
kobelb Mar 15, 2019
2b37677
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 15, 2019
06864e6
Feature Controls - Uptime (#32577)
kobelb Mar 18, 2019
2e79d78
Revising the behavior of maps read-only mode (#33338)
kobelb Mar 18, 2019
ee4c27f
Feature Controls - APIs (#32915)
kobelb Mar 19, 2019
c652e14
Fixing graph test subject, thanks Joe!
kobelb Mar 19, 2019
044387f
Consolidating hideWriteControls dashboard listing test
kobelb Mar 19, 2019
03f74fc
Reusing maps constants
kobelb Mar 19, 2019
a992d80
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 20, 2019
52ebed3
Adding type to saved object management ui capability tests
kobelb Mar 21, 2019
65f39ab
Feature Controls - Index Pattern Management (#33314)
kobelb Mar 21, 2019
b238f62
Fixing maps spaces functional tests
kobelb Mar 21, 2019
fa9b553
Feature Controls - Differentiating the privileges with the same actio…
kobelb Mar 21, 2019
6666e87
Feature Controls: APM (#32812)
kobelb Mar 22, 2019
eec426c
Fixing merge-conflict with privileges allHack: and APM
kobelb Mar 28, 2019
f21862b
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Mar 28, 2019
9277f5d
address canvas feedback (#34269)
legrego Apr 1, 2019
9a1ba2f
[Feature Controls] - Plugin postInit (#29172)
legrego Apr 2, 2019
df4a8f9
Feature Controls - Adds bulk toggle for showing/hiding features withi…
legrego Apr 2, 2019
3f3476e
Feature Controls - Unregistered Applications Authorization (#34122)
kobelb Apr 2, 2019
36024a2
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Apr 3, 2019
b72c46d
Fixing imports, thanks tslint --fix!
kobelb Apr 3, 2019
22c18cd
Updating snapshots
kobelb Apr 3, 2019
c6ed804
Feature Controls - Disable privilege form until spaces are selected (…
legrego Apr 3, 2019
9e3c8c5
Feature Controls - Visualize read-only create new (#34209)
kobelb Apr 4, 2019
28d4c00
Feature Controls - Actions Version Prefix (#34405)
kobelb Apr 4, 2019
37edb25
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Apr 4, 2019
e092f7f
Fixing ui/chrome mock
kobelb Apr 4, 2019
bf43c23
Feature Controls - Displaying share menu on dashboards when in read-o…
kobelb Apr 4, 2019
1e6270b
Merge branch 'master' into granular-app-privileges
legrego Apr 8, 2019
2308242
migrate from tslint to eslint
legrego Apr 8, 2019
80dc0e7
Feature Controls - Reserved Role Apps (#30525)
kobelb Apr 9, 2019
11d9144
Feature Controls - Adds feature registration to plugin generator (#34…
legrego Apr 10, 2019
453aaf0
Merge remote-tracking branch 'upstream/master' into granular-app-priv…
kobelb Apr 10, 2019
1565358
Updating core system docs
kobelb Apr 10, 2019
2e6f958
Fixing infra's dates with data for the functional tests
kobelb Apr 10, 2019
9956a4c
[Feature Controls] - Move UICapabilities to the new platform (#30585)
legrego Apr 11, 2019
f0ab6e2
Merge branch 'master' into granular-app-privileges
legrego Apr 12, 2019
bd9d5b3
Merge branch 'granular-app-privileges' of github.com:elastic/kibana i…
legrego Apr 12, 2019
e988b63
Merge branch 'master' into granular-app-privileges
legrego Apr 12, 2019
bdfc28f
Fixing uptime functional api tests
kobelb Apr 12, 2019
79e9614
Removing .only...
kobelb Apr 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions docs/development/security/rbac.asciidoc
Expand Up @@ -32,9 +32,9 @@ Authorization: Basic kibana changeme
"actions":[
"version:7.0.0-alpha1-SNAPSHOT",
"action:login",
"action:saved_objects/dashboard/get",
"action:saved_objects/dashboard/bulk_get",
"action:saved_objects/dashboard/find",
"saved_object:dashboard/get",
"saved_object:dashboard/bulk_get",
"saved_object:dashboard/find",
...
],"metadata":{}}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ Authorization: Basic foo_read_only_user password
"application":"kibana-.kibana",
"resources":["*"],
"privileges":[
"action:saved_objects/dashboard/save",
"saved_object:dashboard/save",
]
}
]
Expand Down Expand Up @@ -120,7 +120,7 @@ Authorization: Basic foo_legacy_user password
"application":"kibana-.kibana",
"resources":["*"],
"privileges":[
"action:saved_objects/dashboard/save"
"saved_object:dashboard/save"
]
}
],
Expand Down Expand Up @@ -152,7 +152,7 @@ Here is an example response if the user does not have application privileges, bu
"application": {
"kibana-.kibana": {
"*": {
"action:saved_objects/dashboard/save": false
"saved_object:dashboard/save": false
}
}
}
Expand Down
Expand Up @@ -47,6 +47,7 @@ export function KuiListingTable({
toolBarActions,
onFilter,
onItemSelectionChanged,
enableSelection,
selectedRowIds,
filter,
prompt,
Expand Down Expand Up @@ -76,11 +77,12 @@ export function KuiListingTable({
}
}

function renderTableRows() {
function renderTableRows(enableSelection) {
return rows.map((row, rowIndex) => {
return (
<KuiListingTableRow
key={rowIndex}
enableSelection={enableSelection}
isSelected={selectedRowIds.indexOf(row.id) >= 0}
onSelectionChanged={toggleRow}
row={row}
Expand Down Expand Up @@ -111,15 +113,17 @@ export function KuiListingTable({
return (
<KuiTable>
<KuiTableHeader>
<KuiTableHeaderCheckBoxCell
isChecked={areAllRowsSelected()}
onChange={toggleAll}
/>
{enableSelection &&
<KuiTableHeaderCheckBoxCell
isChecked={areAllRowsSelected()}
onChange={toggleAll}
/>
}
{renderHeader()}
</KuiTableHeader>

<KuiTableBody>
{renderTableRows()}
{renderTableRows(enableSelection)}
</KuiTableBody>
</KuiTable>
);
Expand Down Expand Up @@ -171,6 +175,7 @@ KuiListingTable.propTypes = {
})),
pager: PropTypes.node,
onItemSelectionChanged: PropTypes.func.isRequired,
enableSelection: PropTypes.bool,
selectedRowIds: PropTypes.array,
prompt: PropTypes.node, // If given, will be shown instead of a table with rows.
onFilter: PropTypes.func,
Expand All @@ -181,4 +186,5 @@ KuiListingTable.propTypes = {
KuiListingTable.defaultProps = {
rows: [],
selectedRowIds: [],
enableSelection: true,
};
Expand Up @@ -57,13 +57,15 @@ export class KuiListingTableRow extends React.PureComponent {
}

render() {
const { isSelected } = this.props;
const { enableSelection, isSelected } = this.props;
return (
<KuiTableRow>
<KuiTableRowCheckBoxCell
isChecked={isSelected}
onChange={this.onSelectionChanged}
/>
{enableSelection &&
<KuiTableRowCheckBoxCell
isChecked={isSelected}
onChange={this.onSelectionChanged}
/>
}
{this.renderCells()}
</KuiTableRow>
);
Expand All @@ -83,6 +85,11 @@ KuiListingTableRow.propTypes = {
],
)),
}).isRequired,
enableSelection: PropTypes.bool,
onSelectionChanged: PropTypes.func.isRequired,
isSelected: PropTypes.bool,
};

KuiListingTableRow.defaultProps = {
enableSelection: true,
};
Expand Up @@ -19,7 +19,7 @@

import { get } from 'lodash';
import { UiSettingsState } from '../ui_settings';
import { deepFreeze } from './deep_freeze';
import { deepFreeze } from '../utils/deep_freeze';

export interface InjectedMetadataParams {
injectedMetadata: {
Expand Down
1 change: 1 addition & 0 deletions src/es_archiver/lib/indices/kibana_index.js
Expand Up @@ -150,6 +150,7 @@ export async function createDefaultSpace({ index, client }) {
space: {
name: 'Default Space',
description: 'This is the default space',
disabledFeatures: [],
_reserved: true
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/legacy/core_plugins/console/index.js
Expand Up @@ -110,7 +110,12 @@ export default function (kibana) {
defaultVars = {
elasticsearchUrl: url.format(
Object.assign(url.parse(head(legacyEsConfig.hosts)), { auth: false })
)
),
uiCapabilities: {
dev_tools: {
show: true
},
}
};

server.route(createProxyRoute({
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/console/public/console.js
Expand Up @@ -26,6 +26,7 @@ require('ui-bootstrap-custom');
require('ui/modules').get('kibana', ['sense.ui.bootstrap']);
require('ui/tooltip');
require('ui/autoload/styles');
require('ui/capabilities/route_setup');

require('./src/controllers/sense_controller');
require('./src/directives/sense_history');
Expand All @@ -35,6 +36,7 @@ require('./src/directives/sense_welcome');


uiRoutes.when('/dev_tools/console', {
requireUICapability: 'dev_tools.show',
controller: 'SenseController',
template,
});
1 change: 1 addition & 0 deletions src/legacy/core_plugins/console/server/proxy_route.js
Expand Up @@ -65,6 +65,7 @@ export const createProxyRoute = ({
path: '/api/console/proxy',
method: 'POST',
config: {
tags: ['access:execute'],
payload: {
output: 'stream',
parse: false
Expand Down
48 changes: 47 additions & 1 deletion src/legacy/core_plugins/kibana/index.js
Expand Up @@ -135,9 +135,55 @@ export default function (kibana) {
},

injectDefaultVars(server, options) {
const { savedObjects } = server;

return {
kbnIndex: options.index,
kbnBaseUrl
kbnBaseUrl,
uiCapabilities: {
discover: {
show: true,
save: true
},
visualize: {
show: true,
save: true
},
dashboard: {
createNew: true,
show: true,
showWriteControls: true,
},
catalogue: {
discover: true,
dashboard: true,
visualize: true,
console: true,
advanced_settings: true,
index_patterns: true,
},
advancedSettings: {
save: true
},
savedObjectsManagement: savedObjects.types.reduce((acc, type) => ({
...acc,
[type]: {
delete: true,
edit: true,
read: true,
}
}), {}),
management: {
/*
* Management settings correspond to management section/link ids, and should not be changed
* without also updating those definitions.
*/
kibana: {
settings: true,
indices: true,
},
}
}
};
},

Expand Down
Expand Up @@ -18,9 +18,11 @@
*/

import { uiModules } from 'ui/modules';
import { uiCapabilities } from 'ui/capabilities';

uiModules.get('kibana')
.provider('dashboardConfig', () => {
let hideWriteControls = false;
let hideWriteControls = !uiCapabilities.dashboard.showWriteControls;

return {
/**
Expand Down
5 changes: 4 additions & 1 deletion src/legacy/core_plugins/kibana/public/dashboard/index.js
Expand Up @@ -36,6 +36,7 @@ import { recentlyAccessed } from 'ui/persisted_log';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { DashboardListing, EMPTY_FILTER } from './listing/dashboard_listing';
import { uiModules } from 'ui/modules';
import 'ui/capabilities/route_setup';

const app = uiModules.get('app/dashboard', [
'ngRoute',
Expand All @@ -54,7 +55,8 @@ function createNewDashboardCtrl($scope, i18n) {

uiRoutes
.defaults(/dashboard/, {
requireDefaultIndex: true
requireDefaultIndex: true,
requireUICapability: 'dashboard.show'
})
.when(DashboardConstants.LANDING_PAGE_PATH, {
template: dashboardListingTemplate,
Expand Down Expand Up @@ -116,6 +118,7 @@ uiRoutes
.when(DashboardConstants.CREATE_NEW_DASHBOARD_URL, {
template: dashboardTemplate,
controller: createNewDashboardCtrl,
requireUICapability: 'dashboard.createNew',
resolve: {
dash: function (savedDashboards, redirectWhenMissing) {
return savedDashboards.get()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -130,7 +130,7 @@ describe('after fetch', () => {
expect(component).toMatchSnapshot();
});

test('hideWriteControls', async () => {
test('hideWriteControls with no dashboards', async () => {
const component = shallowWithIntl(<DashboardListing.WrappedComponent
findItems={find.bind(null, 0)}
deleteItems={() => {}}
Expand All @@ -149,6 +149,25 @@ describe('after fetch', () => {
expect(component).toMatchSnapshot();
});

test('hideWriteControls with dashboards', async () => {
const component = shallowWithIntl(<DashboardListing.WrappedComponent
findItems={find.bind(null, 1)}
deleteItems={() => {}}
createItem={() => {}}
editItem={() => {}}
getViewUrl={() => {}}
listingLimit={1}
hideWriteControls={true}
/>);

// Ensure all promises resolve
await new Promise(resolve => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();

expect(component).toMatchSnapshot();
});
kobelb marked this conversation as resolved.
Show resolved Hide resolved

test('renders warning when listingLimit is exceeded', async () => {
const component = shallowWithIntl(<DashboardListing.WrappedComponent
findItems={find.bind(null, 2)}
Expand Down
Expand Up @@ -42,7 +42,13 @@ export function getEditPanelAction() {
icon: <EuiIcon type="pencil" />,
isDisabled: ({ embeddable }) =>
!embeddable || !embeddable.metadata || !embeddable.metadata.editUrl,
isVisible: ({ containerState }) => containerState.viewMode === DashboardViewMode.EDIT,
isVisible: ({ containerState, embeddable }) => {
const canEditEmbeddable = Boolean(
embeddable && embeddable.metadata && embeddable.metadata.editable
);
const inDashboardEditMode = containerState.viewMode === DashboardViewMode.EDIT;
return canEditEmbeddable && inDashboardEditMode;
},
getHref: ({ embeddable }) => {
if (embeddable && embeddable.metadata.editUrl) {
return embeddable.metadata.editUrl;
Expand Down