From ef840cd5160c7899808fc39f39862e1062720487 Mon Sep 17 00:00:00 2001 From: Dimitri Mitropoulos Date: Thu, 1 Jul 2021 15:52:35 -0400 Subject: [PATCH] hotfix - INS-782 --- .../app/ui/redux/modules/global.tsx | 40 ++++++++++++------- packages/insomnia-app/package-lock.json | 13 ++++++ packages/insomnia-app/package.json | 1 + 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/insomnia-app/app/ui/redux/modules/global.tsx b/packages/insomnia-app/app/ui/redux/modules/global.tsx index 98abde49d..6d4c1cd1f 100644 --- a/packages/insomnia-app/app/ui/redux/modules/global.tsx +++ b/packages/insomnia-app/app/ui/redux/modules/global.tsx @@ -43,6 +43,7 @@ import { Settings } from '../../../models/settings'; import { GrpcRequest } from '../../../models/grpc-request'; import { Request } from '../../../models/request'; import { Environment } from '../../../models/environment'; +import { unreachableCase } from 'ts-assert-unreachable'; export const LOCALSTORAGE_PREFIX = 'insomnia::meta'; const LOGIN_STATE_CHANGE = 'global/login-state-change'; @@ -489,24 +490,27 @@ export const importUri = ( }; function showSelectExportTypeModal(onCancel: () => void, onDone: (selectedFormat: SelectedFormat) => void) { + const options = [ + { + name: 'Insomnia v4 (JSON)', + value: VALUE_JSON, + }, + { + name: 'Insomnia v4 (YAML)', + value: VALUE_YAML, + }, + { + name: 'HAR – HTTP Archive Format', + value: VALUE_HAR, + }, + ]; const lastFormat = window.localStorage.getItem('insomnia.lastExportFormat'); + const defaultValue = options.map(({ value }) => value).includes(lastFormat) ? lastFormat : VALUE_JSON; + showModal(SelectModal, { title: 'Select Export Type', - value: lastFormat, - options: [ - { - name: 'Insomnia v4 (JSON)', - value: VALUE_JSON, - }, - { - name: 'Insomnia v4 (YAML)', - value: VALUE_YAML, - }, - { - name: 'HAR – HTTP Archive Format', - value: VALUE_HAR, - }, - ], + value: defaultValue, + options, message: 'Which format would you like to export as?', onCancel, onDone: (selectedFormat: SelectedFormat) => { @@ -599,6 +603,9 @@ export const exportWorkspacesToFile = (workspaceId: string | undefined = undefin 'json', ); break; + + default: + unreachableCase(`selected export format "${selectedFormat}" is invalid`); } } catch (err) { showError({ @@ -698,6 +705,9 @@ export const exportRequestsToFile = (requestIds: string[]) => async dispatch => 'json', ); break; + + default: + unreachableCase(`selected export format "${selectedFormat}" is invalid`); } } catch (err) { showError({ diff --git a/packages/insomnia-app/package-lock.json b/packages/insomnia-app/package-lock.json index 6dc750ecb..1ac94b2c7 100644 --- a/packages/insomnia-app/package-lock.json +++ b/packages/insomnia-app/package-lock.json @@ -24462,6 +24462,14 @@ "utf8-byte-length": "^1.0.1" } }, + "ts-assert-unreachable": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/ts-assert-unreachable/-/ts-assert-unreachable-0.0.9.tgz", + "integrity": "sha512-8tpQLahyZSNTSxKS8QPIO0AAxF8VB02tLPNqcMF638gNDOrhr8uGx9SFP1C/Vtbib2Xc/u12hiXnwmqD7pn+2A==", + "requires": { + "ts-tiny-invariant": "0.0.3" + } + }, "ts-dedent": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-1.1.1.tgz", @@ -24587,6 +24595,11 @@ "integrity": "sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==", "dev": true }, + "ts-tiny-invariant": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/ts-tiny-invariant/-/ts-tiny-invariant-0.0.3.tgz", + "integrity": "sha512-EiaBUsUta7PPzVKpvZurcSDgaSkymxwiUc2rhX6Wu30bws2maipT6ihbEY072dU9lz6/FoFWEc6psXdlo0xqtg==" + }, "tsconfig-paths": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", diff --git a/packages/insomnia-app/package.json b/packages/insomnia-app/package.json index ececd49ef..ce045a986 100644 --- a/packages/insomnia-app/package.json +++ b/packages/insomnia-app/package.json @@ -154,6 +154,7 @@ "styled-components": "^4.4.1", "swagger-ui-react": "^3.24.3", "tough-cookie": "^2.3.1", + "ts-assert-unreachable": "^0.0.9", "url-join": "^4.0.1", "uuid": "^3.0.0", "vkbeautify": "^0.99.1",