mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 01:17:43 +00:00
fix(Action): make e2e tests pass
This commit is contained in:
parent
4d709fa9e9
commit
41c41128c2
@ -11,7 +11,7 @@ import { useFieldSchema } from '@formily/react';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { createContext, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { createContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useDataBlockRequestGetter } from '../../../data-source';
|
import { useDataBlockRequest } from '../../../data-source';
|
||||||
import { useCurrentPopupContext } from '../page/PagePopups';
|
import { useCurrentPopupContext } from '../page/PagePopups';
|
||||||
import { getBlockService, storeBlockService } from '../page/pagePopupUtils';
|
import { getBlockService, storeBlockService } from '../page/pagePopupUtils';
|
||||||
import { ActionContextProps } from './types';
|
import { ActionContextProps } from './types';
|
||||||
@ -75,22 +75,21 @@ ActionContextProvider.displayName = 'ActionContextProvider';
|
|||||||
|
|
||||||
const useBlockServiceInActionButton = () => {
|
const useBlockServiceInActionButton = () => {
|
||||||
const { params } = useCurrentPopupContext();
|
const { params } = useCurrentPopupContext();
|
||||||
const fieldSchema = useFieldSchema();
|
|
||||||
const popupUidWithoutOpened = useFieldSchema()?.['x-uid'];
|
const popupUidWithoutOpened = useFieldSchema()?.['x-uid'];
|
||||||
const { getDataBlockRequest } = useDataBlockRequestGetter();
|
const service = useDataBlockRequest();
|
||||||
const currentPopupUid = params?.popupuid;
|
const currentPopupUid = params?.popupuid;
|
||||||
|
|
||||||
// 把 service 存起来
|
// 把 service 存起来
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (popupUidWithoutOpened && currentPopupUid !== popupUidWithoutOpened) {
|
if (popupUidWithoutOpened && currentPopupUid !== popupUidWithoutOpened) {
|
||||||
storeBlockService(popupUidWithoutOpened, { service: getDataBlockRequest() });
|
storeBlockService(popupUidWithoutOpened, { service });
|
||||||
}
|
}
|
||||||
}, [popupUidWithoutOpened, getDataBlockRequest, currentPopupUid, fieldSchema]);
|
}, [currentPopupUid, popupUidWithoutOpened, service]);
|
||||||
|
|
||||||
// 关闭弹窗时,获取到对应的 service
|
// 关闭弹窗时,获取到对应的 service
|
||||||
if (currentPopupUid === popupUidWithoutOpened) {
|
if (currentPopupUid === popupUidWithoutOpened) {
|
||||||
return getBlockService(currentPopupUid)?.service || getDataBlockRequest();
|
return getBlockService(currentPopupUid)?.service || service;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDataBlockRequest();
|
return service;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user