From d32f43efc6b6d010e8bf53fb1599acfbfe5e3242 Mon Sep 17 00:00:00 2001 From: sunhao Date: Wed, 13 Nov 2024 17:24:53 +0800 Subject: [PATCH] * [bug #56825, done, 0.3h] check priv before show api structs and release views. --- lib/zin/wg/docapp/js/v1.js | 20 +++++++++++--------- module/api/js/index.ui.js | 20 +++++++++++--------- module/api/ui/index.html.php | 2 ++ module/doc/ui/app.html.php | 2 ++ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/zin/wg/docapp/js/v1.js b/lib/zin/wg/docapp/js/v1.js index 1bb35b83c9..0c03a94eaf 100644 --- a/lib/zin/wg/docapp/js/v1.js +++ b/lib/zin/wg/docapp/js/v1.js @@ -1316,16 +1316,18 @@ const customRenders = 'sidebar-before': function() { if(!isApiLib()) return; + const canViewStructs = docAppHasPriv('struct'); + const canViewReleases = docAppHasPriv('releases'); + if(!canViewStructs && !canViewReleases) return; + const isListMode = this.mode === 'list'; - const lang = getDocAppLang(); - const listType = this.signals.listType.value; - const items = [ - {text: lang.struct, selected: listType === 'structs' && isListMode, icon: 'treemap muted', command: 'showStructs'}, - {type: 'divider', className: 'my-1'}, - {text: lang.releases, selected: listType === 'releases' && isListMode, icon: 'version muted', command: 'showReleases'}, - {type: 'divider', className: 'my-1'}, - {text: lang.module, icon: 'list muted', command: 'showModules'} - ]; + const lang = getDocAppLang(); + const listType = this.signals.listType.value; + const items = []; + if(canViewStructs) items.push({text: lang.struct, selected: listType === 'structs' && isListMode, icon: 'treemap muted', command: 'showStructs'}, {type: 'divider', className: 'my-1'}); + if(canViewReleases) items.push({text: lang.releases, selected: listType === 'releases' && isListMode, icon: 'version muted', command: 'showReleases'}, {type: 'divider', className: 'my-1'}); + items.push({text: lang.module, icon: 'list muted', command: 'showModules'}); + return { component: 'tree', className: 'p-2 pb-0 api-lib-menu', diff --git a/module/api/js/index.ui.js b/module/api/js/index.ui.js index 1cdafc0ca2..cfc5735035 100644 --- a/module/api/js/index.ui.js +++ b/module/api/js/index.ui.js @@ -136,16 +136,18 @@ const customRenders = 'sidebar-before': function() { if(!this.libID) return; + + const canViewStructs = docAppHasPriv('struct'); + const canViewReleases = docAppHasPriv('releases'); + if(!canViewStructs && !canViewReleases) return; + const isListMode = this.mode === 'list'; - const lang = getDocAppLang(); - const listType = this.signals.listType.value; - const items = [ - {text: lang.struct, selected: listType === 'structs' && isListMode, icon: 'treemap muted', command: 'showStructs'}, - {type: 'divider', className: 'my-1'}, - {text: lang.releases, selected: listType === 'releases' && isListMode, icon: 'version muted', command: 'showReleases'}, - {type: 'divider', className: 'my-1'}, - {text: lang.module, icon: 'list muted', command: 'showModules'} - ]; + const lang = getDocAppLang(); + const listType = this.signals.listType.value; + const items = []; + if(canViewStructs) items.push({text: lang.struct, selected: listType === 'structs' && isListMode, icon: 'treemap muted', command: 'showStructs'}, {type: 'divider', className: 'my-1'}); + if(canViewReleases) items.push({text: lang.releases, selected: listType === 'releases' && isListMode, icon: 'version muted', command: 'showReleases'}, {type: 'divider', className: 'my-1'}); + items.push({text: lang.module, icon: 'list muted', command: 'showModules'}); return { component: 'tree', className: 'p-2 pb-0 api-lib-menu', diff --git a/module/api/ui/index.html.php b/module/api/ui/index.html.php index 78073bac40..339d4ad66f 100644 --- a/module/api/ui/index.html.php +++ b/module/api/ui/index.html.php @@ -26,6 +26,8 @@ $privs['addModule'] = hasPriv('doc', 'addCatalog'); $privs['deleteModule'] = hasPriv('doc', 'deleteCatalog'); $privs['editModule'] = hasPriv('doc', 'editCatalog'); $privs['sortModule'] = hasPriv('doc', 'sortCatalog'); +$privs['releases'] = hasPriv('api', 'releases'); +$privs['struct'] = hasPriv('api', 'struct'); docApp ( diff --git a/module/doc/ui/app.html.php b/module/doc/ui/app.html.php index 4150d8b69a..c6c9c2f8a4 100644 --- a/module/doc/ui/app.html.php +++ b/module/doc/ui/app.html.php @@ -55,6 +55,8 @@ $privs['createApi'] = hasPriv('api', 'create'); $privs['editApi'] = hasPriv('api', 'edit'); $privs['createStruct'] = hasPriv('api', 'createStruct'); $privs['createRelease']= hasPriv('api', 'createRelease'); +$privs['releases'] = hasPriv('api', 'releases'); +$privs['struct'] = hasPriv('api', 'struct'); $privs['createOffice'] = true; $homeName = false;