From 22bc1d4ac55667ea0dfd64f5f91101bcd1f9e577 Mon Sep 17 00:00:00 2001 From: Pragadesh-45 <54320162+Pragadesh-45@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:19:14 +0530 Subject: [PATCH] Feat/content indication for collections and folders (#3359) feat: content indication for collections and folders --- .../components/CollectionSettings/index.js | 32 ++++++++++++++++++- .../src/components/FolderSettings/index.js | 24 ++++++++++++++ .../RequestPane/HttpRequestPane/index.js | 10 ++++-- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/index.js index d7698e26c..5cc7c34e5 100644 --- a/packages/bruno-app/src/components/CollectionSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/index.js @@ -17,6 +17,15 @@ import Presets from './Presets'; import Info from './Info'; import StyledWrapper from './StyledWrapper'; import Vars from './Vars/index'; +import DotIcon from 'components/Icons/Dot'; + +const ContentIndicator = () => { + return ( + + + + ); +}; const CollectionSettings = ({ collection }) => { const dispatch = useDispatch(); @@ -30,10 +39,23 @@ const CollectionSettings = ({ collection }) => { ); }; - const proxyConfig = get(collection, 'brunoConfig.proxy', {}); + const root = collection?.root; + const hasScripts = root?.request?.script.res || root?.request?.script.req; + const hasTests = root?.request?.tests; + const hasDocs = root?.docs; + const headers = get(collection, 'root.request.headers', []); + const activeHeadersCount = headers.filter((header) => header.enabled).length; + + const requestVars = get(collection, 'root.request.vars.req', []); + const responseVars = get(collection, 'root.request.vars.res', []); + const activeVarsCount = requestVars.filter((v) => v.enabled).length + responseVars.filter((v) => v.enabled).length; + const auth = get(collection, 'root.request.auth', {}).mode; + + const proxyConfig = get(collection, 'brunoConfig.proxy', {}); const clientCertConfig = get(collection, 'brunoConfig.clientCertificates.certs', []); + const onProxySettingsUpdate = (config) => { const brunoConfig = cloneDeep(collection.brunoConfig); brunoConfig.proxy = config; @@ -126,30 +148,38 @@ const CollectionSettings = ({ collection }) => {
setTab('headers')}> Headers + {activeHeadersCount > 0 && {activeHeadersCount}}
setTab('vars')}> Vars + {activeVarsCount > 0 && {activeVarsCount}}
setTab('auth')}> Auth + {auth !== 'none' && }
setTab('script')}> Script + {hasScripts && }
setTab('tests')}> Tests + {hasTests && }
setTab('presets')}> Presets
setTab('proxy')}> Proxy + {Object.keys(proxyConfig).length > 0 && }
setTab('clientCert')}> Client Certificates + {clientCertConfig.length > 0 && }
setTab('docs')}> Docs + {hasDocs && }
setTab('info')}> Info diff --git a/packages/bruno-app/src/components/FolderSettings/index.js b/packages/bruno-app/src/components/FolderSettings/index.js index 966c36b36..dba5f170d 100644 --- a/packages/bruno-app/src/components/FolderSettings/index.js +++ b/packages/bruno-app/src/components/FolderSettings/index.js @@ -7,6 +7,15 @@ import Script from './Script'; import Tests from './Tests'; import StyledWrapper from './StyledWrapper'; import Vars from './Vars'; +import DotIcon from 'components/Icons/Dot'; + +const ContentIndicator = () => { + return ( + + + + ); +}; const FolderSettings = ({ collection, folder }) => { const dispatch = useDispatch(); @@ -16,6 +25,17 @@ const FolderSettings = ({ collection, folder }) => { tab = folderLevelSettingsSelectedTab[folder?.uid]; } + const folderRoot = collection?.items.find((item) => item.uid === folder?.uid)?.root; + const hasScripts = folderRoot?.request?.script.res || folderRoot?.request?.script.req; + const hasTests = folderRoot?.request?.tests; + + const headers = folderRoot?.request?.headers || []; + const activeHeadersCount = headers.filter((header) => header.enabled).length; + + const requestVars = folderRoot?.request?.vars?.req || []; + const responseVars = folderRoot?.request?.vars?.res || []; + const activeVarsCount = requestVars.filter((v) => v.enabled).length + responseVars.filter((v) => v.enabled).length; + const setTab = (tab) => { dispatch( updatedFolderSettingsSelectedTab({ @@ -55,15 +75,19 @@ const FolderSettings = ({ collection, folder }) => {
setTab('headers')}> Headers + {activeHeadersCount > 0 && {activeHeadersCount}}
setTab('script')}> Script + {hasScripts && }
setTab('test')}> Test + {hasTests && }
setTab('vars')}> Vars + {activeVarsCount > 0 && {activeVarsCount}}
{getTabPanel(tab)}
diff --git a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js index d2032f7f4..09a665e9f 100644 --- a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js +++ b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js @@ -17,9 +17,11 @@ import { find, get } from 'lodash'; import Documentation from 'components/Documentation/index'; const ContentIndicator = () => { - return - - + return ( + + + + ); }; const HttpRequestPane = ({ item, collection, leftPaneWidth }) => { @@ -100,6 +102,7 @@ const HttpRequestPane = ({ item, collection, leftPaneWidth }) => { const docs = getPropertyFromDraftOrRequest('request.docs'); const requestVars = getPropertyFromDraftOrRequest('request.vars.req'); const responseVars = getPropertyFromDraftOrRequest('request.vars.res'); + const auth = getPropertyFromDraftOrRequest('request.auth'); const activeParamsLength = params.filter((param) => param.enabled).length; const activeHeadersLength = headers.filter((header) => header.enabled).length; @@ -125,6 +128,7 @@ const HttpRequestPane = ({ item, collection, leftPaneWidth }) => {
selectTab('auth')}> Auth + {auth.mode !== 'none' && }
selectTab('vars')}> Vars