mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:27:04 +00:00
fix(client): fix typo in upload component (#5460)
Some checks are pending
Build docker image / build-and-push (push) Waiting to run
Build pro image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase frontEnd test / frontend-test (18) (push) Waiting to run
Some checks are pending
Build docker image / build-and-push (push) Waiting to run
Build pro image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase frontEnd test / frontend-test (18) (push) Waiting to run
* fix(client): fix typo in upload component * fix(plugin-file-manager): fix rule hook
This commit is contained in:
parent
72867c6acb
commit
d553e51b51
@ -250,7 +250,7 @@ function AttachmentListItem(props) {
|
|||||||
{item}
|
{item}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<span className={`${prefixCls}-span`}>{item}3</span>
|
<span className={`${prefixCls}-span`}>{item}</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
@ -358,6 +358,7 @@ export function Uploader({ rules, ...props }: UploadProps) {
|
|||||||
const uploadProps = useUploadProps(props);
|
const uploadProps = useUploadProps(props);
|
||||||
|
|
||||||
const beforeUpload = useBeforeUpload(rules);
|
const beforeUpload = useBeforeUpload(rules);
|
||||||
|
console.log('----------', pendingList);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pendingList.length) {
|
if (pendingList.length) {
|
||||||
|
@ -59,8 +59,11 @@ export class AttachmentFileTypes {
|
|||||||
*/
|
*/
|
||||||
export const attachmentFileTypes = new AttachmentFileTypes();
|
export const attachmentFileTypes = new AttachmentFileTypes();
|
||||||
|
|
||||||
export function matchMimetype(file: FileModel, type: string) {
|
export function matchMimetype(file: FileModel | UploadFile<any>, type: string) {
|
||||||
if (file.mimetype) {
|
if ('originFileObj' in file) {
|
||||||
|
return match(file.type, type);
|
||||||
|
}
|
||||||
|
if ('mimetype' in file) {
|
||||||
return match(file.mimetype, type);
|
return match(file.mimetype, type);
|
||||||
}
|
}
|
||||||
if (file.url) {
|
if (file.url) {
|
||||||
@ -223,7 +226,7 @@ const Rules: Record<string, RuleFunction> = {
|
|||||||
|
|
||||||
type RuleFunction = (file: UploadFile, options: any) => string | null;
|
type RuleFunction = (file: UploadFile, options: any) => string | null;
|
||||||
|
|
||||||
function validate(file, rules: Record<string, any>) {
|
export function validate(file, rules: Record<string, any>) {
|
||||||
if (!rules) {
|
if (!rules) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useField } from '@formily/react';
|
import { useField } from '@formily/react';
|
||||||
import { useAPIClient, useCollectionField, useCollectionManager, useRequest } from '@nocobase/client';
|
import { useAPIClient, useCollectionField, useCollectionManager, useRequest } from '@nocobase/client';
|
||||||
|
|
||||||
@ -14,20 +15,22 @@ export function useStorageRules(storage) {
|
|||||||
const name = storage ?? '';
|
const name = storage ?? '';
|
||||||
const apiClient = useAPIClient();
|
const apiClient = useAPIClient();
|
||||||
const field = useField<any>();
|
const field = useField<any>();
|
||||||
const { loading, data } = useRequest<any>(
|
const { loading, data, run } = useRequest<any>(
|
||||||
async () => {
|
{
|
||||||
if (field.pattern !== 'editable') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return apiClient.request({
|
|
||||||
url: `storages:getRules/${name}`,
|
url: `storages:getRules/${name}`,
|
||||||
});
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
manual: true,
|
||||||
refreshDeps: [name],
|
refreshDeps: [name],
|
||||||
cacheKey: name,
|
cacheKey: name,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
useEffect(() => {
|
||||||
|
if (field.pattern !== 'editable') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
run();
|
||||||
|
}, [field.pattern, run]);
|
||||||
return (!loading && data?.data) || null;
|
return (!loading && data?.data) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user