Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39f42bc

Browse files
authored
feat: show dialog with a redirect if permissions are required (#16661)
Closes [thisissue](coder/internal#385 (comment))## New behaviorWhen a user ends up on a page they don't have permission to view insteadof being redirected back to _/workspaces_ they'll be met with theun-closeable dialog below with a link to _/workspaces_.This is similar to [this PR](#16644)but IMO we should be making sure we are using `<RequirePermissions />`wherever applicable and only relying on `<ErrorAlert />` as a fallbackin case there is some page we missed or endpoint we're accidentallyusing.![Screenshot 2025-02-21 at 4 5058 PM](https://github.com/user-attachments/assets/1f986e28-d99b-425d-b67a-80bb08d5111f)
1 parentce49ce4 commit39f42bc

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

‎site/src/contexts/auth/RequirePermission.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import{
2+
Dialog,
3+
DialogContent,
4+
DialogDescription,
5+
DialogFooter,
6+
DialogHeader,
7+
DialogTitle,
8+
}from"components/Dialog/Dialog";
9+
import{Link}from"components/Link/Link";
110
importtype{FC,ReactNode}from"react";
2-
import{Navigate}from"react-router-dom";
311

412
exportinterfaceRequirePermissionProps{
513
children?:ReactNode;
@@ -14,7 +22,24 @@ export const RequirePermission: FC<RequirePermissionProps> = ({
1422
isFeatureVisible,
1523
})=>{
1624
if(!isFeatureVisible){
17-
return<Navigateto="/workspaces"/>;
25+
return(
26+
<Dialogopen={true}>
27+
<DialogContent>
28+
<DialogHeader>
29+
<DialogTitle>
30+
You don't have permission to view this page
31+
</DialogTitle>
32+
</DialogHeader>
33+
<DialogDescription>
34+
If you believe this is a mistake, please contact your administrator
35+
or try signing in with different credentials.
36+
</DialogDescription>
37+
<DialogFooter>
38+
<Linkhref="/">Go to workspaces</Link>
39+
</DialogFooter>
40+
</DialogContent>
41+
</Dialog>
42+
);
1843
}
1944

2045
return<>{children}</>;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp