alternate collection

This commit is contained in:
tlaloc911 2024-11-27 04:20:49 +00:00
parent dce96e0f13
commit 6fc1f4e94e
2 changed files with 25 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import { uuid } from 'utils/common';
import { IconFiles, IconRun, IconEye, IconSettings } from '@tabler/icons';
import { IconRun, IconEye, IconSettings, IconAB2 } from '@tabler/icons';
import EnvironmentSelector from 'components/Environments/EnvironmentSelector';
import GlobalEnvironmentSelector from 'components/GlobalEnvironments/EnvironmentSelector';
import { addTab } from 'providers/ReduxStore/slices/tabs';
@ -9,7 +9,7 @@ import ToolHint from 'components/ToolHint';
import StyledWrapper from './StyledWrapper';
import JsSandboxMode from 'components/SecuritySettings/JsSandboxMode';
const CollectionToolBar = ({ collection }) => {
const CollectionToolBar = ({ collection, onClick }) => {
const dispatch = useDispatch();
const handleRun = () => {
@ -45,9 +45,9 @@ const CollectionToolBar = ({ collection }) => {
return (
<StyledWrapper>
<div className="flex items-center p-2">
<div className="flex flex-1 items-center cursor-pointer hover:underline" onClick={viewCollectionSettings}>
<IconFiles size={18} strokeWidth={1.5} />
<span className="ml-2 mr-4 font-semibold">{collection?.name}</span>
<div className="flex flex-1 items-center cursor-pointer hover:underline" onClick={onClick} >
<span className="ml-2 mr-2 font-semibold" >{collection?.name}</span>
<IconAB2 size={18} strokeWidth={1.5} />
</div>
<div className="flex flex-3 items-center justify-end">
<span className="mr-2">

View File

@ -20,6 +20,25 @@ const RequestTabs = () => {
const leftSidebarWidth = useSelector((state) => state.app.leftSidebarWidth);
const screenWidth = useSelector((state) => state.app.screenWidth);
const otherCollection = () => {
let currentCollectionUid = activeTab.collectionUid
let index = collections.findIndex((collection) => collection.uid === currentCollectionUid);
let otherTab = null
while (otherTab == null) {
index = (index + 1) % collections.length
currentCollectionUid = collections[index].uid
otherTab = find(tabs, (t) => t.collectionUid === collections[index].uid);
}
dispatch(
focusTab({
uid: otherTab.uid
})
)
};
const getTabClassname = (tab, index) => {
return classnames('request-tab select-none', {
active: tab.uid === activeTabUid,
@ -83,7 +102,7 @@ const RequestTabs = () => {
)}
{collectionRequestTabs && collectionRequestTabs.length ? (
<>
<CollectionToolBar collection={activeCollection} />
<CollectionToolBar collection={activeCollection} onClick={otherCollection} />
<div className="flex items-center pl-4">
<ul role="tablist">
{showChevrons ? (