Skip to content

Disable new organization button if user doesn't have write on the silo#1244

Closed
david-crespo wants to merge 1 commit into
mainfrom
role-gating
Closed

Disable new organization button if user doesn't have write on the silo#1244
david-crespo wants to merge 1 commit into
mainfrom
role-gating

Conversation

@david-crespo

Copy link
Copy Markdown
Collaborator

Proof of concept.

@vercel

vercel Bot commented Oct 20, 2022

Copy link
Copy Markdown

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

Name Status Preview Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview Oct 20, 2022 at 5:41PM (UTC)

Comment thread app/pages/OrgsPage.tsx
<Button size="sm" disabled>
New Organization
</Button>
)}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Clearly this is too noisy — we'd want to wrap this up into a disable-able custom link component with a disabled prop and a message to show in a tooltip when disabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Disabled links are a bit of an odd pattern. We'd want to change the pointer and ensure we had aria-disabled present. I think it's definitely something we'd want to try out on a screen reader just to see what it resulted in.

Comment thread app/pages/OrgsPage.tsx
await Promise.all([
apiQueryClient.prefetchQuery('organizationList', { query: { limit: 10 } }),
apiQueryClient.prefetchQuery('policyView', {}),
])

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

prefetch silo policy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Worth a comment?

Comment thread libs/api/roles.ts
return me && myGroups && siloPolicy
? userRoleFromPolicies(me, myGroups.items, [siloPolicy])
: null
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

all of these requests are prefetched and therefore never undefined, but we don't know it statically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants