mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
Feat/content indication for collections and folders (#3359)
feat: content indication for collections and folders
This commit is contained in:
parent
e8530a1022
commit
22bc1d4ac5
@ -17,6 +17,15 @@ import Presets from './Presets';
|
|||||||
import Info from './Info';
|
import Info from './Info';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
import Vars from './Vars/index';
|
import Vars from './Vars/index';
|
||||||
|
import DotIcon from 'components/Icons/Dot';
|
||||||
|
|
||||||
|
const ContentIndicator = () => {
|
||||||
|
return (
|
||||||
|
<sup className="ml-[.125rem] opacity-80 font-medium">
|
||||||
|
<DotIcon width="10"></DotIcon>
|
||||||
|
</sup>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const CollectionSettings = ({ collection }) => {
|
const CollectionSettings = ({ collection }) => {
|
||||||
const dispatch = useDispatch();
|
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 clientCertConfig = get(collection, 'brunoConfig.clientCertificates.certs', []);
|
||||||
|
|
||||||
|
|
||||||
const onProxySettingsUpdate = (config) => {
|
const onProxySettingsUpdate = (config) => {
|
||||||
const brunoConfig = cloneDeep(collection.brunoConfig);
|
const brunoConfig = cloneDeep(collection.brunoConfig);
|
||||||
brunoConfig.proxy = config;
|
brunoConfig.proxy = config;
|
||||||
@ -126,30 +148,38 @@ const CollectionSettings = ({ collection }) => {
|
|||||||
<div className="flex flex-wrap items-center tabs" role="tablist">
|
<div className="flex flex-wrap items-center tabs" role="tablist">
|
||||||
<div className={getTabClassname('headers')} role="tab" onClick={() => setTab('headers')}>
|
<div className={getTabClassname('headers')} role="tab" onClick={() => setTab('headers')}>
|
||||||
Headers
|
Headers
|
||||||
|
{activeHeadersCount > 0 && <sup className="ml-1 font-medium">{activeHeadersCount}</sup>}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('vars')} role="tab" onClick={() => setTab('vars')}>
|
<div className={getTabClassname('vars')} role="tab" onClick={() => setTab('vars')}>
|
||||||
Vars
|
Vars
|
||||||
|
{activeVarsCount > 0 && <sup className="ml-1 font-medium">{activeVarsCount}</sup>}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('auth')} role="tab" onClick={() => setTab('auth')}>
|
<div className={getTabClassname('auth')} role="tab" onClick={() => setTab('auth')}>
|
||||||
Auth
|
Auth
|
||||||
|
{auth !== 'none' && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('script')} role="tab" onClick={() => setTab('script')}>
|
<div className={getTabClassname('script')} role="tab" onClick={() => setTab('script')}>
|
||||||
Script
|
Script
|
||||||
|
{hasScripts && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('tests')} role="tab" onClick={() => setTab('tests')}>
|
<div className={getTabClassname('tests')} role="tab" onClick={() => setTab('tests')}>
|
||||||
Tests
|
Tests
|
||||||
|
{hasTests && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('presets')} role="tab" onClick={() => setTab('presets')}>
|
<div className={getTabClassname('presets')} role="tab" onClick={() => setTab('presets')}>
|
||||||
Presets
|
Presets
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('proxy')} role="tab" onClick={() => setTab('proxy')}>
|
<div className={getTabClassname('proxy')} role="tab" onClick={() => setTab('proxy')}>
|
||||||
Proxy
|
Proxy
|
||||||
|
{Object.keys(proxyConfig).length > 0 && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('clientCert')} role="tab" onClick={() => setTab('clientCert')}>
|
<div className={getTabClassname('clientCert')} role="tab" onClick={() => setTab('clientCert')}>
|
||||||
Client Certificates
|
Client Certificates
|
||||||
|
{clientCertConfig.length > 0 && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('docs')} role="tab" onClick={() => setTab('docs')}>
|
<div className={getTabClassname('docs')} role="tab" onClick={() => setTab('docs')}>
|
||||||
Docs
|
Docs
|
||||||
|
{hasDocs && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('info')} role="tab" onClick={() => setTab('info')}>
|
<div className={getTabClassname('info')} role="tab" onClick={() => setTab('info')}>
|
||||||
Info
|
Info
|
||||||
|
@ -7,6 +7,15 @@ import Script from './Script';
|
|||||||
import Tests from './Tests';
|
import Tests from './Tests';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
import Vars from './Vars';
|
import Vars from './Vars';
|
||||||
|
import DotIcon from 'components/Icons/Dot';
|
||||||
|
|
||||||
|
const ContentIndicator = () => {
|
||||||
|
return (
|
||||||
|
<sup className="ml-[.125rem] opacity-80 font-medium">
|
||||||
|
<DotIcon width="10"></DotIcon>
|
||||||
|
</sup>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const FolderSettings = ({ collection, folder }) => {
|
const FolderSettings = ({ collection, folder }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -16,6 +25,17 @@ const FolderSettings = ({ collection, folder }) => {
|
|||||||
tab = folderLevelSettingsSelectedTab[folder?.uid];
|
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) => {
|
const setTab = (tab) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
updatedFolderSettingsSelectedTab({
|
updatedFolderSettingsSelectedTab({
|
||||||
@ -55,15 +75,19 @@ const FolderSettings = ({ collection, folder }) => {
|
|||||||
<div className="flex flex-wrap items-center tabs" role="tablist">
|
<div className="flex flex-wrap items-center tabs" role="tablist">
|
||||||
<div className={getTabClassname('headers')} role="tab" onClick={() => setTab('headers')}>
|
<div className={getTabClassname('headers')} role="tab" onClick={() => setTab('headers')}>
|
||||||
Headers
|
Headers
|
||||||
|
{activeHeadersCount > 0 && <sup className="ml-1 font-medium">{activeHeadersCount}</sup>}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('script')} role="tab" onClick={() => setTab('script')}>
|
<div className={getTabClassname('script')} role="tab" onClick={() => setTab('script')}>
|
||||||
Script
|
Script
|
||||||
|
{hasScripts && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('test')} role="tab" onClick={() => setTab('test')}>
|
<div className={getTabClassname('test')} role="tab" onClick={() => setTab('test')}>
|
||||||
Test
|
Test
|
||||||
|
{hasTests && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('vars')} role="tab" onClick={() => setTab('vars')}>
|
<div className={getTabClassname('vars')} role="tab" onClick={() => setTab('vars')}>
|
||||||
Vars
|
Vars
|
||||||
|
{activeVarsCount > 0 && <sup className="ml-1 font-medium">{activeVarsCount}</sup>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<section className={`flex mt-4 h-full`}>{getTabPanel(tab)}</section>
|
<section className={`flex mt-4 h-full`}>{getTabPanel(tab)}</section>
|
||||||
|
@ -17,9 +17,11 @@ import { find, get } from 'lodash';
|
|||||||
import Documentation from 'components/Documentation/index';
|
import Documentation from 'components/Documentation/index';
|
||||||
|
|
||||||
const ContentIndicator = () => {
|
const ContentIndicator = () => {
|
||||||
return <sup className="ml-[.125rem] opacity-80 font-medium">
|
return (
|
||||||
|
<sup className="ml-[.125rem] opacity-80 font-medium">
|
||||||
<DotIcon width="10"></DotIcon>
|
<DotIcon width="10"></DotIcon>
|
||||||
</sup>
|
</sup>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const HttpRequestPane = ({ item, collection, leftPaneWidth }) => {
|
const HttpRequestPane = ({ item, collection, leftPaneWidth }) => {
|
||||||
@ -100,6 +102,7 @@ const HttpRequestPane = ({ item, collection, leftPaneWidth }) => {
|
|||||||
const docs = getPropertyFromDraftOrRequest('request.docs');
|
const docs = getPropertyFromDraftOrRequest('request.docs');
|
||||||
const requestVars = getPropertyFromDraftOrRequest('request.vars.req');
|
const requestVars = getPropertyFromDraftOrRequest('request.vars.req');
|
||||||
const responseVars = getPropertyFromDraftOrRequest('request.vars.res');
|
const responseVars = getPropertyFromDraftOrRequest('request.vars.res');
|
||||||
|
const auth = getPropertyFromDraftOrRequest('request.auth');
|
||||||
|
|
||||||
const activeParamsLength = params.filter((param) => param.enabled).length;
|
const activeParamsLength = params.filter((param) => param.enabled).length;
|
||||||
const activeHeadersLength = headers.filter((header) => header.enabled).length;
|
const activeHeadersLength = headers.filter((header) => header.enabled).length;
|
||||||
@ -125,6 +128,7 @@ const HttpRequestPane = ({ item, collection, leftPaneWidth }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('auth')} role="tab" onClick={() => selectTab('auth')}>
|
<div className={getTabClassname('auth')} role="tab" onClick={() => selectTab('auth')}>
|
||||||
Auth
|
Auth
|
||||||
|
{auth.mode !== 'none' && <ContentIndicator />}
|
||||||
</div>
|
</div>
|
||||||
<div className={getTabClassname('vars')} role="tab" onClick={() => selectTab('vars')}>
|
<div className={getTabClassname('vars')} role="tab" onClick={() => selectTab('vars')}>
|
||||||
Vars
|
Vars
|
||||||
|
Loading…
Reference in New Issue
Block a user