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: Permission search results #2167

Merged
merged 1 commit into from
Oct 17, 2022
Merged
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
27 changes: 8 additions & 19 deletions src/app/views/query-runner/request/permissions/PanelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ const PanelList = ({ messages,

useEffect(() => {
if (shouldGenerateGroups.current) {
if(permissionsList.length === 0){ return }
setGroups(generateGroupsFromList(permissionsList, 'groupName'));
if(groups && groups.length > 0) {
shouldGenerateGroups.current = false;
}
if(permissionsList.length === 0){ return }
}
}, [permissions, searchStarted])

Expand All @@ -101,7 +101,8 @@ const PanelList = ({ messages,

filteredPermissions = fullPermissions.filter((permission: IPermission) => {
const name = permission.value.toLowerCase();
return name.includes(keyword);
const groupName = permission.value.split('.')[0].toLowerCase();
return name.includes(keyword) || groupName.includes(keyword);
});
}
setPermissions(filteredPermissions);
Expand Down Expand Up @@ -188,19 +189,6 @@ const PanelList = ({ messages,

return (
<div>
<Label className={classes.permissionText}>
<FormattedMessage id='Select different permissions' />
</Label>
<hr />
<SearchBox
className={classes.searchBox}
placeholder={messages['Search permissions']}
onChange={(event?: React.ChangeEvent<HTMLInputElement>, newValue?: string) =>
searchValueChanged(event, newValue)}
styles={searchBoxStyles}
/>
<Announced message={`${permissions.length} search results available.`} />
<hr />
<Panel
isOpen={permissionsPanelOpen}
onDismiss={() => changePanelState()}
Expand All @@ -213,7 +201,7 @@ const PanelList = ({ messages,
overlayProps={panelOverlayProps}
styles={permissionPanelStyles}
>
{loading || groups && groups.length === 0 ? displayLoadingPermissionsText() :
{loading ? displayLoadingPermissionsText() :
<>
<Label className={classes.permissionText}>
<FormattedMessage id='Select different permissions' />
Expand Down Expand Up @@ -251,8 +239,8 @@ const PanelList = ({ messages,
onRenderCheckbox={(props?: IDetailsListCheckboxProps) => renderCustomCheckbox(props)}
/>
</>}
</Panel>
{permissions && permissions.length === 0 &&

{!loading && permissions && permissions.length === 0 &&
<Label style={{
display: 'flex',
width: '100%',
Expand All @@ -262,7 +250,8 @@ const PanelList = ({ messages,
}}>
<FormattedMessage id='permissions not found' />
</Label>
}
}
</Panel>
</div>
);
};
Expand Down