feat: 支持快速更新插件版本 (#797)
Reviewed-on: daoyoucloud/tachybase#797 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
9f61c0d093
commit
f0472afcb5
5
.changeset/many-beers-appear.md
Normal file
5
.changeset/many-beers-appear.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nocobase/client": patch
|
||||
---
|
||||
|
||||
支持快速更新插件版本
|
@ -819,5 +819,6 @@
|
||||
"Owners": "Owners",
|
||||
"Plugin settings": "Plugin settings",
|
||||
"Menu": "Menu",
|
||||
"Drag and drop sorting field": "Drag and drop sorting field"
|
||||
"Drag and drop sorting field": "Drag and drop sorting field",
|
||||
"Quick Update": "Quick Update"
|
||||
}
|
||||
|
@ -920,5 +920,6 @@
|
||||
"Multiply by":"乘以",
|
||||
"Divide by":"除以",
|
||||
"Scientifix notation":"科学计数法",
|
||||
"Normal":"常规"
|
||||
"Normal":"常规",
|
||||
"Quick Update": "快速更新"
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import React, { FC, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { DeleteOutlined, ReadOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons';
|
||||
import { DeleteOutlined, ReadOutlined, ReloadOutlined, SettingOutlined, ClockCircleOutlined } from '@ant-design/icons';
|
||||
import { css } from '@emotion/css';
|
||||
import { useAPIClient } from '../api-client';
|
||||
import { useApp } from '../application';
|
||||
@ -12,6 +12,7 @@ import { PluginDetail } from './PluginDetail';
|
||||
import { PluginUpgradeModal } from './PluginForm/modal/PluginUpgradeModal';
|
||||
import { useStyles } from './style';
|
||||
import type { IPluginData } from './types';
|
||||
import { NPM_REGISTRY_ADDRESS } from './PluginForm/form/PluginNpmForm';
|
||||
|
||||
interface IPluginInfo extends IPluginCard {
|
||||
onClick: () => void;
|
||||
@ -30,6 +31,19 @@ function PluginInfo(props: IPluginInfo) {
|
||||
const [showUploadForm, setShowUploadForm] = useState(false);
|
||||
const reload = () => window.location.reload();
|
||||
const title = displayName || name || packageName;
|
||||
|
||||
const quickUpdate = () => {
|
||||
api.request({
|
||||
url: 'pm:update',
|
||||
method: 'post',
|
||||
data: {
|
||||
name,
|
||||
packageName,
|
||||
registry: NPM_REGISTRY_ADDRESS,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{showUploadForm && (
|
||||
@ -90,15 +104,25 @@ function PluginInfo(props: IPluginInfo) {
|
||||
<ReadOutlined /> {t('Docs')}
|
||||
</a>
|
||||
{updatable && (
|
||||
<a
|
||||
key={'3'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowUploadForm(true);
|
||||
}}
|
||||
>
|
||||
<ReloadOutlined /> {t('Update')}
|
||||
</a>
|
||||
<>
|
||||
<a
|
||||
key={'3'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowUploadForm(true);
|
||||
}}
|
||||
>
|
||||
<ReloadOutlined /> {t('Update')}
|
||||
</a>
|
||||
<a
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
quickUpdate();
|
||||
}}
|
||||
>
|
||||
<ClockCircleOutlined /> {t('Quick Update')}
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
{enabled ? (
|
||||
app.pluginSettingsManager.has(name) && (
|
||||
|
@ -16,6 +16,8 @@ interface IPluginNpmFormProps {
|
||||
pluginData?: IPluginData;
|
||||
}
|
||||
|
||||
export const NPM_REGISTRY_ADDRESS = 'https://npm.daoyoucloud.com/';
|
||||
|
||||
export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, pluginData }) => {
|
||||
const { message } = App.useApp();
|
||||
// const { data, loading } = useRequest<{ data: string[] }>(
|
||||
@ -57,7 +59,7 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
||||
return useRequest(
|
||||
() =>
|
||||
Promise.resolve({
|
||||
data: isUpgrade ? pick(pluginData, ['name', 'packageName', 'version']) : {},
|
||||
data: isUpgrade ? pick(pluginData, ['name', 'packageName']) : {},
|
||||
}),
|
||||
options,
|
||||
);
|
||||
@ -96,7 +98,7 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
||||
registry: {
|
||||
type: 'string',
|
||||
title: "{{t('Registry url')}}",
|
||||
default: 'https://npm.daoyoucloud.com/',
|
||||
default: NPM_REGISTRY_ADDRESS,
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
// required: true,
|
||||
@ -118,6 +120,9 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
||||
title: "{{t('Version')}}",
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
'x-component-props': {
|
||||
placeholder: pluginData?.version || '',
|
||||
},
|
||||
// enum: '{{versionList}}',
|
||||
},
|
||||
footer: {
|
||||
|
Loading…
Reference in New Issue
Block a user