From 51784d08cd2caf99d6b120f77aab33415ec09398 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sun, 23 Oct 2022 11:57:35 +0530 Subject: [PATCH] fix: fixed bugs --- .../EnvironmentSettings/EnvironmentList/index.js | 4 ++-- .../Collection/RemoveCollectionFromWorkspace/index.js | 1 - .../Collections/CreateOrAddCollection/StyledWrapper.js | 7 +++++++ .../Sidebar/Collections/CreateOrAddCollection/index.js | 5 +++-- packages/bruno-app/src/themes/dark.js | 3 ++- packages/bruno-app/src/themes/light.js | 3 ++- packages/bruno-app/src/utils/collections/import.js | 7 ++++--- 7 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/StyledWrapper.js diff --git a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js index 02034f661..4daff582c 100644 --- a/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js +++ b/packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js @@ -9,8 +9,8 @@ const EnvironmentList = ({ collection }) => { const [openCreateModal, setOpenCreateModal] = useState(false); useEffect(() => { - setSelectedEnvironment(environments[0]); - }, []); + setSelectedEnvironment(environments && environments.length ? environments[0] : null); + }, [environments]); if (!selectedEnvironment) { return null; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js index 5b22f0d4e..ed3b314be 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js @@ -20,7 +20,6 @@ const RemoveCollectionFromWorkspace = ({ onClose, collection }) => { }) ); }) - .then(() => dispatch(removeLocalCollection(collection.uid))) .then(() => toast.success('Collection removed from workspace')) .catch((err) => console.log(err) && toast.error('An error occured while removing the collection')); }; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/StyledWrapper.js b/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/StyledWrapper.js new file mode 100644 index 000000000..f392dffa5 --- /dev/null +++ b/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/StyledWrapper.js @@ -0,0 +1,7 @@ +import styled from 'styled-components'; + +const Wrapper = styled.div` + color: ${(props) => props.theme.colors.text.muted}; +`; + +export default Wrapper; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/index.js b/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/index.js index 4ad41d08d..131876bb9 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/CreateOrAddCollection/index.js @@ -8,6 +8,7 @@ import toast from 'react-hot-toast'; import styled from 'styled-components'; import CreateCollection from 'components/Sidebar/CreateCollection'; import SelectCollection from 'components/Sidebar/Collections/SelectCollection'; +import StyledWrapper from './StyledWrapper'; const LinkStyle = styled.span` color: ${(props) => props.theme['text-link']}; @@ -50,7 +51,7 @@ const CreateOrAddCollection = () => { ); return ( -
+ {createCollectionModalOpen ? setCreateCollectionModalOpen(false)} handleConfirm={handleCreateCollection} /> : null} {addCollectionToWSModalOpen ? ( @@ -63,7 +64,7 @@ const CreateOrAddCollection = () => { or Collection to Workspace.
- + ); }; diff --git a/packages/bruno-app/src/themes/dark.js b/packages/bruno-app/src/themes/dark.js index 8e21528f6..99967b88c 100644 --- a/packages/bruno-app/src/themes/dark.js +++ b/packages/bruno-app/src/themes/dark.js @@ -6,7 +6,8 @@ const darkTheme = { colors: { text: { - danger: '#f06f57' + danger: '#f06f57', + muted: '#9d9d9d' }, bg: { danger: '#d03544' diff --git a/packages/bruno-app/src/themes/light.js b/packages/bruno-app/src/themes/light.js index eb669db97..73a68ca8d 100644 --- a/packages/bruno-app/src/themes/light.js +++ b/packages/bruno-app/src/themes/light.js @@ -6,7 +6,8 @@ const lightTheme = { colors: { text: { - danger: 'rgb(185, 28, 28)' + danger: 'rgb(185, 28, 28)', + muted: '#4b5563', }, bg: { danger: '#dc3545' diff --git a/packages/bruno-app/src/utils/collections/import.js b/packages/bruno-app/src/utils/collections/import.js index e6b087da0..3b8b01989 100644 --- a/packages/bruno-app/src/utils/collections/import.js +++ b/packages/bruno-app/src/utils/collections/import.js @@ -2,6 +2,7 @@ import each from 'lodash/each'; import get from 'lodash/get'; import fileDialog from 'file-dialog'; import toast from 'react-hot-toast'; +import cloneDeep from 'lodash/cloneDeep'; import { uuid } from 'utils/common'; import { collectionSchema } from '@usebruno/schema'; import { saveCollectionToIdb } from 'utils/idb'; @@ -29,7 +30,6 @@ const parseJsonCollection = (str) => { }; const validateSchema = (collection = {}) => { - collection.uid = uuid(); return new Promise((resolve, reject) => { collectionSchema .validate(collection) @@ -41,7 +41,9 @@ const validateSchema = (collection = {}) => { }); }; -const updateUidsInCollection = (collection) => { +const updateUidsInCollection = (_collection) => { + const collection = cloneDeep(_collection); + collection.uid = uuid(); const updateItemUids = (items = []) => { @@ -86,7 +88,6 @@ const importCollection = () => { export const importSampleCollection = () => { return new Promise((resolve, reject) => { validateSchema(sampleCollection) - .then(validateSchema) .then(updateUidsInCollection) .then(validateSchema) .then((collection) => saveCollectionToIdb(window.__idb, collection))