fix: Fix create/delete certificate && menu

1. Fix delete server/ca certificate
2. Update cert display in detail page
3. Add default type when create cert
4. Display the cert list page based on the barbican endpoint
5. Temporarily remove network topology e2e because of cypress crashes

Change-Id: Ie0f01bd7c818b4c553351cc1cd8549e79a301c29
This commit is contained in:
Jingwei.Zhang 2022-06-01 11:31:47 +08:00
parent 276f554ed6
commit 2fd46f588c
8 changed files with 72 additions and 24 deletions

View File

@ -83,6 +83,10 @@ export default class BaseDetail extends React.Component {
return false; return false;
} }
get leftCardsStyle() {
return {};
}
getRouteName(routeName) { getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName; return this.isAdminPage ? `${routeName}Admin` : routeName;
} }
@ -181,7 +185,11 @@ export default class BaseDetail extends React.Component {
render() { render() {
return ( return (
<div className={classnames(styles.main)}> <div className={classnames(styles.main)}>
<div className={styles['left-side']} id="detail-left-side"> <div
className={styles['left-side']}
id="detail-left-side"
style={this.leftCardsStyle}
>
{this.renderLeftCards()} {this.renderLeftCards()}
</div> </div>
<div className={styles['right-side']} id="detail-right-side"> <div className={styles['right-side']} id="detail-right-side">

View File

@ -351,6 +351,7 @@ const renderMenu = (t) => {
path: '/network/certificate', path: '/network/certificate',
name: t('Certificate Management'), name: t('Certificate Management'),
key: 'certificate', key: 'certificate',
endpoints: 'barbican',
level: 1, level: 1,
children: [ children: [
{ {

View File

@ -12,13 +12,23 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
export class BaseDetail extends Base { export class BaseDetail extends Base {
get leftCardsStyle() {
return {
flex: 1,
};
}
get leftCards() { get leftCards() {
const cards = [this.contentCard, this.keyPairCard]; return [this.contentCard];
return cards; }
get rightCards() {
return [this.keyPairCard];
} }
get contentCard() { get contentCard() {
@ -27,13 +37,14 @@ export class BaseDetail extends Base {
secret_refs.find((it) => it.name === 'certificate') || {}; secret_refs.find((it) => it.name === 'certificate') || {};
const options = [ const options = [
{ {
content: secret_info.payload, content: <pre>{secret_info.payload}</pre>,
copyable: true, copyable: true,
}, },
]; ];
return { return {
title: t('Certificate Content'), title: t('Certificate Content'),
labelCol: 0, labelCol: 0,
contentCol: 24,
options, options,
}; };
} }
@ -44,13 +55,14 @@ export class BaseDetail extends Base {
secret_refs.find((it) => it.name === 'private_key') || {}; secret_refs.find((it) => it.name === 'private_key') || {};
const options = [ const options = [
{ {
content: secret_info.payload, content: <pre>{secret_info.payload}</pre>,
copyable: true, copyable: true,
}, },
]; ];
return { return {
title: t('Private Key'), title: t('Private Key'),
labelCol: 0, labelCol: 0,
contentCol: 24,
options, options,
}; };
} }

View File

@ -12,10 +12,17 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
export class BaseDetail extends Base { export class BaseDetail extends Base {
get leftCardsStyle() {
return {
flex: 1,
};
}
get leftCards() { get leftCards() {
const cards = [this.contentCard]; const cards = [this.contentCard];
return cards; return cards;
@ -25,13 +32,14 @@ export class BaseDetail extends Base {
const { payload } = this.props.detail; const { payload } = this.props.detail;
const options = [ const options = [
{ {
content: payload, content: <pre>{payload}</pre>,
copyable: true, copyable: true,
}, },
]; ];
return { return {
title: t('Certificate Content'), title: t('Certificate Content'),
labelCol: 0, labelCol: 0,
contentCol: 24,
options, options,
}; };
} }

View File

@ -23,6 +23,7 @@ import {
} from 'resources/octavia/secrets'; } from 'resources/octavia/secrets';
import globalContainersStore from 'stores/barbican/containers'; import globalContainersStore from 'stores/barbican/containers';
import moment from 'moment'; import moment from 'moment';
import { parse } from 'qs';
export class CreateAction extends ModalAction { export class CreateAction extends ModalAction {
static id = 'create-certificate'; static id = 'create-certificate';
@ -49,13 +50,21 @@ export class CreateAction extends ModalAction {
get defaultValue() { get defaultValue() {
const data = { const data = {
mode: 'SERVER', mode: this.typeTab,
}; };
return data; return data;
} }
get typeTab() {
const { location: { search = '' } = {} } = this.containerProps;
const params = parse(search.slice(1));
return params.tab || 'SERVER';
}
get certificateModeOptions() { get certificateModeOptions() {
return getOptions(certificateMode); return getOptions(certificateMode).filter((it) => {
return it.value === this.typeTab;
});
} }
validateDomain = (rule, value) => { validateDomain = (rule, value) => {
@ -129,6 +138,7 @@ export class CreateAction extends ModalAction {
tip: certificateContentTip, tip: certificateContentTip,
validator: this.validateCertificateContent, validator: this.validateCertificateContent,
required: true, required: true,
rows: 6,
}, },
{ {
name: 'private_key', name: 'private_key',
@ -140,6 +150,7 @@ export class CreateAction extends ModalAction {
validator: this.validateCertificateKeyPair, validator: this.validateCertificateKeyPair,
required: true, required: true,
display: mode === 'SERVER', display: mode === 'SERVER',
rows: 6,
}, },
{ {
name: 'domain', name: 'domain',

View File

@ -40,6 +40,17 @@ export class ContainersStore extends Base {
offset, offset,
}); });
get mapper() {
return (data) => {
const { container_ref } = data;
const [, uuid] = container_ref.split('/containers/');
return {
...data,
id: uuid,
};
};
}
async requestListAllByLimit(params, limit) { async requestListAllByLimit(params, limit) {
let hasNext = true; let hasNext = true;
let data = []; let data = [];
@ -60,8 +71,7 @@ export class ContainersStore extends Base {
if (items.length === 0) return items; if (items.length === 0) return items;
const secrets = await this.secretStore.fetchList({ mode: 'SERVER' }); const secrets = await this.secretStore.fetchList({ mode: 'SERVER' });
const newItems = items.map((it) => { const newItems = items.map((it) => {
const { container_ref = '', secret_refs = [] } = it; const { secret_refs = [] } = it;
const [, uuid] = container_ref.split('/containers/');
if (secret_refs.length === 0) { if (secret_refs.length === 0) {
it.hidden = true; it.hidden = true;
} else { } else {
@ -84,7 +94,6 @@ export class ContainersStore extends Base {
} }
return { return {
...it, ...it,
id: uuid,
}; };
}); });
return newItems.filter((it) => it.hidden !== true); return newItems.filter((it) => it.hidden !== true);

View File

@ -40,6 +40,17 @@ export class SecretsStore extends Base {
offset, offset,
}); });
get mapper() {
return (data) => {
const { secret_ref } = data;
const [, uuid] = secret_ref.split('/secrets/');
return {
...data,
id: uuid,
};
};
}
async requestListAllByLimit(params, limit) { async requestListAllByLimit(params, limit) {
let hasNext = true; let hasNext = true;
let data = []; let data = [];
@ -56,18 +67,6 @@ export class SecretsStore extends Base {
return data; return data;
} }
listDidFetch(items) {
if (items.length === 0) return items;
return items.map((it) => {
const { secret_ref = '' } = it;
const [, uuid] = secret_ref.split('/secrets/');
return {
...it,
id: uuid,
};
});
}
@action @action
async fetchDetail({ id, silent }) { async fetchDetail({ id, silent }) {
if (!silent) { if (!silent) {

View File

@ -27,4 +27,4 @@ testFiles:
- pages/network/security-group.spec.js - pages/network/security-group.spec.js
- pages/network/vpn.spec.js - pages/network/vpn.spec.js
- pages/network/lb.spec.js - pages/network/lb.spec.js
- pages/network/topology.spec.js # - pages/network/topology.spec.js