From 7ef73dfb2e4c7ee97af0abfbbea3c0cc77e02899 Mon Sep 17 00:00:00 2001 From: Jack Kavanagh Date: Tue, 11 Oct 2022 10:27:06 +0200 Subject: [PATCH] add rename options to request context options (#5256) * add rename folder and request context options * Add rename dropdown option for WS requests Co-authored-by: Filipe Freire --- .../dropdowns/request-actions-dropdown.tsx | 22 ++++++++++++++++++- .../request-group-actions-dropdown.tsx | 18 +++++++++++++++ .../websocket-request-actions-dropdown.tsx | 21 ++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/packages/insomnia/src/ui/components/dropdowns/request-actions-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/request-actions-dropdown.tsx index b7794bb26..61328c8bb 100644 --- a/packages/insomnia/src/ui/components/dropdowns/request-actions-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/request-actions-dropdown.tsx @@ -25,7 +25,7 @@ import { DropdownDivider } from '../base/dropdown/dropdown-divider'; import { DropdownHint } from '../base/dropdown/dropdown-hint'; import { DropdownItem } from '../base/dropdown/dropdown-item'; import { PromptButton } from '../base/prompt-button'; -import { showError, showModal } from '../modals'; +import { showError, showModal, showPrompt } from '../modals'; import { GenerateCodeModal } from '../modals/generate-code-modal'; interface Props extends Pick { @@ -104,6 +104,19 @@ export const RequestActionsDropdown = forwardRef(({ } }, [activeEnvironment, request._id]); + const handleRename = useCallback(() => { + showPrompt({ + title: 'Rename Request', + defaultValue: request.name, + submitName: 'Rename', + selectText: true, + label: 'Name', + onComplete: name => { + requestOperations.update(request, { name }); + }, + }); + }, [request]); + const togglePin = useCallback(() => { updateRequestMetaByParentId(request._id, { pinned: !isPinned }); }, [isPinned, request]); @@ -146,6 +159,13 @@ export const RequestActionsDropdown = forwardRef(({ )} + + Rename + + { + showPrompt({ + title: 'Rename Folder', + defaultValue: requestGroup.name, + submitName: 'Rename', + selectText: true, + label: 'Name', + onComplete: name => { + requestOperations.update(requestGroup, { name }); + }, + }); + }, [requestGroup]); + const handleDeleteFolder = useCallback(async () => { await models.stats.incrementDeletedRequestsForDescendents(requestGroup); models.requestGroup.remove(requestGroup); @@ -164,6 +178,10 @@ export const RequestGroupActionsDropdown = forwardRef Environment + + Rename + + Delete diff --git a/packages/insomnia/src/ui/components/dropdowns/websocket-request-actions-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/websocket-request-actions-dropdown.tsx index 2c1e8007b..fcdcd0934 100644 --- a/packages/insomnia/src/ui/components/dropdowns/websocket-request-actions-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/websocket-request-actions-dropdown.tsx @@ -12,6 +12,7 @@ import { DropdownDivider } from '../base/dropdown/dropdown-divider'; import { DropdownHint } from '../base/dropdown/dropdown-hint'; import { DropdownItem } from '../base/dropdown/dropdown-item'; import { PromptButton } from '../base/prompt-button'; +import { showPrompt } from '../modals'; interface Props extends Pick { handleDuplicateRequest: Function; @@ -33,6 +34,19 @@ export const WebSocketRequestActionsDropdown = forwardRef handleDuplicateRequest(request); }, [handleDuplicateRequest, request]); + const handleRename = useCallback(() => { + showPrompt({ + title: 'Rename Request', + defaultValue: request.name, + submitName: 'Rename', + selectText: true, + label: 'Name', + onComplete: name => { + requestOperations.update(request, { name }); + }, + }); + }, [request]); + const togglePin = useCallback(() => { updateRequestMetaByParentId(request._id, { pinned: !isPinned }); }, [isPinned, request]); @@ -58,6 +72,13 @@ export const WebSocketRequestActionsDropdown = forwardRef + + Rename + +