fix: extra button control

main
jialin 10 months ago
parent 092aeceb9d
commit f80daf6cd4

@ -1,5 +1,4 @@
{
"concurrent": 2,
"*.{md,json}": ["prettier --cache --write"],
"*.{js,jsx}": ["max lint --fix --eslint-only", "prettier --cache --write"],
"*.{css,less}": [
@ -9,5 +8,6 @@
"*.ts?(x)": [
"max lint --fix --eslint-only",
"prettier --cache --parser=typescript --write"
]
],
"src/locales/**/*.ts": ["npx tsx src/locales/check.ts"]
}

@ -51,7 +51,7 @@ const RowPrefix: React.FC<RowPrefixProps> = (props) => {
<IconFont
type="icon-down"
rotate={isExpanded ? 0 : -90}
className="size-14"
style={{ fontSize: '12px' }}
></IconFont>
</Button>
) : (
@ -78,7 +78,7 @@ const RowPrefix: React.FC<RowPrefixProps> = (props) => {
<IconFont
type="icon-down"
rotate={isExpanded ? 0 : -90}
className="size-14"
style={{ fontSize: '12px' }}
></IconFont>
</Button>
) : (

@ -1,5 +1,3 @@
import IconFont from '@/components/icon-font';
/**
* Language configuration map
* Warning: The key of the map must be the same as the directory name in the locales directory
@ -70,7 +68,7 @@ const langConfigMap = {
'en-US': {
lang: 'en-US',
label: 'English',
icon: <IconFont type="icon-English" />,
icon: '🇺🇸',
title: 'Language'
},
'es-ES': {
@ -322,7 +320,7 @@ const langConfigMap = {
'zh-CN': {
lang: 'zh-CN',
label: '简体中文',
icon: <IconFont type="icon-chinese" />,
icon: '🇨🇳',
title: '语言'
},
'zh-TW': {

@ -5,7 +5,14 @@ import { CloseOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Drawer } from 'antd';
import _ from 'lodash';
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
import React, {
memo,
useCallback,
useEffect,
useMemo,
useRef,
useState
} from 'react';
import styled from 'styled-components';
import { queryCatalogItemSpec } from '../apis';
import {
@ -448,6 +455,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
axiosToken.current?.cancel?.();
}, [onCancel]);
const showExtraButton = useMemo(() => {
return warningStatus.show && warningStatus.type !== 'success';
}, [warningStatus.show, warningStatus.type]);
useEffect(() => {
if (open) {
fetchSpecData();
@ -542,12 +553,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
<ModalFooter
onCancel={handleCancel}
onOk={handleSumit}
showOkBtn={
!warningStatus.show || warningStatus.type === 'success'
}
showOkBtn={!showExtraButton}
extra={
warningStatus.show &&
warningStatus.type !== 'success' && (
showExtraButton && (
<Button
type="primary"
onClick={handleSubmitAnyway}

@ -4,7 +4,7 @@ import { CloseOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Drawer } from 'antd';
import _, { debounce } from 'lodash';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import styled from 'styled-components';
import {
backendOptionsMap,
@ -229,6 +229,10 @@ const AddModal: FC<AddModalProps> = (props) => {
}
};
const showExtraButton = useMemo(() => {
return warningStatus.show && warningStatus.type !== 'success';
}, [warningStatus.show, warningStatus.type]);
useEffect(() => {
if (open) {
handleOnOpen();
@ -338,12 +342,9 @@ const AddModal: FC<AddModalProps> = (props) => {
<ModalFooter
onCancel={handleCancel}
onOk={handleSumit}
showOkBtn={
!warningStatus.show || warningStatus.type === 'success'
}
showOkBtn={!showExtraButton}
extra={
warningStatus.show &&
warningStatus.type !== 'success' && (
showExtraButton && (
<Button
type="primary"
onClick={handleSubmitAnyway}

@ -141,6 +141,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
const data = form.getFieldsValue?.();
const res = handleBackendChangeBefore(data);
console.log('res+++++++++++', res);
if (res.show) {
return;
}
@ -393,6 +394,14 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
onCancel?.();
};
const showExtraButton = useMemo(() => {
return (
warningStatus.show &&
warningStatus.type !== 'success' &&
!warningStatus.isDefault
);
}, [warningStatus.show, warningStatus.type, warningStatus.isDefault]);
useEffect(() => {
if (open && formData) {
setOriginalFormData();
@ -441,15 +450,9 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
<ModalFooter
onCancel={onCancel}
onOk={handleSumit}
showOkBtn={
!warningStatus.show ||
warningStatus.type === 'success' ||
warningStatus.isDefault
}
showOkBtn={!showExtraButton}
extra={
warningStatus.show &&
warningStatus.type !== 'success' &&
!warningStatus.isDefault && (
showExtraButton && (
<Button
type="primary"
onClick={handleSubmitAnyway}

Loading…
Cancel
Save