From a79cef9cc647fe1d491bb1a6ac06267414c85fca Mon Sep 17 00:00:00 2001 From: bpoulaindev Date: Wed, 28 Feb 2024 16:53:41 +0100 Subject: [PATCH] feature(postman_tests_scripts): reinstore css vars, add try catch to postmanTranslation function --- packages/bruno-app/src/styles/globals.css | 138 +++++++++--------- .../translators/postman_translation.js | 27 ++-- 2 files changed, 81 insertions(+), 84 deletions(-) diff --git a/packages/bruno-app/src/styles/globals.css b/packages/bruno-app/src/styles/globals.css index 0b46ea13c8..29e9196ea4 100644 --- a/packages/bruno-app/src/styles/globals.css +++ b/packages/bruno-app/src/styles/globals.css @@ -1,76 +1,68 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 240 10% 3.9%; +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; - --card: 0 0% 100%; - --card-foreground: 240 10% 3.9%; - - --popover: 0 0% 100%; - --popover-foreground: 240 10% 3.9%; - - --primary: 240 5.9% 10%; - --primary-foreground: 0 0% 98%; - - --secondary: 240 4.8% 95.9%; - --secondary-foreground: 240 5.9% 10%; - - --muted: 240 4.8% 95.9%; - --muted-foreground: 240 3.8% 46.1%; - - --accent: 240 4.8% 95.9%; - --accent-foreground: 240 5.9% 10%; - - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 0 0% 98%; +:root { + --color-brand: #546de5; + --color-text: rgb(52 52 52); + --color-sidebar-collection-item-active-indent-border: #d0d0d0; + --color-sidebar-background: #f3f3f3; + --color-request-dragbar-background: #efefef; + --color-request-dragbar-background-active: rgb(200, 200, 200); + --color-tab-inactive: rgb(155 155 155); + --color-tab-active-border: #546de5; + --color-layout-border: #dedede; + --color-text-link: #1663bb; + --color-text-danger: rgb(185, 28, 28); + --color-background-danger: #dc3545; + --color-method-get: rgb(5, 150, 105); + --color-method-post: #8e44ad; + --color-method-put: #ca7811; + --color-method-delete: rgb(185, 28, 28); + --color-method-patch: rgb(52 52 52); + --color-method-options: rgb(52 52 52); + --color-method-head: rgb(52 52 52); +} + +html, +body { + margin: 0; + padding: 0; + font-size: 1rem; + color: rgb(52 52 52); + + font-kerning: none; + text-rendering: optimizeSpeed; + letter-spacing: normal; + font-family: Inter, sans-serif !important; + overflow-x: hidden; +} + +body { + font-size: 0.875rem; +} - --border: 240 5.9% 90%; - --input: 240 5.9% 90%; - --ring: 240 10% 3.9%; - - --radius: 0.5rem; - } - - .dark { - --background: 240 10% 3.9%; - --foreground: 0 0% 98%; - - --card: 240 10% 3.9%; - --card-foreground: 0 0% 98%; - - --popover: 240 10% 3.9%; - --popover-foreground: 0 0% 98%; - - --primary: 0 0% 98%; - --primary-foreground: 240 5.9% 10%; - - --secondary: 240 3.7% 15.9%; - --secondary-foreground: 0 0% 98%; - - --muted: 240 3.7% 15.9%; - --muted-foreground: 240 5% 64.9%; - - --accent: 240 3.7% 15.9%; - --accent-foreground: 0 0% 98%; - - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 0 0% 98%; - - --border: 240 3.7% 15.9%; - --input: 240 3.7% 15.9%; - --ring: 240 4.9% 83.9%; - } +body::-webkit-scrollbar, +.CodeMirror-vscrollbar::-webkit-scrollbar { + width: 0.6rem; } - -@layer base { - * { - @apply border-border; - } - body { - @apply bg-background text-foreground; - } -} \ No newline at end of file + +body::-webkit-scrollbar-track, +.CodeMirror-vscrollbar::-webkit-scrollbar-track { + background-color: #f1f1f1; +} + +body::-webkit-scrollbar-thumb, +.CodeMirror-vscrollbar::-webkit-scrollbar-thumb { + background-color: #cdcdcd; + border-radius: 5rem; +} + +/* + * todo: this will be supported in the future to be changed via applying a theme + * making all the checkboxes and radios bigger + * input[type='checkbox'], + * input[type='radio'] { + * transform: scale(1.1); + * } + */ diff --git a/packages/bruno-app/src/utils/importers/translators/postman_translation.js b/packages/bruno-app/src/utils/importers/translators/postman_translation.js index 27db7d77a8..8d53d72e8e 100644 --- a/packages/bruno-app/src/utils/importers/translators/postman_translation.js +++ b/packages/bruno-app/src/utils/importers/translators/postman_translation.js @@ -6,17 +6,22 @@ const replacements = { }; export const postmanTranslation = (script) => { - const modifiedScript = Object.entries(replacements) - .map(([pattern, replacement]) => { - const regex = new RegExp(pattern, 'g'); - return script.replace(regex, replacement); - }) - .find((modified) => modified !== script); - if (modifiedScript) { - // translation successful - return modifiedScript; - } else { + try { + const modifiedScript = Object.entries(replacements || {}) + .map(([pattern, replacement]) => { + const regex = new RegExp(pattern, 'g'); + return script?.replace(regex, replacement); + }) + .find((modified) => modified !== script); + if (modifiedScript) { + // translation successful + return modifiedScript; + } else { + // non-translatable script + return script?.includes('pm.') ? `// ${script}` : script; + } + } catch (e) { // non-translatable script - return script.includes('pm.') ? `// ${script}` : script; + return script?.includes('pm.') ? `// ${script}` : script; } };