mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 20:55:41 +00:00
fixes (#6383)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { IconPlus, IconFolder, IconFileImport } from '@tabler/icons';
|
||||
import { importCollectionInWorkspace } from 'providers/ReduxStore/slices/workspaces/actions';
|
||||
@@ -12,24 +12,14 @@ import StyledWrapper from './StyledWrapper';
|
||||
|
||||
const WorkspaceOverview = ({ workspace }) => {
|
||||
const dispatch = useDispatch();
|
||||
const { collections } = useSelector((state) => state.collections);
|
||||
const { globalEnvironments } = useSelector((state) => state.globalEnvironments);
|
||||
|
||||
const [createCollectionModalOpen, setCreateCollectionModalOpen] = useState(false);
|
||||
const [importCollectionModalOpen, setImportCollectionModalOpen] = useState(false);
|
||||
|
||||
const workspaceCollectionsCount = workspace?.collections?.length || 0;
|
||||
|
||||
const workspaceEnvironmentsCount = useMemo(() => {
|
||||
if (!workspace?.collections || !collections) return 0;
|
||||
let count = 0;
|
||||
workspace.collections.forEach((wc) => {
|
||||
const loadedCollection = collections.find((c) => c.pathname === wc.path);
|
||||
if (loadedCollection?.environments) {
|
||||
count += loadedCollection.environments.length;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}, [workspace?.collections, collections]);
|
||||
const workspaceEnvironmentsCount = globalEnvironments?.length || 0;
|
||||
|
||||
const handleCreateCollection = async () => {
|
||||
if (!workspace?.pathname) {
|
||||
|
||||
@@ -213,7 +213,7 @@ const addCollectionToWorkspace = async (workspacePath, collection) => {
|
||||
normalizedCollection.remote = collection.remote;
|
||||
}
|
||||
|
||||
const existingIndex = config.collections.findIndex((c) => c.name === normalizedCollection.name || c.path === normalizedCollection.path);
|
||||
const existingIndex = config.collections.findIndex((c) => c.path === normalizedCollection.path);
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
config.collections[existingIndex] = normalizedCollection;
|
||||
|
||||
Reference in New Issue
Block a user