Skip to content

Commit 7032c83

Browse files
committed
fix: Standardize button names and permissions in user policy example
1 parent c0476d9 commit 7032c83

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

code/examples/user-policy.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getPolicyByRole(role) {
3434

3535
return {
3636
canInvite: policy.includes("invite"),
37-
canRead: policy.includes("view")
37+
canView: policy.includes("view")
3838
};
3939
}
4040

@@ -69,14 +69,14 @@ function Page() {
6969
return (
7070
<div>
7171
<Button disabled={false}>Invite</Button>
72-
<Button disabled={false}>Read</Button>
72+
<Button disabled={false}>View</Button>
7373
</div>
7474
);
7575
case "viewer":
7676
return (
7777
<div>
7878
<Button disabled={true}>Invite</Button>
79-
<Button disabled={false}>Read</Button>
79+
<Button disabled={false}>View</Button>
8080
</div>
8181
);
8282
default:
@@ -88,20 +88,20 @@ function Page() {
8888
### B. 조건을 한눈에 볼 수 있는 객체로 만들기
8989

9090
권한을 다루는 로직을 컴포넌트 안에서 객체로 관리해서, 여러 차례의 시점 이동 없이 한눈에 조건을 파악할 수 있게 수정할 수 있어요.
91-
`canInvite``canRead`의 조건을 `Page` 컴포넌트만 보면 확인할 수 있어요.
91+
`canInvite``canView`의 조건을 `Page` 컴포넌트만 보면 확인할 수 있어요.
9292

9393
```tsx
9494
function Page() {
9595
const user = useUser();
9696
const policy = {
97-
admin: { canInvite: true, canRead: true },
98-
viewer: { canInvite: false, canRead: true },
97+
admin: { canInvite: true, canView: true },
98+
viewer: { canInvite: false, canView: true },
9999
}[user.role];
100100

101101
return (
102102
<div>
103103
<Button disabled={!policy.canInvite}>Invite</Button>
104-
<Button disabled={!policy.canRead}>Read</Button>
104+
<Button disabled={!policy.canView}>View</Button>
105105
</div>
106106
);
107107
}

en/code/examples/user-policy.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getPolicyByRole(role) {
3434

3535
return {
3636
canInvite: policy.includes("invite"),
37-
canRead: policy.includes("view")
37+
canView: policy.includes("view")
3838
};
3939
}
4040

@@ -69,14 +69,14 @@ function Page() {
6969
return (
7070
<div>
7171
<Button disabled={false}>Invite</Button>
72-
<Button disabled={false}>Read</Button>
72+
<Button disabled={false}>View</Button>
7373
</div>
7474
);
7575
case "viewer":
7676
return (
7777
<div>
7878
<Button disabled={true}>Invite</Button>
79-
<Button disabled={false}>Read</Button>
79+
<Button disabled={false}>View</Button>
8080
</div>
8181
);
8282
default:
@@ -88,20 +88,20 @@ function Page() {
8888
### B. Creating an Object to View Conditions at a Glance
8989

9090
By managing the logic for handling permissions within the component as an object, you can modify it to be able to grasp the conditions at a glance without multiple context shifts.
91-
You can check the conditions for `canInvite` and `canRead` just by looking at the `Page` component.
91+
You can check the conditions for `canInvite` and `canView` just by looking at the `Page` component.
9292

9393
```tsx
9494
function Page() {
9595
const user = useUser();
9696
const policy = {
97-
admin: { canInvite: true, canRead: true },
98-
viewer: { canInvite: false, canRead: true },
97+
admin: { canInvite: true, canView: true },
98+
viewer: { canInvite: false, canView: true },
9999
}[user.role];
100100

101101
return (
102102
<div>
103103
<Button disabled={!policy.canInvite}>Invite</Button>
104-
<Button disabled={!policy.canRead}>Read</Button>
104+
<Button disabled={!policy.canView}>View</Button>
105105
</div>
106106
);
107107
}

0 commit comments

Comments
 (0)