refactor: replace checkAdminOrOwner with team.create permission in teams page (#24116)

* refactor: replace checkAdminOrOwner with team.create permission in teams page

- Replace role-based access control with PBAC using team.create permission
- Follow PBAC refactoring guide pattern for server-side permission checking
- Use permission-specific variable naming (canCreateTeam)
- Maintain existing TeamsListing component interface

Co-Authored-By: [email protected] <[email protected]>

* refactor: implement permissions object pattern for TeamsListing

- Replace isOrgAdmin prop with permissions object containing canCreateTeam
- Follow PBAC refactoring guide pattern for UI components
- Update TeamsListing component to use permissions.canCreateTeam
- Maintain existing functionality while improving code structure
- All type checking and linting verification passed

Co-Authored-By: [email protected] <[email protected]>

* use different method

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-09-29 14:11:42 +05:30
1 parent f6b061f787
commit 752f7fcde0
2 files changed
+22 -11

No files matched your search

@@ -19,7 +19,9 @@ import TeamList from "./TeamList";
type TeamsListingProps = {
orgId: number | null;
isOrgAdmin: boolean;
permissions: {
canCreateTeam: boolean;
};
teams: RouterOutputs["viewer"]["teams"]["list"];
teamNameFromInvite: string | null;
errorMsgFromInvite: string | null;
@@ -27,7 +29,7 @@ type TeamsListingProps = {
export function TeamsListing({
orgId,
isOrgAdmin,
permissions,
teams: data,
teamNameFromInvite,
errorMsgFromInvite,
@@ -51,7 +53,7 @@ export function TeamsListing({
}
);
const isCreateTeamButtonDisabled = !!(orgId && !isOrgAdmin);
const isCreateTeamButtonDisabled = !!(orgId && !permissions.canCreateTeam);
const features = [
{
@@ -128,7 +130,7 @@ export function TeamsListing({
features={features}
background="/tips/teams"
buttons={
!orgId || isOrgAdmin ? (
!orgId || permissions.canCreateTeam ? (
<div className="space-y-2 rtl:space-x-reverse sm:space-x-2">
<ButtonGroup>
<Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>