This commit is contained in:
naman-bruno
2025-12-11 19:49:27 +05:30
committed by GitHub
parent 50a72a16bc
commit 575f37124c
2 changed files with 4 additions and 14 deletions

View File

@@ -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) {

View File

@@ -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;