fix: fix ip showing and users database access
1. Fix the ip showing in databse instance 2. Support grant database access in databse users Change-Id: I96f2c9685f9a2c9890005779ff0e8585ad4dfbfb
This commit is contained in:
parent
41eaf509b6
commit
24dbf8e0f9
@ -48,6 +48,20 @@ export class TroveClient extends Base {
|
|||||||
responseKey: 'log',
|
responseKey: 'log',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
extendOperations: [
|
||||||
|
{
|
||||||
|
name: 'grantDatabase',
|
||||||
|
generate: (id, subId, body) => {
|
||||||
|
return this.request.put(
|
||||||
|
`${this.getDetailUrl(
|
||||||
|
'instances',
|
||||||
|
id
|
||||||
|
)}/users/${subId}/databases`,
|
||||||
|
body
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'datastores',
|
name: 'datastores',
|
||||||
|
@ -176,7 +176,6 @@
|
|||||||
"Auto Scaling": "Auto Scaling",
|
"Auto Scaling": "Auto Scaling",
|
||||||
"Auto allocate mac address": "Auto allocate mac address",
|
"Auto allocate mac address": "Auto allocate mac address",
|
||||||
"Auto scaling feature will be enabled": "Auto scaling feature will be enabled",
|
"Auto scaling feature will be enabled": "Auto scaling feature will be enabled",
|
||||||
"Automatic backup": "Automatic backup",
|
|
||||||
"Automatically Assigned Address": "Automatically Assigned Address",
|
"Automatically Assigned Address": "Automatically Assigned Address",
|
||||||
"Automatically repair unhealhty nodes": "Automatically repair unhealhty nodes",
|
"Automatically repair unhealhty nodes": "Automatically repair unhealhty nodes",
|
||||||
"Availability Zone": "Availability Zone",
|
"Availability Zone": "Availability Zone",
|
||||||
@ -989,6 +988,7 @@
|
|||||||
"Glance": "Glance",
|
"Glance": "Glance",
|
||||||
"Global Setting": "Global Setting",
|
"Global Setting": "Global Setting",
|
||||||
"GlusterFS": "GlusterFS",
|
"GlusterFS": "GlusterFS",
|
||||||
|
"Grant Databases Access": "Grant Databases Access",
|
||||||
"Greece": "Greece",
|
"Greece": "Greece",
|
||||||
"Greenland": "Greenland",
|
"Greenland": "Greenland",
|
||||||
"Grenada": "Grenada",
|
"Grenada": "Grenada",
|
||||||
@ -1366,7 +1366,6 @@
|
|||||||
"Management": "Management",
|
"Management": "Management",
|
||||||
"Management Reason": "Management Reason",
|
"Management Reason": "Management Reason",
|
||||||
"Manu": "Manu",
|
"Manu": "Manu",
|
||||||
"Manual backup": "Manual backup",
|
|
||||||
"Manual input": "Manual input",
|
"Manual input": "Manual input",
|
||||||
"Manually Assigned Address": "Manually Assigned Address",
|
"Manually Assigned Address": "Manually Assigned Address",
|
||||||
"Manually Specify": "Manually Specify",
|
"Manually Specify": "Manually Specify",
|
||||||
@ -2662,6 +2661,7 @@
|
|||||||
"flavor": "flavor",
|
"flavor": "flavor",
|
||||||
"floating ip": "floating ip",
|
"floating ip": "floating ip",
|
||||||
"floating ips": "floating ips",
|
"floating ips": "floating ips",
|
||||||
|
"gigabytes": "gigabytes",
|
||||||
"heat services": "heat services",
|
"heat services": "heat services",
|
||||||
"host aggregates": "host aggregates",
|
"host aggregates": "host aggregates",
|
||||||
"hosts": "hosts",
|
"hosts": "hosts",
|
||||||
|
@ -176,7 +176,6 @@
|
|||||||
"Auto Scaling": "自动缩放",
|
"Auto Scaling": "自动缩放",
|
||||||
"Auto allocate mac address": "自动分配MAC地址",
|
"Auto allocate mac address": "自动分配MAC地址",
|
||||||
"Auto scaling feature will be enabled": "将启用自动缩放功能",
|
"Auto scaling feature will be enabled": "将启用自动缩放功能",
|
||||||
"Automatic backup": "自动备份",
|
|
||||||
"Automatically Assigned Address": "自动分配地址",
|
"Automatically Assigned Address": "自动分配地址",
|
||||||
"Automatically repair unhealhty nodes": "自动修复不健康的节点",
|
"Automatically repair unhealhty nodes": "自动修复不健康的节点",
|
||||||
"Availability Zone": "可用域",
|
"Availability Zone": "可用域",
|
||||||
@ -989,6 +988,7 @@
|
|||||||
"Glance": "",
|
"Glance": "",
|
||||||
"Global Setting": "平台配置",
|
"Global Setting": "平台配置",
|
||||||
"GlusterFS": "",
|
"GlusterFS": "",
|
||||||
|
"Grant Databases Access": "设置数据库访问",
|
||||||
"Greece": "希腊",
|
"Greece": "希腊",
|
||||||
"Greenland": "格陵兰",
|
"Greenland": "格陵兰",
|
||||||
"Grenada": "格林纳达",
|
"Grenada": "格林纳达",
|
||||||
@ -1366,7 +1366,6 @@
|
|||||||
"Management": "维护",
|
"Management": "维护",
|
||||||
"Management Reason": "维护原因",
|
"Management Reason": "维护原因",
|
||||||
"Manu": "手动",
|
"Manu": "手动",
|
||||||
"Manual backup": "手动备份",
|
|
||||||
"Manual input": "手动输入",
|
"Manual input": "手动输入",
|
||||||
"Manually Assigned Address": "手动分配地址",
|
"Manually Assigned Address": "手动分配地址",
|
||||||
"Manually Specify": "手动指定",
|
"Manually Specify": "手动指定",
|
||||||
@ -2662,6 +2661,7 @@
|
|||||||
"flavor": "云主机类型",
|
"flavor": "云主机类型",
|
||||||
"floating ip": "浮动IP",
|
"floating ip": "浮动IP",
|
||||||
"floating ips": "浮动IP",
|
"floating ips": "浮动IP",
|
||||||
|
"gigabytes": "容量",
|
||||||
"heat services": "编排服务",
|
"heat services": "编排服务",
|
||||||
"host aggregates": "主机集合",
|
"host aggregates": "主机集合",
|
||||||
"hosts": "主机",
|
"hosts": "主机",
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// 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';
|
||||||
import { InstanceStatus, policyType } from 'resources/trove/database';
|
import { InstanceStatus, policyType } from 'resources/trove/database';
|
||||||
@ -104,7 +105,17 @@ export class BaseDetail extends Base {
|
|||||||
{
|
{
|
||||||
label: t('Host'),
|
label: t('Host'),
|
||||||
dataIndex: 'ip',
|
dataIndex: 'ip',
|
||||||
render: (value) => (value ? value.map((it) => it) : '-'),
|
render: (value) => {
|
||||||
|
return value && value.length ? (
|
||||||
|
<span>
|
||||||
|
{value.map((it) => (
|
||||||
|
<div key={it}>{it}</div>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Database Port'),
|
label: t('Database Port'),
|
||||||
|
@ -14,10 +14,16 @@
|
|||||||
|
|
||||||
import DeleteUser from './UserDelete';
|
import DeleteUser from './UserDelete';
|
||||||
import CreateUser from './UserCreate';
|
import CreateUser from './UserCreate';
|
||||||
|
import UserDatabase from './UserDatabase';
|
||||||
|
|
||||||
const actionConfigs = {
|
const actionConfigs = {
|
||||||
rowActions: {
|
rowActions: {
|
||||||
firstAction: DeleteUser,
|
firstAction: DeleteUser,
|
||||||
|
moreActions: [
|
||||||
|
{
|
||||||
|
action: UserDatabase,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
batchActions: [DeleteUser],
|
batchActions: [DeleteUser],
|
||||||
primaryActions: [CreateUser],
|
primaryActions: [CreateUser],
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
// Copyright 2021 99cloud
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { inject, observer } from 'mobx-react';
|
||||||
|
import ModalAction from 'containers/Action/ModalAction';
|
||||||
|
import globalInstancesUsersStore from 'stores/trove/instances-user';
|
||||||
|
import { InstancesDatabasesStore } from 'stores/trove/instances-database';
|
||||||
|
|
||||||
|
export class UserDatabase extends ModalAction {
|
||||||
|
init() {
|
||||||
|
this.store = globalInstancesUsersStore;
|
||||||
|
this.databaseStore = new InstancesDatabasesStore();
|
||||||
|
this.fetchDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
static id = 'grant-databases-access';
|
||||||
|
|
||||||
|
static title = t('Grant Databases Access');
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return t('Grant Databases Access');
|
||||||
|
}
|
||||||
|
|
||||||
|
static policy = 'instance:extension:user_access:update';
|
||||||
|
|
||||||
|
static allowed() {
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchDatabase() {
|
||||||
|
const { containerProps: { detail: { id } = {} } = {} } = this.props;
|
||||||
|
await this.databaseStore.fetchList({ id });
|
||||||
|
this.updateDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
get database() {
|
||||||
|
return (this.databaseStore.list.data || []).map((it) => ({
|
||||||
|
label: it.name,
|
||||||
|
value: it.name,
|
||||||
|
key: it.name,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
get defaultValue() {
|
||||||
|
const { name, databases } = this.item;
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
database: databases,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
get formItems() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
label: t('Name'),
|
||||||
|
type: 'input-name',
|
||||||
|
required: true,
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'database',
|
||||||
|
label: t('Database'),
|
||||||
|
type: 'select',
|
||||||
|
options: this.database,
|
||||||
|
mode: 'multiple',
|
||||||
|
required: true,
|
||||||
|
loading: this.databaseStore.list.isLoading,
|
||||||
|
disabled: this.databaseStore.list.isLoading,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit = (values, containerProps) => {
|
||||||
|
const { detail: { id } = {} } = containerProps;
|
||||||
|
const data = {
|
||||||
|
databases: values.database.map((it) => ({ name: it })),
|
||||||
|
};
|
||||||
|
return this.store.grantDatabaseAccess({ id, name: values.name, data });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default inject('rootStore')(observer(UserDatabase));
|
@ -12,6 +12,7 @@
|
|||||||
// 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 Base from 'containers/List';
|
import Base from 'containers/List';
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import { InstancesUsersStore } from 'stores/trove/instances-user';
|
import { InstancesUsersStore } from 'stores/trove/instances-user';
|
||||||
@ -58,6 +59,17 @@ export class Users extends Base {
|
|||||||
{
|
{
|
||||||
title: t('Databases'),
|
title: t('Databases'),
|
||||||
dataIndex: 'databases',
|
dataIndex: 'databases',
|
||||||
|
render: (value) => {
|
||||||
|
return value.length ? (
|
||||||
|
<span>
|
||||||
|
{value.map((it) => (
|
||||||
|
<div key={it}>{it}</div>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// 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 { observer, inject } from 'mobx-react';
|
import { observer, inject } from 'mobx-react';
|
||||||
import Base from 'containers/List';
|
import Base from 'containers/List';
|
||||||
import globalInstancesStore from 'stores/trove/instances';
|
import globalInstancesStore from 'stores/trove/instances';
|
||||||
@ -65,6 +66,17 @@ export class Instances extends Base {
|
|||||||
{
|
{
|
||||||
title: t('Host'),
|
title: t('Host'),
|
||||||
dataIndex: 'ip',
|
dataIndex: 'ip',
|
||||||
|
render: (value) => {
|
||||||
|
return value && value.length ? (
|
||||||
|
<>
|
||||||
|
{value.map((it) => (
|
||||||
|
<div key={it}>{it}</div>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
'-'
|
||||||
|
);
|
||||||
|
},
|
||||||
isHideable: true,
|
isHideable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,10 @@ export class InstancesUsersStore extends Base {
|
|||||||
return client.trove.instances.databases;
|
return client.trove.instances.databases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get instanceClient() {
|
||||||
|
return client.trove.instances;
|
||||||
|
}
|
||||||
|
|
||||||
get isSubResource() {
|
get isSubResource() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -46,11 +50,9 @@ export class InstancesUsersStore extends Base {
|
|||||||
const { databases = [] } = await this.databaseClient.list(id);
|
const { databases = [] } = await this.databaseClient.list(id);
|
||||||
return items.map((it) => ({
|
return items.map((it) => ({
|
||||||
...it,
|
...it,
|
||||||
databases:
|
databases: (it.databases || [])
|
||||||
(it.databases || [])
|
|
||||||
.filter((l1) => databases.find((l2) => l2.name === l1.name))
|
.filter((l1) => databases.find((l2) => l2.name === l1.name))
|
||||||
.map((db) => db.name)
|
.map((db) => db.name),
|
||||||
.join(' , ') || '-',
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +65,11 @@ export class InstancesUsersStore extends Base {
|
|||||||
async deleteUser({ id, name }) {
|
async deleteUser({ id, name }) {
|
||||||
return this.submitting(this.client.delete(id, name));
|
return this.submitting(this.client.delete(id, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
async grantDatabaseAccess({ id, name, data }) {
|
||||||
|
return this.submitting(this.instanceClient.grantDatabase(id, name, data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalInstancesUsersStore = new InstancesUsersStore();
|
const globalInstancesUsersStore = new InstancesUsersStore();
|
||||||
|
Loading…
Reference in New Issue
Block a user