mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 13:45:52 +00:00
fixes: coderabbit
This commit is contained in:
@@ -33,6 +33,10 @@ const RemoveCollection = ({ onClose, collectionUid }) => {
|
||||
.catch(() => toast.error('An error occurred while removing the collection'));
|
||||
};
|
||||
|
||||
if (!collection) {
|
||||
return <div>Collection not found</div>;
|
||||
}
|
||||
|
||||
// If there are drafts, show the draft confirmation modal
|
||||
if (drafts.length > 0) {
|
||||
return <ConfirmCollectionCloseDrafts onClose={onClose} collection={collection} collectionUid={collectionUid} />;
|
||||
|
||||
@@ -36,6 +36,11 @@ const WorkspaceDocs = ({ workspace }) => {
|
||||
};
|
||||
|
||||
const onSave = async () => {
|
||||
if (!workspace) {
|
||||
toast.error('Workspace not found');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await dispatch(saveWorkspaceDocs(workspace.uid, localDocs));
|
||||
toast.success('Documentation saved successfully');
|
||||
@@ -76,7 +81,7 @@ const WorkspaceDocs = ({ workspace }) => {
|
||||
value={localDocs}
|
||||
onEdit={onEdit}
|
||||
onSave={onSave}
|
||||
mode="application/text"
|
||||
mode="markdown"
|
||||
font={get(preferences, 'font.codeFont', 'default')}
|
||||
fontSize={get(preferences, 'font.codeFontSize')}
|
||||
/>
|
||||
|
||||
@@ -14,10 +14,10 @@ const ImportEnvironment = ({ onClose, onEnvironmentCreated }) => {
|
||||
const handleImportPostmanEnvironment = () => {
|
||||
importPostmanEnvironment()
|
||||
.then((environments) => {
|
||||
environments
|
||||
const importPromises = environments
|
||||
.filter((env) =>
|
||||
env.name && env.name !== 'undefined')
|
||||
.map((environment) => {
|
||||
.map((environment) =>
|
||||
dispatch(addGlobalEnvironment({ name: environment.name, variables: environment.variables }))
|
||||
.then(() => {
|
||||
toast.success('Environment imported successfully');
|
||||
@@ -25,8 +25,8 @@ const ImportEnvironment = ({ onClose, onEnvironmentCreated }) => {
|
||||
.catch((error) => {
|
||||
toast.error('An error occurred while importing the environment');
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
}));
|
||||
return Promise.all(importPromises);
|
||||
})
|
||||
.then(() => {
|
||||
onClose();
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
const Wrapper = styled.div``;
|
||||
|
||||
export default Wrapper;
|
||||
@@ -8,7 +8,6 @@ import { createWorkspaceAction } from 'providers/ReduxStore/slices/workspaces/ac
|
||||
import { browseDirectory } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import { multiLineMsg } from 'utils/common/index';
|
||||
import { formatIpcError } from 'utils/common/error';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
|
||||
const CreateWorkspace = ({ onClose }) => {
|
||||
const inputRef = useRef();
|
||||
@@ -72,75 +71,73 @@ const CreateWorkspace = ({ onClose }) => {
|
||||
}, [inputRef]);
|
||||
|
||||
return (
|
||||
<StyledWrapper>
|
||||
<Modal
|
||||
size="md"
|
||||
title="Create Workspace"
|
||||
description="Give your new workspace a name and choose its type to get started."
|
||||
confirmText={isSubmitting ? 'Creating...' : 'Create Workspace'}
|
||||
handleConfirm={formik.handleSubmit}
|
||||
handleCancel={onClose}
|
||||
style="new"
|
||||
confirmDisabled={isSubmitting}
|
||||
>
|
||||
<div>
|
||||
<form className="bruno-form" onSubmit={formik.handleSubmit}>
|
||||
<div className="mb-4">
|
||||
<label htmlFor="workspaceName" className="block font-semibold mb-2">
|
||||
Name
|
||||
</label>
|
||||
<Modal
|
||||
size="md"
|
||||
title="Create Workspace"
|
||||
description="Give your new workspace a name and choose its type to get started."
|
||||
confirmText={isSubmitting ? 'Creating...' : 'Create Workspace'}
|
||||
handleConfirm={formik.handleSubmit}
|
||||
handleCancel={onClose}
|
||||
style="new"
|
||||
confirmDisabled={isSubmitting}
|
||||
>
|
||||
<div>
|
||||
<form className="bruno-form" onSubmit={formik.handleSubmit}>
|
||||
<div className="mb-4">
|
||||
<label htmlFor="workspaceName" className="block font-semibold mb-2">
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
id="workspace-name"
|
||||
type="text"
|
||||
name="workspaceName"
|
||||
ref={inputRef}
|
||||
className="block textbox w-full"
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
autoCapitalize="off"
|
||||
spellCheck="false"
|
||||
onChange={formik.handleChange}
|
||||
value={formik.values.workspaceName || ''}
|
||||
/>
|
||||
{formik.touched.workspaceName && formik.errors.workspaceName ? (
|
||||
<div className="text-red-500 text-sm mt-1">{formik.errors.workspaceName}</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="mb-4">
|
||||
<label htmlFor="workspaceLocation" className="block font-semibold mb-2">
|
||||
Location
|
||||
<span className="ml-1 text-gray-500 text-sm">
|
||||
<svg className="inline w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
id="workspace-name"
|
||||
id="workspace-location"
|
||||
type="text"
|
||||
name="workspaceName"
|
||||
ref={inputRef}
|
||||
className="block textbox w-full"
|
||||
name="workspaceLocation"
|
||||
readOnly={true}
|
||||
className="block textbox flex-1 bg-gray-50"
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
autoCapitalize="off"
|
||||
spellCheck="false"
|
||||
onChange={formik.handleChange}
|
||||
value={formik.values.workspaceName || ''}
|
||||
value={formik.values.workspaceLocation || ''}
|
||||
/>
|
||||
{formik.touched.workspaceName && formik.errors.workspaceName ? (
|
||||
<div className="text-red-500 text-sm mt-1">{formik.errors.workspaceName}</div>
|
||||
) : null}
|
||||
<button type="button" className="btn btn-sm btn-secondary" onClick={browse}>
|
||||
Browse
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mb-4">
|
||||
<label htmlFor="workspaceLocation" className="block font-semibold mb-2">
|
||||
Location
|
||||
<span className="ml-1 text-gray-500 text-sm">
|
||||
<svg className="inline w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
id="workspace-location"
|
||||
type="text"
|
||||
name="workspaceLocation"
|
||||
readOnly={true}
|
||||
className="block textbox flex-1 bg-gray-50"
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
autoCapitalize="off"
|
||||
spellCheck="false"
|
||||
value={formik.values.workspaceLocation || ''}
|
||||
/>
|
||||
<button type="button" className="btn btn-sm btn-secondary" onClick={browse}>
|
||||
Browse
|
||||
</button>
|
||||
</div>
|
||||
{formik.touched.workspaceLocation && formik.errors.workspaceLocation ? (
|
||||
<div className="text-red-500 text-sm mt-1">{formik.errors.workspaceLocation}</div>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</Modal>
|
||||
</StyledWrapper>
|
||||
{formik.touched.workspaceLocation && formik.errors.workspaceLocation ? (
|
||||
<div className="text-red-500 text-sm mt-1">{formik.errors.workspaceLocation}</div>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user