@@ -5,6 +5,7 @@ import { CreateSecretKeyModal } from '../AccessTokens/CreateSecretKeyModal'
5
5
import {
6
6
Publisher ,
7
7
useDeletePersonalAccessToken ,
8
+ useGetPermissionOnPublisher ,
8
9
useListNodesForPublisher ,
9
10
useListPersonalAccessTokens ,
10
11
useUpdatePublisher ,
@@ -27,6 +28,9 @@ const PublisherDetail: React.FC<PublisherDetailProps> = ({ publisher }) => {
27
28
refetch : refetchTokens ,
28
29
} = useListPersonalAccessTokens ( publisher . id as string )
29
30
const { data : nodes } = useListNodesForPublisher ( publisher . id as string )
31
+ const { data : permissions } = useGetPermissionOnPublisher (
32
+ publisher . id as string
33
+ )
30
34
const [ openSecretKeyModal , setOpenSecretKeyModal ] = useState ( false )
31
35
const [ openEditModal , setOpenEditModal ] = useState ( false )
32
36
@@ -68,7 +72,11 @@ const PublisherDetail: React.FC<PublisherDetailProps> = ({ publisher }) => {
68
72
const oneMemberOfPublisher = getFirstMemberName ( publisher )
69
73
70
74
if ( error || publisher === undefined || publisher . id === undefined ) {
71
- return < div className = "container p-6 mx-auto h-[90vh]" > Not Found</ div >
75
+ return (
76
+ < div className = "container p-6 mx-auto h-[90vh] text-white" >
77
+ Not Found
78
+ </ div >
79
+ )
72
80
}
73
81
74
82
return (
@@ -104,31 +112,33 @@ const PublisherDetail: React.FC<PublisherDetailProps> = ({ publisher }) => {
104
112
< h1 className = "mb-4 text-5xl font-bold text-white" >
105
113
{ publisher . name }
106
114
</ h1 >
107
- < Button
108
- size = "xs"
109
- className = "h-8 p-2 px-4 font-bold text-white bg-blue-500 rounded hover:bg-blue-600"
110
- color = "blue"
111
- onClick = { handleEditButtonClick }
112
- >
113
- < svg
114
- className = "w-5 h-5 text-white"
115
- aria-hidden = "true"
116
- xmlns = "http://www.w3.org/2000/svg"
117
- width = "24"
118
- height = "24"
119
- fill = "none"
120
- viewBox = "0 0 24 24"
115
+ { permissions ?. canEdit && (
116
+ < Button
117
+ size = "xs"
118
+ className = "h-8 p-2 px-4 font-bold text-white bg-blue-500 rounded hover:bg-blue-600"
119
+ color = "blue"
120
+ onClick = { handleEditButtonClick }
121
121
>
122
- < path
123
- stroke = "currentColor"
124
- stroke-linecap = "round"
125
- stroke-linejoin = "round"
126
- stroke-width = "2"
127
- d = "m14.304 4.844 2.852 2.852M7 7H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1v-4.5m2.409-9.91a2.017 2.017 0 0 1 0 2.853l-6.844 6.844L8 14l.713-3.565 6.844-6.844a2.015 2.015 0 0 1 2.852 0Z"
128
- />
129
- </ svg >
130
- < span className = "text-[10px]" > Edit details</ span >
131
- </ Button >
122
+ < svg
123
+ className = "w-5 h-5 text-white"
124
+ aria-hidden = "true"
125
+ xmlns = "http://www.w3.org/2000/svg"
126
+ width = "24"
127
+ height = "24"
128
+ fill = "none"
129
+ viewBox = "0 0 24 24"
130
+ >
131
+ < path
132
+ stroke = "currentColor"
133
+ stroke-linecap = "round"
134
+ stroke-linejoin = "round"
135
+ stroke-width = "2"
136
+ d = "m14.304 4.844 2.852 2.852M7 7H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1v-4.5m2.409-9.91a2.017 2.017 0 0 1 0 2.853l-6.844 6.844L8 14l.713-3.565 6.844-6.844a2.015 2.015 0 0 1 2.852 0Z"
137
+ />
138
+ </ svg >
139
+ < span className = "text-[10px]" > Edit details</ span >
140
+ </ Button >
141
+ ) }
132
142
</ div >
133
143
< p className = "text-gray-400" > @{ publisher . id } </ p >
134
144
< div className = "flex flex-col my-4 " >
@@ -175,28 +185,30 @@ const PublisherDetail: React.FC<PublisherDetailProps> = ({ publisher }) => {
175
185
</ p >
176
186
) }
177
187
</ div >
178
- < PersonalAccessTokenTable
179
- handleCreateButtonClick = { handleCreateButtonClick }
180
- accessTokens = { personalAccessTokens || [ ] }
181
- isLoading = { isLoadingAccessTokens }
182
- deleteToken = { ( tokenId : string ) =>
183
- deleteTokenMutation . mutate (
184
- {
185
- publisherId : publisher . id as string ,
186
- tokenId : tokenId ,
187
- } ,
188
- {
189
- onError : ( error ) => {
190
- toast . error ( 'Failed to delete token' )
188
+ { permissions ?. canEdit && (
189
+ < PersonalAccessTokenTable
190
+ handleCreateButtonClick = { handleCreateButtonClick }
191
+ accessTokens = { personalAccessTokens || [ ] }
192
+ isLoading = { isLoadingAccessTokens }
193
+ deleteToken = { ( tokenId : string ) =>
194
+ deleteTokenMutation . mutate (
195
+ {
196
+ publisherId : publisher . id as string ,
197
+ tokenId : tokenId ,
191
198
} ,
192
- onSuccess : ( ) => {
193
- toast . success ( 'Token deleted' )
194
- refetchTokens ( )
195
- } ,
196
- }
197
- )
198
- }
199
- />
199
+ {
200
+ onError : ( error ) => {
201
+ toast . error ( 'Failed to delete token' )
202
+ } ,
203
+ onSuccess : ( ) => {
204
+ toast . success ( 'Token deleted' )
205
+ refetchTokens ( )
206
+ } ,
207
+ }
208
+ )
209
+ }
210
+ />
211
+ ) }
200
212
</ div >
201
213
< CreateSecretKeyModal
202
214
publisherId = { publisher . id }
0 commit comments