fix: data source permission role update (#3643)
This commit is contained in:
parent
d427dc6ea1
commit
4bbce06d5e
@ -1,5 +1,5 @@
|
|||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import React, { createContext, useContext, useState } from 'react';
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient, useRecord, RecordContext_deprecated, SchemaComponentOptions } from '@nocobase/client';
|
import { useAPIClient, useRecord, RecordContext_deprecated, SchemaComponentOptions } from '@nocobase/client';
|
||||||
import { CurrentRolesContext } from './';
|
import { CurrentRolesContext } from './';
|
||||||
@ -25,7 +25,9 @@ export const PermissionProvider = (props) => {
|
|||||||
role[key] = true;
|
role[key] = true;
|
||||||
});
|
});
|
||||||
const [currentRecord, setCurrentRecord] = useState(role);
|
const [currentRecord, setCurrentRecord] = useState(role);
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrentRecord(role);
|
||||||
|
}, [role]);
|
||||||
return (
|
return (
|
||||||
<PermissionContext.Provider
|
<PermissionContext.Provider
|
||||||
value={{
|
value={{
|
||||||
@ -36,7 +38,7 @@ export const PermissionProvider = (props) => {
|
|||||||
url: `dataSources/${record.key}/roles:update`,
|
url: `dataSources/${record.key}/roles:update`,
|
||||||
data: form.values,
|
data: form.values,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params: { filterByTk: role.name },
|
params: { filterByTk: form.values.roleName },
|
||||||
});
|
});
|
||||||
setCurrentRecord({ ...currentRecord, ...form.values });
|
setCurrentRecord({ ...currentRecord, ...form.values });
|
||||||
message.success(t('Saved successfully'));
|
message.success(t('Saved successfully'));
|
||||||
|
Loading…
Reference in New Issue
Block a user