-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Spaces] Replace Space Selector modal with a less intrusive popover (#…
…19497) This replaces the existing Modal with a smaller Popover which is less intrusive. The popover also features a search bar for finding the desired Space when there are 8 or more Spaces to choose from. ### Details When there are less than 8 spaces available, the selector will render a simple list of spaces. When there are >= 8 spaces available, the selector will also render a search bar to let users search for their space. ### Prerequisites - [x] Merge #18862 into `spaces-phase-1` ### Known Issues - elastic/eui#1043 (fixed in `v3.2.0`) - elastic/eui#1052 (fixed in `v3.2.1`) - Missing typdefs (not a blocker to merge): elastic/eui#1120
- Loading branch information
Showing
25 changed files
with
638 additions
and
293 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 interface Space { | ||
id: string; | ||
name: string; | ||
description?: string; | ||
color?: string; | ||
initials?: string; | ||
_reserved?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* 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 chrome from 'ui/chrome'; | ||
|
||
export const MANAGE_SPACES_URL = chrome.addBasePath(`/app/kibana#/management/spaces/list`); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 { toastNotifications } from 'ui/notify'; | ||
|
||
import { IHttpResponse } from 'angular'; | ||
import { EventEmitter } from 'events'; | ||
import { Space } from '../../common/model/space'; | ||
|
||
export class SpacesManager extends EventEmitter { | ||
private httpAgent: any; | ||
private baseUrl: any; | ||
|
||
constructor(httpAgent: any, chrome: any) { | ||
super(); | ||
this.httpAgent = httpAgent; | ||
this.baseUrl = chrome.addBasePath(`/api/spaces/v1`); | ||
} | ||
|
||
public async getSpaces(): Promise<Space[]> { | ||
return await this.httpAgent | ||
.get(`${this.baseUrl}/spaces`) | ||
.then((response: IHttpResponse<Space[]>) => response.data); | ||
} | ||
|
||
public async getSpace(id: string): Promise<Space> { | ||
return await this.httpAgent.get(`${this.baseUrl}/space/${id}`); | ||
} | ||
|
||
public async createSpace(space: Space) { | ||
return await this.httpAgent.post(`${this.baseUrl}/space`, space); | ||
} | ||
|
||
public async updateSpace(space: Space) { | ||
return await this.httpAgent.put(`${this.baseUrl}/space/${space.id}?overwrite=true`, space); | ||
} | ||
|
||
public async deleteSpace(space: Space) { | ||
return await this.httpAgent.delete(`${this.baseUrl}/space/${space.id}`); | ||
} | ||
|
||
public async changeSelectedSpace(space: Space) { | ||
return await this.httpAgent | ||
.post(`${this.baseUrl}/space/${space.id}/select`) | ||
.then((response: IHttpResponse<any>) => { | ||
if (response.data && response.data.location) { | ||
window.location = response.data.location; | ||
} else { | ||
this._displayError(); | ||
} | ||
}) | ||
.catch(() => this._displayError()); | ||
} | ||
|
||
public async requestRefresh() { | ||
this.emit('request_refresh'); | ||
} | ||
|
||
public _displayError() { | ||
toastNotifications.addDanger({ | ||
title: 'Unable to change your Space', | ||
text: 'please try again later', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/spaces/public/views/components/manage_spaces_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 { EuiButton } from '@elastic/eui'; | ||
import React, { Component } from 'react'; | ||
import { MANAGE_SPACES_URL } from '../../lib/constants'; | ||
|
||
interface Props { | ||
isDisabled?: boolean; | ||
size?: 's' | 'l'; | ||
style?: CSSProperties; | ||
} | ||
|
||
export class ManageSpacesButton extends Component<Props, {}> { | ||
public render() { | ||
return ( | ||
<EuiButton | ||
size={this.props.size || 's'} | ||
className="manage-spaces-button" | ||
isDisabled={this.props.isDisabled} | ||
onClick={this.navigateToManageSpaces} | ||
style={this.props.style} | ||
> | ||
Manage Spaces | ||
</EuiButton> | ||
); | ||
} | ||
|
||
private navigateToManageSpaces = () => { | ||
window.location.replace(MANAGE_SPACES_URL); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ck/plugins/spaces/public/views/nav_control/__snapshots__/nav_control_popover.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`NavControlPopover renders without crashing 1`] = `""`; |
32 changes: 32 additions & 0 deletions
32
...spaces/public/views/nav_control/components/__snapshots__/spaces_description.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SpacesDescription renders without crashing 1`] = ` | ||
<EuiContextMenuPanel | ||
className="spacesDescription" | ||
hasFocus={true} | ||
items={Array []} | ||
title="Spaces" | ||
> | ||
<EuiText | ||
className="spacesDescription__text" | ||
grow={true} | ||
> | ||
<p> | ||
Use Spaces within Kibana to organize your Dashboards, Visualizations, and other saved objects. | ||
</p> | ||
</EuiText> | ||
<div | ||
className="spacesDescription__manageButtonWrapper" | ||
key="manageSpacesButton" | ||
> | ||
<ManageSpacesButton | ||
size="s" | ||
style={ | ||
Object { | ||
"width": "100%", | ||
} | ||
} | ||
/> | ||
</div> | ||
</EuiContextMenuPanel> | ||
`; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.spacesDescription { | ||
max-width: 300px; | ||
} | ||
|
||
.spacesDescription__text, | ||
.spacesDescription__manageButtonWrapper { | ||
padding: 12px; | ||
} |
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/spaces/public/views/nav_control/components/spaces_description.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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 { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import { SpacesDescription } from './spaces_description'; | ||
|
||
describe('SpacesDescription', () => { | ||
it('renders without crashing', () => { | ||
expect(shallow(<SpacesDescription />)).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.