Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: "Reload" Button in Admin Scopes Not Functioning Correctly (#1329) #855

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import RefreshIcon from '@mui/icons-material/Refresh';
*/
function ListAddOns(props) {
const {
searchActive, filterData, onRefresh, searchPlaceholder, children,
searchActive, filterData, onRefresh, searchPlaceholder, children, searchValue,
} = props;

return (
Expand All @@ -60,6 +60,7 @@ function ListAddOns(props) {
disableUnderline: true,
style: { fontSize: '12px' },
}}
value={searchValue}
onChange={filterData}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ export default function ListRoles() {
const [hasListPermission, setHasListPermission] = useState(true);
const intl = useIntl();
const [errorMessage, setError] = useState(null);
const [searchText, setSearchText] = useState('');

useEffect(() => {
const fetchData = useCallback(() => {
PermissionAPI.getRoleAliases();
setSearchText('');
Promise.all([PermissionAPI.getRoleAliases(), PermissionAPI.systemScopes()]).then(
([roleAliasesRes, systemScopesRes]) => {
setSystemScopes(systemScopesRes.body);
Expand All @@ -181,6 +183,10 @@ export default function ListRoles() {
});
}, []);

useEffect(() => {
fetchData();
}, [fetchData]);

useEffect(() => {
if (systemScopes && roleAliases) {
const [roleMapping, appMapping] = extractMappings(systemScopes.list);
Expand All @@ -200,6 +206,7 @@ export default function ListRoles() {

const onSearch = (searchKey) => {
const keys = Object.keys(permissionMappings);
setSearchText(searchKey.target.value);
const filteredKeys = keys.filter((key) => key.toLowerCase().includes(searchKey.target.value.toLowerCase()));
const newPermissionMappings = {};
for (let i = 0; i < filteredKeys.length; i++) {
Expand Down Expand Up @@ -300,6 +307,8 @@ export default function ListRoles() {
searchActive={searchProps.active}
searchPlaceholder={searchProps.searchPlaceholder}
filterData={onSearch}
onRefresh={fetchData}
searchValue={searchText}
>
<Grid item>
<Button
Expand Down
Loading