Skip to content

Commit

Permalink
chore: adjust the deletion modal config
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Dec 24, 2024
1 parent 762ab30 commit 02391e6
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/components/delete-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const DeleteModal = forwardRef((props, ref) => {
okText?: string;
cancelText?: string;
title?: string;
operation: string;
}
>({});

Expand All @@ -27,6 +28,7 @@ const DeleteModal = forwardRef((props, ref) => {
title?: string;
cancelText?: string;
okText?: string;
operation: string;
}
) => {
setConfig(data);
Expand Down Expand Up @@ -94,9 +96,7 @@ const DeleteModal = forwardRef((props, ref) => {
config.content &&
intl.formatMessage(
{
id: config.selection
? 'common.delete.confirm'
: 'common.delete.single.confirm'
id: config.operation || ''
},
{
type: intl.formatMessage({ id: config.content }),
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en-US/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export default {
'Are you sure you want to delete the selected {type}?',
'common.delete.single.confirm':
'Are you sure you want to delete <span style="font-size: 13px;font-weight: 700">{name}</span>?',
'common.stop.confirm': 'Are you sure you want to stop the selected {type}?',
'common.stop.single.confirm':
'Are you sure you want to stop <span style="font-size: 13px;font-weight: 700">{name}</span>?',
'common.filter.name': 'Filter by name',
'common.form.password': 'Password',
'common.form.username': 'Username',
Expand All @@ -204,6 +207,7 @@ export default {
'common.button.docs': 'Documentation',
'common.button.version': 'Version',
'common.title.delete.confirm': 'Confirm delete',
'common.title.stop.confirm': 'Confirm stop',
'common.title.recreate.confirm': 'Confirm recreate',
'common.button.addLabel': 'Add Labels',
'common.button.addSelector': 'Add Selectors',
Expand Down
4 changes: 4 additions & 0 deletions src/locales/zh-CN/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export default {
'common.delete.confirm': '删除选中的{type},确定吗?',
'common.delete.single.confirm':
'删除 <span style="font-size: 13px;font-weight: 700">{name}</span>,确定吗?',
'common.stop.confirm': '停止选中的{type},确定吗?',
'common.stop.single.confirm':
'停止 <span style="font-size: 13px;font-weight: 700">{name}</span>,确定吗?',
'common.filter.name': '名称查询',
'common.form.password': '密码',
'common.form.username': '用户名',
Expand All @@ -197,6 +200,7 @@ export default {
'common.button.docs': '文档',
'common.button.version': '版本',
'common.title.delete.confirm': '确认删除',
'common.title.stop.confirm': '确认',
'common.title.recreate.confirm': '确认重新创建',
'common.button.addLabel': '添加标签',
'common.button.addSelector': '添加选择器',
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api-keys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const APIKeys: React.FC = () => {
const handleDelete = (row: ListItem) => {
modalRef.current.show({
content: 'apikeys.table.apikeys',
operation: 'common.delete.single.confirm',
name: row.name,
async onOk() {
console.log('OK');
Expand All @@ -130,6 +131,7 @@ const APIKeys: React.FC = () => {
const handleDeleteBatch = () => {
modalRef.current.show({
content: 'apikeys.table.apikeys',
operation: 'common.delete.confirm',
selection: true,
async onOk() {
await handleBatchRequest(rowSelection.selectedRowKeys, deleteApisKey);
Expand Down
45 changes: 41 additions & 4 deletions src/pages/llmodels/components/table-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const Models: React.FC<ModelsProps> = ({
message.success(intl.formatMessage({ id: 'common.message.success' }));
};

const handleToggleStart = async (row: ListItem, action: string) => {
const handleStartModel = async (row: ListItem) => {
try {
await updateModel({
id: row.id,
Expand All @@ -313,7 +313,28 @@ const Models: React.FC<ModelsProps> = ({
'updated_at',
'rowIndex'
]),
replicas: action === 'start' ? 1 : 0
replicas: 1
}
});
message.success(intl.formatMessage({ id: 'common.message.success' }));
} catch (error) {
// ingore
}
};

const handleStopModel = async (row: ListItem) => {
try {
await updateModel({
id: row.id,
data: {
..._.omit(row, [
'id',
'ready_replicas',
'created_at',
'updated_at',
'rowIndex'
]),
replicas: 0
}
});
message.success(intl.formatMessage({ id: 'common.message.success' }));
Expand Down Expand Up @@ -385,6 +406,7 @@ const Models: React.FC<ModelsProps> = ({
const handleDelete = async (row: any) => {
modalRef.current.show({
content: 'models.table.models',
operation: 'common.delete.single.confirm',
name: row.name,
async onOk() {
await deleteModel(row.id);
Expand All @@ -398,6 +420,7 @@ const Models: React.FC<ModelsProps> = ({
const handleDeleteBatch = () => {
modalRef.current.show({
content: 'models.table.models',
operation: 'common.delete.confirm',
selection: true,
async onOk() {
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
Expand Down Expand Up @@ -450,6 +473,7 @@ const Models: React.FC<ModelsProps> = ({
modalRef.current.show({
content: 'models.instances',
okText: 'common.button.delrecreate',
operation: 'common.delete.single.confirm',
name: row.name,
async onOk() {
await deleteModelInstance(row.id);
Expand Down Expand Up @@ -487,8 +511,21 @@ const Models: React.FC<ModelsProps> = ({
if (val === 'delete') {
handleDelete(row);
}
if (val === 'start' || val === 'stop') {
handleToggleStart(row, val);
if (val === 'start') {
handleStartModel(row);
}

if (val === 'stop') {
modalRef.current.show({
content: 'models.instances',
title: 'common.title.stop.confirm',
okText: 'common.button.stop',
operation: 'common.stop.single.confirm',
name: row.name,
async onOk() {
await handleStopModel(row);
}
});
}
},
[handleEdit, handleOpenPlayGround, handleDelete]
Expand Down
12 changes: 6 additions & 6 deletions src/pages/llmodels/config/llama-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const options = [
value: '--image-strength'
},
{
label: '--image-sampler',
value: '--image-sampler',
label: '--image-sample-method',
value: '--image-sample-method',
options: [
'euler_a',
'euler',
Expand All @@ -65,8 +65,8 @@ const options = [
]
},
{
label: '--image-sampler-steps',
value: '--image-sample-steps'
label: '--image-sampling-steps',
value: '--image-sampling-steps'
},
{
label: '--image-cfg-scale',
Expand All @@ -85,8 +85,8 @@ const options = [
value: '--image-slg-end'
},
{
label: '--image-schedule',
value: '--image-schedule',
label: '--image-schedule-method',
value: '--image-schedule-method',
options: ['default', 'discrete', 'karras', 'exponential', 'ays', 'gits']
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resources/components/add-worker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
width={600}
styles={{
body: {
height: 410
height: 420
}
}}
footer={null}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/resources/components/workers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const Resources: React.FC = () => {
const handleDelete = (row: ListItem) => {
modalRef.current.show({
content: 'worker',
operation: 'common.delete.single.confirm',
name: row.name,
async onOk() {
console.log('OK');
Expand All @@ -161,6 +162,7 @@ const Resources: React.FC = () => {
const handleDeleteBatch = () => {
modalRef.current.show({
content: 'wokers',
operation: 'common.delete.confirm',
selection: true,
async onOk() {
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
Expand Down
2 changes: 2 additions & 0 deletions src/pages/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const Users: React.FC = () => {
const handleDelete = (row: ListItem) => {
modalRef.current.show({
content: 'users.table.user',
operation: 'common.delete.single.confirm',
name: row.name,
async onOk() {
console.log('OK');
Expand All @@ -172,6 +173,7 @@ const Users: React.FC = () => {
const handleDeleteBatch = () => {
modalRef.current.show({
content: 'users.table.user',
operation: 'common.delete.confirm',
selection: true,
async onOk() {
await handleBatchRequest(rowSelection.selectedRowKeys, deleteUser);
Expand Down

0 comments on commit 02391e6

Please sign in to comment.