mockaton 10.6.3 → 10.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Dashboard.js +10 -6
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "10.6.3",
5
+ "version": "10.6.4",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Dashboard.js CHANGED
@@ -85,6 +85,9 @@ const state = /** @type {State} */ {
85
85
  chosenLink: { method: '', urlMask: '' },
86
86
  setChosenLink(method, urlMask) {
87
87
  state.chosenLink = { method, urlMask }
88
+ },
89
+ get hasChosenLink() {
90
+ return state.chosenLink.method && state.chosenLink.urlMask
88
91
  }
89
92
  }
90
93
 
@@ -107,10 +110,8 @@ async function updateState() {
107
110
  if (focusedElem)
108
111
  document.querySelector(focusedElem)?.focus()
109
112
 
110
- const { method, urlMask } = state.chosenLink
111
- if (method && urlMask)
112
- await previewMock(method, urlMask)
113
-
113
+ if (state.hasChosenLink)
114
+ await previewMock(state.chosenLink.method, state.chosenLink.urlMask)
114
115
  }
115
116
  catch (error) {
116
117
  onError(error)
@@ -710,11 +711,14 @@ const payloadViewerTitleRef = useRef()
710
711
  const payloadViewerCodeRef = useRef()
711
712
 
712
713
  function PayloadViewer() {
714
+ const { hasChosenLink } = state
713
715
  return (
714
716
  r('div', className(CSS.PayloadViewer),
715
- r('h2', { ref: payloadViewerTitleRef }, t`Preview`),
717
+ r('h2', { ref: payloadViewerTitleRef },
718
+ !hasChosenLink && t`Preview`),
716
719
  r('pre', null,
717
- r('code', { ref: payloadViewerCodeRef }, t`Click a link to preview it`))))
720
+ r('code', { ref: payloadViewerCodeRef },
721
+ !hasChosenLink && t`Click a link to preview it`))))
718
722
  }
719
723
 
720
724
  function PayloadViewerTitle({ file, statusText }) {