-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
860 additions
and
1 deletion.
There are no files selected for viewing
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,22 @@ | ||
/* | ||
* 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 mockSpaces = [{ | ||
id: 'engineering', | ||
name: 'Engineering', | ||
description: 'This is the Engineering Space', | ||
logo: 'logoKubernetes' | ||
}, { | ||
id: 'sales', | ||
name: 'Sales', | ||
description: 'This is the Sales Space', | ||
logo: 'logoElastic' | ||
}, { | ||
id: 'support', | ||
name: 'Support', | ||
description: 'This is the Support Space', | ||
logo: 'logoElasticStack' | ||
}]; |
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,55 @@ | ||
/* | ||
* 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 { resolve } from 'path'; | ||
import { validateConfig } from './server/lib/validate_config'; | ||
import { checkLicense } from './server/lib/check_license'; | ||
import { initSpacesApi } from './server/routes/api/v1/spaces'; | ||
import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status'; | ||
|
||
export const spaces = (kibana) => new kibana.Plugin({ | ||
id: 'spaces', | ||
configPrefix: 'xpack.spaces', | ||
publicDir: resolve(__dirname, 'public'), | ||
require: ['kibana', 'elasticsearch', 'xpack_main'], | ||
|
||
config(Joi) { | ||
return Joi.object({ | ||
enabled: Joi.boolean().default(true), | ||
}).default(); | ||
}, | ||
|
||
uiExports: { | ||
chromeNavControls: ['plugins/spaces/views/nav_control'], | ||
managementSections: ['plugins/spaces/views/management'], | ||
apps: [{ | ||
id: 'space_selector', | ||
title: 'Spaces', | ||
main: 'plugins/spaces/views/space_selector', | ||
hidden: true, | ||
}], | ||
hacks: [], | ||
home: ['plugins/spaces/register_feature'], | ||
injectDefaultVars: function () { | ||
return { }; | ||
} | ||
}, | ||
|
||
async init(server) { | ||
const thisPlugin = this; | ||
const xpackMainPlugin = server.plugins.xpack_main; | ||
mirrorPluginStatus(xpackMainPlugin, thisPlugin); | ||
|
||
// Register a function that is called whenever the xpack info changes, | ||
// to re-compute the license check results for this plugin | ||
xpackMainPlugin.info.feature(thisPlugin.id).registerLicenseCheckResultsGenerator(checkLicense); | ||
|
||
const config = server.config(); | ||
validateConfig(config, message => server.log(['spaces', 'warning'], message)); | ||
|
||
initSpacesApi(server); | ||
} | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
/* | ||
* 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 { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; | ||
|
||
FeatureCatalogueRegistryProvider.register(() => { | ||
return { | ||
id: 'spaces', | ||
title: 'Spaces', | ||
description: 'You know, for space.', | ||
icon: '/plugins/kibana/assets/app_security.svg', | ||
path: '/app/kibana#/management/spaces/list', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/spaces/public/views/management/components/index.js
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 @@ | ||
/* | ||
* 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 { SpacesGridPage } from './spaces_grid_page'; | ||
export { ManageSpacePage } from './manage_space_page'; |
165 changes: 165 additions & 0 deletions
165
x-pack/plugins/spaces/public/views/management/components/manage_space_page.js
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,165 @@ | ||
/* | ||
* 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 from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
EuiText, | ||
EuiSpacer, | ||
EuiPageContent, | ||
EuiForm, | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiButton, | ||
} from '@elastic/eui'; | ||
|
||
import { Notifier, toastNotifications } from 'ui/notify'; | ||
|
||
export class ManageSpacePage extends React.Component { | ||
state = { | ||
space: {}, | ||
error: null | ||
} | ||
|
||
componentDidMount() { | ||
this.notifier = new Notifier({ location: 'Spaces' }); | ||
|
||
const { | ||
space, | ||
httpAgent, | ||
chrome | ||
} = this.props; | ||
|
||
if (space) { | ||
httpAgent | ||
.get(chrome.addBasePath(`/api/spaces/v1/spaces/${space}`)) | ||
.then(result => { | ||
if (result.data) { | ||
this.setState({ | ||
space: result.data | ||
}); | ||
} | ||
}) | ||
.catch(error => { | ||
this.setState({ | ||
error | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
render() { | ||
const { | ||
name = '', | ||
description = '' | ||
} = this.state.space; | ||
|
||
return ( | ||
<EuiPageContent> | ||
<EuiForm> | ||
<EuiText><h1>{this.getTitle()}</h1></EuiText> | ||
<EuiSpacer /> | ||
<EuiFormRow | ||
label="Name" | ||
helpText="Name your space" | ||
> | ||
<EuiFieldText | ||
name="name" | ||
placeholder={'Awesome space'} | ||
value={name} | ||
onChange={this.onNameChange} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow | ||
label="Description" | ||
helpText="Describe your space" | ||
> | ||
<EuiFieldText | ||
name="description" | ||
placeholder={'This is where the magic happens'} | ||
value={description} | ||
onChange={this.onDescriptionChange} | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton fill onClick={this.saveSpace}>Save</EuiButton> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton onClick={this.backToSpacesList}> | ||
Cancel | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
{this.getActionButtons} | ||
</EuiForm> | ||
</EuiPageContent> | ||
); | ||
} | ||
|
||
getTitle = () => { | ||
const isEditing = !!this.props.space; | ||
if (isEditing) { | ||
return `Edit space`; | ||
} | ||
return `Create a space`; | ||
} | ||
|
||
onNameChange = (e) => { | ||
this.setState({ | ||
space: { | ||
...this.state.space, | ||
name: e.target.value | ||
} | ||
}); | ||
} | ||
|
||
onDescriptionChange = (e) => { | ||
this.setState({ | ||
space: { | ||
...this.state.space, | ||
description: e.target.value | ||
} | ||
}); | ||
} | ||
|
||
saveSpace = () => { | ||
const { | ||
name = '', | ||
id = name.toLowerCase(), | ||
description | ||
} = this.state.space; | ||
|
||
const { httpAgent, chrome } = this.props; | ||
|
||
if (name && description) { | ||
console.log(this.state.space); | ||
httpAgent | ||
.post(chrome.addBasePath(`/api/spaces/v1/spaces/${encodeURIComponent(id)}`), { id, name, description }) | ||
.then(result => { | ||
toastNotifications.addSuccess(`Saved '${result.data.id}'`); | ||
window.location.hash = `#/management/spaces/list`; | ||
}) | ||
.catch(error => { | ||
toastNotifications.addError(error); | ||
}); | ||
} | ||
} | ||
|
||
backToSpacesList = () => { | ||
window.location.hash = `#/management/spaces/list`; | ||
} | ||
} | ||
|
||
ManageSpacePage.propTypes = { | ||
space: PropTypes.string, | ||
httpAgent: PropTypes.func.isRequired, | ||
chrome: PropTypes.object | ||
}; |
Oops, something went wrong.