@@ -9,6 +9,7 @@ import { DeleteDirectoryOrFileModal } from '@/features/instance/applications/mod
99import { RedeployApplicationModal } from '@/features/instance/applications/modals/RedeployApplicationModal' ;
1010import { useDeployComponentMutation } from '@/features/instance/operations/mutations/deployComponent' ;
1111import { useEffectedState } from '@/hooks/useEffectedState' ;
12+ import { useInstanceBrowseManagePermission } from '@/hooks/usePermissions' ;
1213import { useToggler } from '@/hooks/useToggler' ;
1314import { parseFileExtension } from '@/lib/string/parseFileExtension' ;
1415import { Editor , EditorProps , OnMount } from '@monaco-editor/react' ;
@@ -46,6 +47,7 @@ export function TextEditorView() {
4647 [ openedEntryContents ] ,
4748 ) ;
4849 const targetNoun = instanceId || isLocalStudio ? 'Instance' : 'Cluster' ;
50+ const canManageBrowseInstance = useInstanceBrowseManagePermission ( ) ;
4951
5052 const mountedRef = useRef < Parameters < OnMount > | null > ( null ) ;
5153
@@ -148,7 +150,7 @@ export function TextEditorView() {
148150 } , [ openedEntry ?. package ] ) ;
149151
150152 useEffect ( ( ) => {
151- if ( ! mountedRef . current ) {
153+ if ( ! mountedRef . current || ! canManageBrowseInstance ) {
152154 return ;
153155 }
154156 const [ editor , monaco ] = mountedRef . current ;
@@ -187,7 +189,7 @@ export function TextEditorView() {
187189 disposable ?. dispose ( ) ;
188190 }
189191 } ;
190- } , [ mountedRef , onSaveClick , onRevertChangesClicked ] ) ;
192+ } , [ mountedRef , canManageBrowseInstance , onAddFileClicked , onAddDirectoryClicked , onSaveClick , onRevertChangesClicked , onDeleteClick ] ) ;
191193
192194 if ( ! openedEntry ) {
193195 return null ;
@@ -207,7 +209,7 @@ export function TextEditorView() {
207209 options = { {
208210 automaticLayout : true ,
209211 minimap : { enabled : false } ,
210- readOnly : ! ! openedEntry . package ,
212+ readOnly : ! ! openedEntry . package || ! canManageBrowseInstance ,
211213 padding : { top : 50 } ,
212214 } }
213215 />
@@ -221,7 +223,7 @@ export function TextEditorView() {
221223
222224 < div className = "absolute top-0 right-0 left-0 backdrop-blur-sm bg-black-10 shadow-xl flex pr-12 -mr-1" >
223225
224- { ! isDirectory ( openedEntry ) && ! openedEntry . package && < Button
226+ { ! isDirectory ( openedEntry ) && ! openedEntry . package && canManageBrowseInstance && < Button
225227 variant = "default"
226228 className = "rounded-none"
227229 onClick = { onSaveClick }
@@ -235,7 +237,7 @@ export function TextEditorView() {
235237 < span className = "hidden lg:inline-block" > < u > S</ u > ave</ span >
236238 </ Button > }
237239
238- { ! openedEntry . package && < Button
240+ { ! openedEntry . package && canManageBrowseInstance && < Button
239241 variant = "ghost"
240242 className = "rounded-none"
241243 // onClick={onRenameClick}
@@ -249,7 +251,7 @@ export function TextEditorView() {
249251 < span className = "hidden lg:inline-block" > < u > R</ u > ename</ span >
250252 </ Button > }
251253
252- { ! openedEntry . package && < Button
254+ { ! openedEntry . package && canManageBrowseInstance && < Button
253255 variant = "ghost"
254256 className = "rounded-none"
255257 onClick = { onAddFileClicked }
@@ -258,7 +260,7 @@ export function TextEditorView() {
258260 < span className = "hidden lg:inline-block" > < u > N</ u > ew File</ span >
259261 </ Button > }
260262
261- { ! openedEntry . package && < Button
263+ { ! openedEntry . package && canManageBrowseInstance && < Button
262264 variant = "ghost"
263265 className = "rounded-none"
264266 onClick = { onAddDirectoryClicked }
@@ -267,7 +269,7 @@ export function TextEditorView() {
267269 < span className = "hidden lg:inline-block" > < u > A</ u > dd Directory</ span >
268270 </ Button > }
269271
270- { ! ! openedEntry . package && ! restrictPackageModification && < Button
272+ { ! ! openedEntry . package && canManageBrowseInstance && ! restrictPackageModification && < Button
271273 variant = "ghost"
272274 className = "rounded-none"
273275 onClick = { onRedeployClicked }
@@ -276,17 +278,17 @@ export function TextEditorView() {
276278 < span > Redeploy < u > P</ u > ackage</ span >
277279 </ Button > }
278280
279- < RestartButton
281+ { canManageBrowseInstance && < RestartButton
280282 targetNoun = { targetNoun }
281283 instanceClient = { instanceParams . instanceClient }
282284 operation = "restart_service"
283285 variant = "ghost"
284286 className = "rounded-none"
285- />
287+ /> }
286288
287289 < div className = "grow" > </ div >
288290
289- { ! restrictPackageModification && < Button
291+ { ! restrictPackageModification && canManageBrowseInstance && < Button
290292 variant = "destructiveGhost"
291293 className = "rounded-none"
292294 onClick = { onDeleteClick }
@@ -295,7 +297,7 @@ export function TextEditorView() {
295297 < span className = "hidden xl:inline-block" > < u > D</ u > elete</ span >
296298 </ Button > }
297299
298- { ! isDirectory ( openedEntry ) && ! openedEntry . package && < Button
300+ { ! isDirectory ( openedEntry ) && ! openedEntry . package && canManageBrowseInstance && < Button
299301 variant = "ghost"
300302 className = "rounded-none"
301303 onClick = { onRevertChangesClicked }
0 commit comments