fix: fixed bugs

This commit is contained in:
Anoop M D 2022-10-23 11:57:35 +05:30
parent 96f50b0c6d
commit 51784d08cd
7 changed files with 20 additions and 10 deletions

View File

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

View File

@ -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'));
};

View File

@ -0,0 +1,7 @@
import styled from 'styled-components';
const Wrapper = styled.div`
color: ${(props) => props.theme.colors.text.muted};
`;
export default Wrapper;

View File

@ -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 (
<div className="px-2 mt-4 text-gray-600">
<StyledWrapper className="px-2 mt-4">
{createCollectionModalOpen ? <CreateCollection handleCancel={() => setCreateCollectionModalOpen(false)} handleConfirm={handleCreateCollection} /> : null}
{addCollectionToWSModalOpen ? (
@ -63,7 +64,7 @@ const CreateOrAddCollection = () => {
<CreateLink /> or <AddLink /> Collection to Workspace.
</div>
</div>
</div>
</StyledWrapper>
);
};

View File

@ -6,7 +6,8 @@ const darkTheme = {
colors: {
text: {
danger: '#f06f57'
danger: '#f06f57',
muted: '#9d9d9d'
},
bg: {
danger: '#d03544'

View File

@ -6,7 +6,8 @@ const lightTheme = {
colors: {
text: {
danger: 'rgb(185, 28, 28)'
danger: 'rgb(185, 28, 28)',
muted: '#4b5563',
},
bg: {
danger: '#dc3545'

View File

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