Skip to content

Commit a80f07e

Browse files
gtryusGreg Trihus
andauthored
TT-6984 Enhance OrgHead component to include personal team logic (#163)
* TT-6984 Enhance OrgHead component to include personal team logic This update introduces a new check to determine if the current organization is a personal team. Key changes include: - Added `personalTeam` to the context state and a new `isPersonalTeam` memoized value to identify personal teams. - Updated the rendering logic to conditionally display the members button based on whether the organization is a personal team. These enhancements improve the user experience by ensuring that the interface accurately reflects the user`s organizational context. * rename isPersonal and add test --------- Co-authored-by: Greg Trihus <[email protected]>
1 parent 5fbb0af commit a80f07e

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

src/renderer/src/components/App/OrgHead.cy.tsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ describe('OrgHead', () => {
242242
initialEntries: string[] = ['/team'],
243243
orgId?: string,
244244
orgData?: OrganizationD,
245-
isAdmin: boolean = false
245+
isAdmin: boolean = false,
246+
personalTeam?: string
246247
) => {
247248
// Set organization ID in localStorage if provided
248249
if (orgId) {
@@ -297,7 +298,7 @@ describe('OrgHead', () => {
297298
planTypes: [],
298299
isDeleting: false,
299300
teams: [],
300-
personalTeam: '',
301+
personalTeam: personalTeam ?? '',
301302
personalProjects: [],
302303
teamProjects: () => [],
303304
teamMembers: () => 0,
@@ -596,4 +597,40 @@ describe('OrgHead', () => {
596597
expect(displayedText).to.equal('Test Organization');
597598
});
598599
});
600+
601+
it('should not show members button for personal projects', () => {
602+
const orgId = 'test-org-id';
603+
const orgName = 'Personal Project';
604+
const orgData = createMockOrganization(orgId, orgName);
605+
606+
// Set personalTeam to match orgId to make it a personal project
607+
mountOrgHead(createInitialState(), ['/team'], orgId, orgData, false, orgId);
608+
609+
// Members button should not be shown for personal projects
610+
// Even though orgRec exists and we're on team screen, isPersonal should prevent the button
611+
cy.contains(orgName).should('be.visible');
612+
cy.get('button').should('not.exist');
613+
});
614+
615+
it('should show members button for non-personal projects', () => {
616+
const orgId = 'test-org-id';
617+
const orgName = 'Team Organization';
618+
const orgData = createMockOrganization(orgId, orgName);
619+
const differentPersonalTeam = 'different-personal-team-id';
620+
621+
// Set personalTeam to a different ID so this is NOT a personal project
622+
mountOrgHead(
623+
createInitialState(),
624+
['/team'],
625+
orgId,
626+
orgData,
627+
false,
628+
differentPersonalTeam
629+
);
630+
631+
// Members button should be shown for non-personal projects
632+
cy.contains(orgName).should('be.visible');
633+
cy.get('button').should('have.length', 1);
634+
cy.get('button svg').should('have.length', 1);
635+
});
599636
});

src/renderer/src/components/App/OrgHead.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ export const OrgHead = () => {
3939
const isSwitchTeamsScreen = pathname.includes('/switch-teams');
4040
const { userIsOrgAdmin, setMyOrgRole } = useRole();
4141
const ctx = useContext(TeamContext);
42-
const { teamDelete } = ctx?.state ?? {};
42+
const { teamDelete, personalTeam } = ctx?.state ?? {};
4343

4444
const orgId = useMemo(
4545
() => localStorage.getItem(localUserKey(LocalKey.team)),
4646
// eslint-disable-next-line react-hooks/exhaustive-deps
4747
[user]
4848
);
49+
50+
const isPersonal = useMemo(() => {
51+
return personalTeam === orgId;
52+
}, [personalTeam, orgId]);
53+
4954
const orgRec = useMemo(() => {
5055
if (!orgId) return undefined;
5156
return organizations.find((o) => o.id === orgId);
@@ -121,7 +126,7 @@ export const OrgHead = () => {
121126
<SettingsIcon />
122127
</IconButton>
123128
)}
124-
{orgRec && (
129+
{orgRec && !isPersonal && (
125130
<IconButton onClick={handleMembers(orgRec)}>
126131
<UsersIcon />
127132
</IconButton>

0 commit comments

Comments
 (0)