mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Unsafe deletion of a protofile (#2798)
This commit is contained in:
parent
e6bdbf27ea
commit
175834efa9
@ -10,7 +10,7 @@ import type { Workspace } from '../../../models/workspace';
|
||||
import Modal from '../base/modal';
|
||||
import ProtoFileList from '../proto-file/proto-file-list';
|
||||
import FileInputButton from '../base/file-input-button';
|
||||
import { showError } from './index';
|
||||
import { showAlert, showError } from './index';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@ -72,9 +72,25 @@ class ProtoFilesModal extends React.PureComponent<Props, State> {
|
||||
this.setState({ selectedProtoFileId: id });
|
||||
}
|
||||
|
||||
_handleDelete(protoFile: ProtoFile) {
|
||||
// TODO: to be built in INS-209
|
||||
console.log(`delete ${protoFile._id}`);
|
||||
async _handleDelete(protoFile: ProtoFile) {
|
||||
showAlert({
|
||||
title: `Delete ${protoFile.name}`,
|
||||
message: (
|
||||
<span>
|
||||
Really delete <strong>{protoFile.name}</strong>? All requests that use this proto file
|
||||
will stop working.
|
||||
</span>
|
||||
),
|
||||
addCancel: true,
|
||||
onConfirm: async () => {
|
||||
await models.protoFile.remove(protoFile);
|
||||
|
||||
// if the deleted protoFile was previously selected, clear the selection
|
||||
if (this.state.selectedProtoFileId === protoFile._id) {
|
||||
this.setState({ selectedProtoFileId: '' });
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async _handleProtoFileUpload(filePath: string) {
|
||||
|
@ -2,13 +2,12 @@
|
||||
import * as React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import type { ProtoFile } from '../../../models/proto-file';
|
||||
import PromptButton from '../base/prompt-button';
|
||||
import type {
|
||||
DeleteProtoFileHandler,
|
||||
RenameProtoFileHandler,
|
||||
SelectProtoFileHandler,
|
||||
} from './proto-file-list';
|
||||
import { ListGroupItem } from '../../../../../insomnia-components';
|
||||
import { ListGroupItem, Button } from '../../../../../insomnia-components';
|
||||
import Editable from '../base/editable';
|
||||
|
||||
type Props = {
|
||||
@ -55,15 +54,10 @@ const ProtoFileListItem = ({
|
||||
return (
|
||||
<SelectableListItem isSelected={isSelected} onClick={handleSelectCallback}>
|
||||
<div className="row-spaced">
|
||||
<Editable onSubmit={handleRenameCallback} value={name} preventBlank />
|
||||
<PromptButton
|
||||
className="btn btn--super-compact btn--outlined"
|
||||
addIcon
|
||||
confirmMessage=""
|
||||
onClick={handleDeleteCallback}
|
||||
title="Delete Proto File">
|
||||
<Editable className="wide" onSubmit={handleRenameCallback} value={name} preventBlank />
|
||||
<Button size="small" title="Delete Proto File" onClick={handleDeleteCallback}>
|
||||
<i className="fa fa-trash-o" />
|
||||
</PromptButton>
|
||||
</Button>
|
||||
</div>
|
||||
</SelectableListItem>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user