feature: Support tips at top in StepForm component

Support tips at top in StepForm component

Change-Id: I4cc4e489a81847f0c3b6190576141b9c39d9075e
This commit is contained in:
Jingwei.Zhang 2021-08-20 16:28:30 +08:00 committed by hanxiang gao
parent 3093a201ed
commit 9a955f280b
6 changed files with 35 additions and 14 deletions

View File

@ -42,6 +42,7 @@ export default class BaseForm extends React.Component {
this.response = null; this.response = null;
this.responseError = null; this.responseError = null;
this.formRef = React.createRef(); this.formRef = React.createRef();
this.tipRef = React.createRef();
this.codeError = false; this.codeError = false;
this.currentFormValue = {}; this.currentFormValue = {};
this.init(); this.init();
@ -100,7 +101,7 @@ export default class BaseForm extends React.Component {
} }
get listUrl() { get listUrl() {
return '/base/tmp'; return '';
} }
get isAdminPage() { get isAdminPage() {
@ -386,7 +387,7 @@ export default class BaseForm extends React.Component {
renderTips() { renderTips() {
if (this.tips) { if (this.tips) {
return ( return (
<div className={styles.tips}> <div className={styles.tips} ref={this.tipRef}>
<InfoCircleOutlined className={styles['tips-icon']} /> <InfoCircleOutlined className={styles['tips-icon']} />
{this.tips} {this.tips}
</div> </div>
@ -496,11 +497,28 @@ export default class BaseForm extends React.Component {
} }
render() { render() {
const wrapperPadding =
this.listUrl || this.isStep || (this.isModal && this.tips)
? styles['wrapper-page-padding']
: '';
const tips = this.renderTips();
const formStyle = {};
if ((this.listUrl || this.isStep) && this.tips && this.tipRef.current) {
if (this.isStep) {
const tipHeight = this.tipRef.current.clientHeight + 219;
formStyle.height = `calc(100vh - ${tipHeight}px)`;
} else {
const tipHeight = this.tipRef.current.clientHeight + 66;
formStyle.height = `calc(100% - ${tipHeight}px)`;
}
}
return ( return (
<div className={classnames(styles.wrapper, this.className)}> <div
className={classnames(styles.wrapper, wrapperPadding, this.className)}
>
<Spin spinning={this.isSubmitting}> <Spin spinning={this.isSubmitting}>
{this.renderTips()} {tips}
<div className={classnames(styles.form, 'sl-form')}> <div className={classnames(styles.form, 'sl-form')} style={formStyle}>
{this.renderForms()} {this.renderForms()}
</div> </div>
{this.renderFooter()} {this.renderFooter()}

View File

@ -18,6 +18,10 @@
} }
} }
.wrapper-page-padding {
padding-top: 0;
}
.form { .form {
margin-left: @body-padding * 2; margin-left: @body-padding * 2;
margin-right: @body-padding * 2; margin-right: @body-padding * 2;
@ -86,7 +90,6 @@
.tips { .tips {
padding: 8px 16px; padding: 8px 16px;
background: rgba(89, 157, 255, 0.15); background: rgba(89, 157, 255, 0.15);
margin-top: -16px;
margin-bottom: 16px; margin-bottom: 16px;
} }

View File

@ -1231,7 +1231,6 @@
"Qos Policy": "Qos Policy", "Qos Policy": "Qos Policy",
"Queued": "Queued", "Queued": "Queued",
"Quota Overview": "Quota Overview", "Quota Overview": "Quota Overview",
"Quota Resource": "Quota Resource",
"Quota exceeded": "Quota exceeded", "Quota exceeded": "Quota exceeded",
"Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).", "Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).",
"Quota: Project quotas sufficient resources can be created": "Quota: Project quotas sufficient resources can be created", "Quota: Project quotas sufficient resources can be created": "Quota: Project quotas sufficient resources can be created",
@ -1842,8 +1841,6 @@
"image": "image", "image": "image",
"images": "images", "images": "images",
"ingress": "ingress", "ingress": "ingress",
"insert": "insert",
"insert rule": "insert rule",
"instance": "instance", "instance": "instance",
"instance snapshot": "instance snapshot", "instance snapshot": "instance snapshot",
"instances": "instances", "instances": "instances",
@ -1927,7 +1924,6 @@
"unlock instance": "unlock instance", "unlock instance": "unlock instance",
"unpause instance": "unpause instance", "unpause instance": "unpause instance",
"unshelve instance": "unshelve instance", "unshelve instance": "unshelve instance",
"update": "update",
"update status": "update status", "update status": "update status",
"update template": "update template", "update template": "update template",
"user": "user", "user": "user",

View File

@ -1231,7 +1231,6 @@
"Qos Policy": "QoS策略", "Qos Policy": "QoS策略",
"Queued": "已排队", "Queued": "已排队",
"Quota Overview": "配额概况", "Quota Overview": "配额概况",
"Quota Resource": "Quota(配额)",
"Quota exceeded": "配额用尽", "Quota exceeded": "配额用尽",
"Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "配额:项目配额不足,无法创建资源,请进行资源数量或配额的调整(剩余{ quota },输入{ input })。", "Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "配额:项目配额不足,无法创建资源,请进行资源数量或配额的调整(剩余{ quota },输入{ input })。",
"Quota: Project quotas sufficient resources can be created": "配额:项目配额充足,可创建资源", "Quota: Project quotas sufficient resources can be created": "配额:项目配额充足,可创建资源",
@ -1842,8 +1841,6 @@
"image": "镜像", "image": "镜像",
"images": "镜像", "images": "镜像",
"ingress": "入方向", "ingress": "入方向",
"insert": "",
"insert rule": "插入规则",
"instance": "云主机", "instance": "云主机",
"instance snapshot": "云主机快照", "instance snapshot": "云主机快照",
"instances": "云主机", "instances": "云主机",
@ -1927,7 +1924,6 @@
"unlock instance": "解锁云主机", "unlock instance": "解锁云主机",
"unpause instance": "恢复云主机", "unpause instance": "恢复云主机",
"unshelve instance": "取消归档云主机", "unshelve instance": "取消归档云主机",
"update": "",
"update status": "更新状态", "update status": "更新状态",
"update template": "更新模板", "update template": "更新模板",
"user": "用户", "user": "用户",

View File

@ -25,6 +25,10 @@ import {
@inject('rootStore') @inject('rootStore')
@observer @observer
export default class Parameter extends Base { export default class Parameter extends Base {
get isStep() {
return true;
}
get title() { get title() {
return t('Parameter'); return t('Parameter');
} }

View File

@ -19,6 +19,10 @@ import { yamlTip, validateYaml, paramTip } from 'resources/stack';
@inject('rootStore') @inject('rootStore')
@observer @observer
export default class Template extends Base { export default class Template extends Base {
get isStep() {
return true;
}
get title() { get title() {
return t('Prepare Template'); return t('Prepare Template');
} }