From adf0994b3f32fe5beddd9f9653506ea7df1359e5 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 8 Sep 2022 10:05:44 +0200 Subject: [PATCH] feat(web): ability to not be able to close the context menu --- resource/interface/client/context.lua | 1 + web/src/features/menu/context/ContextMenu.tsx | 13 ++++++++++--- web/src/interfaces/context.ts | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/resource/interface/client/context.lua b/resource/interface/client/context.lua index 6d4548803..e80015776 100644 --- a/resource/interface/client/context.lua +++ b/resource/interface/client/context.lua @@ -18,6 +18,7 @@ function lib.showContext(id) action = 'showContext', data = { title = data.title, + canClose = data.canClose, menu = data.menu, options = data.options } diff --git a/web/src/features/menu/context/ContextMenu.tsx b/web/src/features/menu/context/ContextMenu.tsx index ade235b9a..78ce8330a 100644 --- a/web/src/features/menu/context/ContextMenu.tsx +++ b/web/src/features/menu/context/ContextMenu.tsx @@ -18,6 +18,7 @@ const ContextMenu: React.FC = () => { }); const closeContext = () => { + if (contextMenu.canClose === false) return; setVisible(false); fetchNui('closeContext'); }; @@ -76,7 +77,8 @@ const ContextMenu: React.FC = () => { { alignItems="center" marginLeft={2} p={2} - _hover={{ bg: 'gray.700' }} + cursor={contextMenu.canClose === false ? 'not-allowed' : undefined} + _hover={{ bg: contextMenu.canClose === false ? undefined : 'gray.700' }} transition="300ms" onClick={() => closeContext()} > - + diff --git a/web/src/interfaces/context.ts b/web/src/interfaces/context.ts index 8328b447b..4dc9d2880 100644 --- a/web/src/interfaces/context.ts +++ b/web/src/interfaces/context.ts @@ -21,5 +21,6 @@ export interface Options { export interface ContextMenuProps { title: string; menu?: string; + canClose?: boolean; options: Options | Option[]; }