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",
|
"Owners": "Owners",
|
||||||
"Plugin settings": "Plugin settings",
|
"Plugin settings": "Plugin settings",
|
||||||
"Menu": "Menu",
|
"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":"乘以",
|
"Multiply by":"乘以",
|
||||||
"Divide by":"除以",
|
"Divide by":"除以",
|
||||||
"Scientifix notation":"科学计数法",
|
"Scientifix notation":"科学计数法",
|
||||||
"Normal":"常规"
|
"Normal":"常规",
|
||||||
|
"Quick Update": "快速更新"
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import React, { FC, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
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 { css } from '@emotion/css';
|
||||||
import { useAPIClient } from '../api-client';
|
import { useAPIClient } from '../api-client';
|
||||||
import { useApp } from '../application';
|
import { useApp } from '../application';
|
||||||
@ -12,6 +12,7 @@ import { PluginDetail } from './PluginDetail';
|
|||||||
import { PluginUpgradeModal } from './PluginForm/modal/PluginUpgradeModal';
|
import { PluginUpgradeModal } from './PluginForm/modal/PluginUpgradeModal';
|
||||||
import { useStyles } from './style';
|
import { useStyles } from './style';
|
||||||
import type { IPluginData } from './types';
|
import type { IPluginData } from './types';
|
||||||
|
import { NPM_REGISTRY_ADDRESS } from './PluginForm/form/PluginNpmForm';
|
||||||
|
|
||||||
interface IPluginInfo extends IPluginCard {
|
interface IPluginInfo extends IPluginCard {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
@ -30,6 +31,19 @@ function PluginInfo(props: IPluginInfo) {
|
|||||||
const [showUploadForm, setShowUploadForm] = useState(false);
|
const [showUploadForm, setShowUploadForm] = useState(false);
|
||||||
const reload = () => window.location.reload();
|
const reload = () => window.location.reload();
|
||||||
const title = displayName || name || packageName;
|
const title = displayName || name || packageName;
|
||||||
|
|
||||||
|
const quickUpdate = () => {
|
||||||
|
api.request({
|
||||||
|
url: 'pm:update',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
name,
|
||||||
|
packageName,
|
||||||
|
registry: NPM_REGISTRY_ADDRESS,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showUploadForm && (
|
{showUploadForm && (
|
||||||
@ -90,6 +104,7 @@ function PluginInfo(props: IPluginInfo) {
|
|||||||
<ReadOutlined /> {t('Docs')}
|
<ReadOutlined /> {t('Docs')}
|
||||||
</a>
|
</a>
|
||||||
{updatable && (
|
{updatable && (
|
||||||
|
<>
|
||||||
<a
|
<a
|
||||||
key={'3'}
|
key={'3'}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@ -99,6 +114,15 @@ function PluginInfo(props: IPluginInfo) {
|
|||||||
>
|
>
|
||||||
<ReloadOutlined /> {t('Update')}
|
<ReloadOutlined /> {t('Update')}
|
||||||
</a>
|
</a>
|
||||||
|
<a
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
quickUpdate();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ClockCircleOutlined /> {t('Quick Update')}
|
||||||
|
</a>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{enabled ? (
|
{enabled ? (
|
||||||
app.pluginSettingsManager.has(name) && (
|
app.pluginSettingsManager.has(name) && (
|
||||||
|
@ -16,6 +16,8 @@ interface IPluginNpmFormProps {
|
|||||||
pluginData?: IPluginData;
|
pluginData?: IPluginData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const NPM_REGISTRY_ADDRESS = 'https://npm.daoyoucloud.com/';
|
||||||
|
|
||||||
export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, pluginData }) => {
|
export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, pluginData }) => {
|
||||||
const { message } = App.useApp();
|
const { message } = App.useApp();
|
||||||
// const { data, loading } = useRequest<{ data: string[] }>(
|
// const { data, loading } = useRequest<{ data: string[] }>(
|
||||||
@ -57,7 +59,7 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
|||||||
return useRequest(
|
return useRequest(
|
||||||
() =>
|
() =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
data: isUpgrade ? pick(pluginData, ['name', 'packageName', 'version']) : {},
|
data: isUpgrade ? pick(pluginData, ['name', 'packageName']) : {},
|
||||||
}),
|
}),
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
@ -96,7 +98,7 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
|||||||
registry: {
|
registry: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: "{{t('Registry url')}}",
|
title: "{{t('Registry url')}}",
|
||||||
default: 'https://npm.daoyoucloud.com/',
|
default: NPM_REGISTRY_ADDRESS,
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
// required: true,
|
// required: true,
|
||||||
@ -118,6 +120,9 @@ export const PluginNpmForm: FC<IPluginNpmFormProps> = ({ onClose, isUpgrade, plu
|
|||||||
title: "{{t('Version')}}",
|
title: "{{t('Version')}}",
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
|
'x-component-props': {
|
||||||
|
placeholder: pluginData?.version || '',
|
||||||
|
},
|
||||||
// enum: '{{versionList}}',
|
// enum: '{{versionList}}',
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
|
Loading…
Reference in New Issue
Block a user