diff --git a/app/components/Secrets/Generic/Generic.jsx b/app/components/Secrets/Generic/Generic.jsx
index 6cebaf9..dd59637 100644
--- a/app/components/Secrets/Generic/Generic.jsx
+++ b/app/components/Secrets/Generic/Generic.jsx
@@ -59,6 +59,9 @@ class GenericSecretBackend extends React.Component {
wrapPath: null,
useRootKey: window.localStorage.getItem("useRootKey") === 'true' || false,
rootKey: window.localStorage.getItem("secretsRootKey") || '',
+ description: '',
+ disableDescEdit: true,
+ genericName: ''
}
_.bindAll(
@@ -71,7 +74,13 @@ class GenericSecretBackend extends React.Component {
'DeleteObject',
'renderNewObjectDialog',
'renderEditObjectDialog',
- 'renderDeleteConfirmationDialog'
+ 'renderDeleteConfirmationDialog',
+ /*
+ TODO:
+ Waiting on the ability to update mount description: https://github.com/hashicorp/vault/issues/2645
+ 'editDescription',
+ 'updateDescription'
+ */
);
}
@@ -131,11 +140,54 @@ class GenericSecretBackend extends React.Component {
})
}
+ getMountDescription() {
+ this.setState({ genericName: this.props.params.namespace });
+ tokenHasCapabilities(['read'], 'sys/mounts')
+ .then(() => {
+ callVaultApi('get', 'sys/mounts')
+ .then((resp) => {
+ let desc = _.get(resp, `data.data.${this.state.genericName}/.description`, null);
+ if (desc) this.setState({ description: desc })
+ });
+ })
+ .catch();
+ }
+
+ /*
+ TODO:
+ Waiting on the ability to update mount description: https://github.com/hashicorp/vault/issues/2645
+
+ editDescription() {
+ let uri = `/sys/mounts/${this.state.genericName}`;
+ tokenHasCapabilities(['post'], uri)
+ .then(() => {
+ this.setState({ disableDescEdit: false });
+ })
+ .catch();
+ }
+
+ updateDescription() {
+ let uri = `/sys/mounts/${this.state.genericName}`;
+ tokenHasCapabilities(['post'], uri)
+ .then(() => {
+ callVaultApi('post', uri, {}, { description: this.state.description, type: 'generic', path: this.state.genericName })
+ .then((resp) => {
+ snackBarMessage('Description updated')
+ })
+ .catch((error) => {
+ snackBarMessage(error);
+ });
+ })
+ .catch();
+ }
+ */
+
componentWillMount() {
this.setState({ currentLogicalPath: `${this.props.params.namespace}/${this.props.params.splat}` })
}
componentDidMount() {
+ this.getMountDescription();
if (this.isPathDirectory(this.props.params.splat)) {
this.loadSecretsList();
} else {
@@ -148,13 +200,15 @@ class GenericSecretBackend extends React.Component {
if (!_.isEqual(this.props.params.namespace, nextProps.params.namespace)) {
// Reset
this.setState({
- secretList: []
+ secretList: [],
+ description: ''
})
}
}
componentDidUpdate(prevProps) {
if (!_.isEqual(this.props.params, prevProps.params)) {
+ this.getMountDescription();
if (this.isPathDirectory(this.props.params.splat)) {
this.loadSecretsList();
} else {
@@ -432,7 +486,29 @@ class GenericSecretBackend extends React.Component {
{this.renderDeleteConfirmationDialog()}
+ {backend.description &&
+ {backend.description}
+ }
+ type: {backend.type}
+
+ }
+ type: {backend.type}
+