diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx index d16bf11d..ff0c6259 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx @@ -96,6 +96,12 @@ export class SystemStep extends Base { })); } + get serverGroupRequired() { + const { more } = this.state; + const { servergroup } = this.locationParams; + return !!servergroup && more; + } + get inputHelp() { const { input = '' } = this.state; const maxCount = 1000; @@ -370,6 +376,7 @@ export class SystemStep extends Base { hidden: !more, data: this.serverGroups, isLoading: this.serverGroupStore.list.isLoading, + required: this.serverGroupRequired, extra: t( 'Using server groups, you can create cloud hosts on the same/different physical nodes as much as possible to meet the affinity/non-affinity requirements of business applications.' ), diff --git a/src/pages/compute/containers/ServerGroup/actions/CreateInstance.jsx b/src/pages/compute/containers/ServerGroup/actions/CreateInstance.jsx new file mode 100644 index 00000000..06a88e91 --- /dev/null +++ b/src/pages/compute/containers/ServerGroup/actions/CreateInstance.jsx @@ -0,0 +1,34 @@ +// Copyright 2022 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 CreateInstance from 'pages/compute/containers/Instance/actions/StepCreate'; + +export class StepCreate extends CreateInstance { + static id = 'instance-create'; + + static title = t('Create Instance'); + + static path(item) { + return `/compute/instance/create?servergroup=${item.id}`; + } + + static policy = 'os_compute_api:servers:create'; + + static allowed() { + return true; + } +} + +export default inject('rootStore')(observer(StepCreate)); diff --git a/src/pages/compute/containers/ServerGroup/actions/index.jsx b/src/pages/compute/containers/ServerGroup/actions/index.jsx index bd6b65f2..d61dc58d 100644 --- a/src/pages/compute/containers/ServerGroup/actions/index.jsx +++ b/src/pages/compute/containers/ServerGroup/actions/index.jsx @@ -14,10 +14,16 @@ import Create from './Create'; import Delete from './Delete'; +import CreateInstance from './CreateInstance'; const actionConfigs = { rowActions: { firstAction: Delete, + moreActions: [ + { + action: CreateInstance, + }, + ], }, batchActions: [Delete], primaryActions: [Create],