Skip to content

Commit

Permalink
fix: display all roles if we can't get project roles
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Feb 20, 2024
1 parent b22b423 commit 7350c91
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Expand Up @@ -16,7 +16,6 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
import { UPDATE_APPLICATION } from 'component/providers/AccessProvider/permissions';
import { ApplicationView } from '../ApplicationView/ApplicationView';
import { ApplicationUpdate } from '../ApplicationUpdate/ApplicationUpdate';
import { ConnectedInstances } from '../ConnectedInstances/ConnectedInstances';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { PageContent } from 'component/common/PageContent/PageContent';
import { PageHeader } from 'component/common/PageHeader/PageHeader';
Expand Down
Expand Up @@ -321,13 +321,20 @@ export const ProjectAccessAssign = ({
};

const isValid = selectedOptions.length > 0 && selectedRoles.length > 0;
const filteredRoles = userRoles.some(
(userrole) => userrole.name === 'Admin' || userrole.name === 'Owner',
)
? roles
: roles.filter((role) =>
userRoles.some((userrole) => role.id === userrole.id),
);
const displayAllRoles =
userRoles.length === 0 ||
userRoles.some(
(userRole) =>
userRole.name === 'Admin' || userRole.name === 'Owner',
);
let filteredRoles: IRole[];
if (displayAllRoles) {
filteredRoles = roles;
} else {
filteredRoles = roles.filter((role) =>
userRoles.some((userrole) => role.id === userrole.id),
);
}
return (
<SidebarModal
open
Expand Down
1 change: 1 addition & 0 deletions src/lib/routes/admin-api/user/user.ts
Expand Up @@ -185,6 +185,7 @@ class UserController extends Controller {
},
);
} else {
res.status(400).end();
}
}
async getMe(req: IAuthRequest, res: Response<MeSchema>): Promise<void> {
Expand Down

0 comments on commit 7350c91

Please sign in to comment.