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: Update visibility of team members based on user role #14629

Conversation

sean-brydon
Copy link
Member

@sean-brydon sean-brydon commented Apr 17, 2024

What does this PR do?

Fixes CAL-3484

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is a UI/UX design document, please, share it here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tests (Unit/Integration/E2E or any other test)
  • This change requires a documentation update

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

Copy link

vercel bot commented Apr 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2024 1:33pm
platform-starter-kit ❌ Failed (Inspect) Apr 22, 2024 1:33pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2024 1:33pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2024 1:33pm

Copy link
Contributor

github-actions bot commented Apr 17, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@keithwillcode keithwillcode added consumer core area: core, team members only labels Apr 17, 2024
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sean-brydon and the rest of your teammates on Graphite Graphite

@sean-brydon sean-brydon changed the title fix: team memebrs being hidden for admin when org is private and they are not org admin fix: team members being hidden for admin when org is private and they are not org admin Apr 17, 2024
@sean-brydon sean-brydon changed the title fix: team members being hidden for admin when org is private and they are not org admin fix: Update visibility of team members based on user role Apr 17, 2024
const hideMembers =
(ctx.user.profile?.organization?.isPrivate && !ctx.user.organization?.isOrgAdmin) ||
(isOrgPrivate && !isOrgAdminOrOwner && input.teamId === ctx.user.organizationId) ||
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check the teamId here to ensure we are not targeting a team other than the org ID

Copy link
Contributor

github-actions bot commented Apr 17, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link

deploysentinel bot commented Apr 17, 2024

Current Playwright Test Results Summary

✅ 314 Passing - ⚠️ 13 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 04/22/2024 01:44:25pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 2b546f6

Started: 04/22/2024 01:40:47pm UTC

⚠️ Flakes

📄   apps/web/playwright/workflow.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Workflow Tab - Event Type Check the functionalities of the Workflow Tab Team Workflows Admin user
Retry 1Initial Attempt
0.47% (1) 1 / 214 run
failed over last 7 days
0.47% (1) 1 / 214 run
flaked over last 7 days

📄   apps/web/playwright/profile.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Update Profile Can update a users email (verification enabled)
Retry 1Initial Attempt
6.02% (13) 13 / 216 runs
failed over last 7 days
28.24% (61) 61 / 216 runs
flaked over last 7 days

📄   apps/web/playwright/payment-apps.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Payment app Should not display App is not setup already for non payment app
Retry 1Initial Attempt
0% (0) 0 / 217 runs
failed over last 7 days
0.46% (1) 1 / 217 run
flaked over last 7 days

📄   apps/web/playwright/event-types.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests -- future user Different Locations Tests can add Attendee Phone Number location and book with it
Retry 1Initial Attempt
0% (0) 0 / 244 runs
failed over last 7 days
6.97% (17) 17 / 244 runs
flaked over last 7 days
Event Types tests -- future user Different Locations Tests Can add Cal video location and book with it
Retry 1Initial Attempt
11.89% (29) 29 / 244 runs
failed over last 7 days
3.69% (9) 9 / 244 runs
flaked over last 7 days

📄   apps/web/playwright/teams.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - NonOrg -- future Can create a booking for Round Robin EventType
Retry 1Initial Attempt
13.25% (33) 33 / 249 runs
failed over last 7 days
17.27% (43) 43 / 249 runs
flaked over last 7 days

📄   apps/web/playwright/settings-admin.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Settings/admin tests -- future should render /settings/admin page
Retry 1Initial Attempt
1.19% (3) 3 / 252 runs
failed over last 7 days
1.98% (5) 5 / 252 runs
flaked over last 7 days

📄   packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Routing Forms Seeded Routing Form Test preview should return correct route
Retry 1Initial Attempt
0% (0) 0 / 241 runs
failed over last 7 days
34.85% (84) 84 / 241 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/preview.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Preview Preview - embed-core should load
Retry 1Initial Attempt
0% (0) 0 / 243 runs
failed over last 7 days
41.56% (101) 101 / 243 runs
flaked over last 7 days

📄   apps/web/playwright/organization/across-org/across-org.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
user1NotMemberOfOrg1 is part of team1MemberOfOrg1 EventTypes listing should show correct link for user events and team1MemberOfOrg1's events
Retry 2Retry 1Initial Attempt
1.59% (4) 4 / 251 runs
failed over last 7 days
7.17% (18) 18 / 251 runs
flaked over last 7 days

📄   apps/web/playwright/app-store.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
App Store - Authed -- future Browse apple-calendar and try to install
Retry 1Initial Attempt
0% (0) 0 / 243 runs
failed over last 7 days
0.82% (2) 2 / 243 runs
flaked over last 7 days

📄   apps/web/playwright/reschedule.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Reschedule Tests Should display request reschedule send on bookings/cancelled
Retry 1Initial Attempt
0% (0) 0 / 220 runs
failed over last 7 days
0.45% (1) 1 / 220 run
flaked over last 7 days

📄   packages/embeds/embed-react/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
React Embed Element Click Popup should verify that the iframe got created with correct URL - namespaced
Retry 1Initial Attempt
21.78% (22) 22 / 101 runs
failed over last 7 days
35.64% (36) 36 / 101 runs
flaked over last 7 days

View Detailed Build Results


@sean-brydon sean-brydon marked this pull request as ready for review April 17, 2024 10:53
@graphite-app graphite-app bot requested a review from a team April 17, 2024 10:53
@dosubot dosubot bot added teams area: teams, round robin, collective, managed event-types 🐛 bug Something isn't working labels Apr 17, 2024
Copy link

graphite-app bot commented Apr 17, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (04/17/24)

1 reviewer was added to this PR based on Keith Williams's automation.

const hideMembers =
(ctx.user.profile?.organization?.isPrivate && !ctx.user.organization?.isOrgAdmin) ||
(isOrgPrivate && !isOrgAdminOrOwner && input.teamId === ctx.user.organizationId) ||
Copy link
Member

@hariombalhara hariombalhara Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could make more sense to convert it into a function that does it something like this

function shouldHideMembers() {
	if (!team.isPrivate) {
	  return false;
	}
	return isTeamAnOrg ? !isOrgAdminOrOwner : !isOrgAdminOrOwner && !isTeamAdminOrOwner
}

Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sean-brydon can you also add automated tests for the fix?

@sean-brydon
Copy link
Member Author

@sean-brydon can you also add automated tests for the fix?

Yep working on it now <3

}) {
return await prisma.team.create({
data: {
name: name,
slug: slug,
isOrganization: true,
isPrivate: isPrivate,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow us to create private orgs

@@ -788,7 +788,7 @@ const createUser = (
},
},
accepted: true,
role: MembershipRole.ADMIN,
role,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actualy pass in the role to the figure - previously all were admin

const tableLocator = await page.getByTestId("team-member-list-container");
await expect(tableLocator).toBeVisible();

const memberUser = await prisma.membership.findFirst({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easier than selecting from the UI

Copy link

linear bot commented Apr 18, 2024

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now !! Thanks for the tests @sean-brydon

…n_when_org_is_private_and_they_are_not_org_admin
…n_when_org_is_private_and_they_are_not_org_admin
@sean-brydon sean-brydon merged commit 3ce6c23 into main Apr 22, 2024
37 of 39 checks passed
@sean-brydon sean-brydon deleted the 04-17-fix_team_memebrs_being_hidden_for_admin_when_org_is_private_and_they_are_not_org_admin branch April 22, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working consumer core area: core, team members only teams area: teams, round robin, collective, managed event-types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants