Fix(UI): Loader not shown while fetching permissions on teams page (#7882)

* Fixed issue with no permissions placeholder showing before the data is displayed on teams page

* Fixed failing cypress tests for teams page
This commit is contained in:
Aniket Katkar 2022-10-04 11:42:39 +05:30 committed by GitHub
parent ba37fda0f1
commit 1e00d0d487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -67,9 +67,12 @@ describe('Teams flow should work properly', () => {
});
it('Add user to created team', () => {
interceptURL('GET', '/api/v1/users*', 'getUsers');
//Click on created team
cy.get('table').find('.ant-table-row').contains(TEAM_DETAILS.name).click();
verifyResponseStatusCode('@getUsers', 200);
//Clicking on users tab
cy.get('[data-testid="Users"]')
.should('exist')
@ -140,9 +143,12 @@ describe('Teams flow should work properly', () => {
});
it('Join team should work properly', () => {
interceptURL('GET', '/api/v1/users*', 'getUsers');
//Click on created team
cy.get('table').find('.ant-table-row').contains(TEAM_DETAILS.name).click();
verifyResponseStatusCode('@getUsers', 200);
//Click on join teams button
cy.get('[data-testid="join-teams"]').should('be.visible').click();

View File

@ -163,6 +163,7 @@ const TeamDetailsV1 = ({
TitleBreadcrumbProps['titleLinks']
>([]);
const [addAttribute, setAddAttribute] = useState<AddAttribute>();
const [loading, setLoading] = useState<boolean>(false);
const [selectedEntity, setEntity] = useState<{
attribute: 'defaultRoles' | 'policies';
record: EntityReference;
@ -491,6 +492,7 @@ const TeamDetailsV1 = ({
};
const fetchPermissions = async () => {
setLoading(true);
try {
const perms = await getEntityPermission(
ResourceEntity.TEAM,
@ -502,6 +504,8 @@ const TeamDetailsV1 = ({
error as AxiosError,
jsonData['api-error-messages']['fetch-user-permission-error']
);
} finally {
setLoading(false);
}
};
@ -859,6 +863,10 @@ const TeamDetailsV1 = ({
const viewPermission =
entityPermissions.ViewAll || entityPermissions.ViewBasic;
if (loading) {
return <Loader />;
}
return viewPermission ? (
<div
className="tw-h-full tw-flex tw-flex-col tw-flex-grow"