mockaton 10.3.6 → 10.3.7

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.
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.3.6",
5
+ "version": "10.3.7",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Dashboard.css CHANGED
@@ -43,7 +43,7 @@
43
43
  --colorComboBoxBackground: #2a2a2a;
44
44
  --colorSecondaryButtonBackground: #2a2a2a;
45
45
  --colorSecondaryActionBorder: #333;
46
- --colorSecondaryAction: #999;
46
+ --colorSecondaryAction: #aaa;
47
47
  --colorComboBoxHeaderBackground: #222;
48
48
  --colorDisabledMockSelector: #b9b9b9;
49
49
  --colorHover: #023661;
@@ -168,7 +168,7 @@ header {
168
168
  width: 100px;
169
169
  align-self: center;
170
170
  }
171
-
171
+
172
172
  > div {
173
173
  width: 400px;
174
174
  .MenuTrigger {
@@ -347,7 +347,6 @@ main {
347
347
  .leftSide {
348
348
  width: 50%;
349
349
  padding: 16px;
350
- padding-bottom: 0;
351
350
  border-right: 1px solid var(--colorSecondaryActionBorder);
352
351
  user-select: none;
353
352
  overflow-y: auto;
@@ -383,11 +382,12 @@ table {
383
382
  th {
384
383
  padding-bottom: 2px;
385
384
  padding-left: 4px;
385
+ border-top: 20px solid transparent;
386
386
  text-align: left;
387
387
  }
388
-
389
- tbody {
390
- border-bottom: 20px solid transparent;
388
+
389
+ > tr:first-child > th {
390
+ border-top: 0;
391
391
  }
392
392
  }
393
393
 
@@ -395,12 +395,19 @@ table {
395
395
  margin-top: 80px;
396
396
  }
397
397
 
398
+ .Method {
399
+ padding-right: 8px;
400
+ color: var(--colorSecondaryAction);
401
+ text-align: center;
402
+ font-size: 11px;
403
+ }
398
404
 
399
405
  .PreviewLink {
400
406
  position: relative;
401
407
  left: -8px;
402
408
  display: inline-block;
403
409
  width: 100%;
410
+ min-width: 140px;
404
411
  padding: 6px 8px;
405
412
  margin-left: 4px;
406
413
  border-radius: var(--radius);
@@ -581,14 +588,12 @@ table {
581
588
  }
582
589
 
583
590
 
584
- .StaticFilesList {
585
- a {
586
- display: inline-block;
587
- padding: 6px 0;
588
- margin-left: 4px;
589
- border-radius: var(--radius);
590
- color: var(--colorAccent);
591
- }
591
+ .StaticFileLink {
592
+ display: inline-block;
593
+ padding: 6px 0;
594
+ margin-left: 4px;
595
+ border-radius: var(--radius);
596
+ color: var(--colorAccent);
592
597
  }
593
598
 
594
599
 
package/src/Dashboard.js CHANGED
@@ -46,6 +46,7 @@ const CSS = {
46
46
  GroupByMethod: null,
47
47
  InternalServerErrorToggler: null,
48
48
  MenuTrigger: null,
49
+ Method: null,
49
50
  MockList: null,
50
51
  MockSelector: null,
51
52
  NotFoundToggler: null,
@@ -57,7 +58,7 @@ const CSS = {
57
58
  Resizer: null,
58
59
  SaveProxiedCheckbox: null,
59
60
  SettingsMenu: null,
60
- StaticFilesList: null,
61
+ StaticFileLink: null,
61
62
 
62
63
  chosen: null,
63
64
  dittoDir: null,
@@ -142,8 +143,9 @@ function App() {
142
143
  style: { width: leftSideWidth + 'px' },
143
144
  className: CSS.leftSide
144
145
  },
145
- MockList(),
146
- StaticFilesList()),
146
+ r('table', null,
147
+ MockList(),
148
+ StaticFilesList())),
147
149
  r('div', { className: CSS.rightSide },
148
150
  Resizer(),
149
151
  PayloadViewer()))
@@ -363,28 +365,24 @@ function MockList() {
363
365
  Strings.no_mocks_found))
364
366
 
365
367
  if (groupByMethod)
366
- return (
367
- r('div', null,
368
- r('table', null, Object.keys(brokersByMethod).map(method =>
369
- r('tbody', null,
370
- r('tr', null,
371
- r('th', { colspan: 2 + Number(canProxy) }),
372
- r('th', null, method)),
373
- rowsFor(method).map(Row))))))
368
+ return Object.keys(brokersByMethod).map((method) => Fragment(
369
+ r('tr', null,
370
+ r('th', { colspan: 2 + Number(canProxy) }),
371
+ r('th', null, method)),
372
+ rowsFor(method).map(Row)))
374
373
 
375
- return (
376
- r('div', null,
377
- r('table', null,
378
- r('tbody', null, rowsFor('*').map(Row)))))
374
+ return rowsFor('*').map(Row)
379
375
  }
380
376
 
377
+
381
378
  function Row({ method, urlMask, urlMaskDittoed, broker }) {
382
- const { canProxy } = state
379
+ const { canProxy, groupByMethod } = state
383
380
  return (
384
381
  r('tr', { 'data-method': method, 'data-urlMask': urlMask },
385
382
  canProxy && r('td', null, ProxyToggler(broker)),
386
383
  r('td', null, DelayRouteToggler(broker)),
387
384
  r('td', null, InternalServerErrorToggler(broker)),
385
+ !groupByMethod && r('td', className(CSS.Method), method),
388
386
  r('td', null, PreviewLink(method, urlMask, urlMaskDittoed)),
389
387
  r('td', null, MockSelector(broker))))
390
388
  }
@@ -434,8 +432,6 @@ function PreviewLink(method, urlMask, urlMaskDittoed) {
434
432
 
435
433
  /** @param {ClientMockBroker} broker */
436
434
  function MockSelector(broker) {
437
- const { groupByMethod } = state
438
-
439
435
  function onChange() {
440
436
  const { urlMask, method } = parseFilename(this.value)
441
437
  mockaton.select(this.value)
@@ -462,7 +458,6 @@ function MockSelector(broker) {
462
458
  const comments = extractComments(file)
463
459
  const isAutogen500 = comments.includes(AUTOGENERATED_500_COMMENT)
464
460
  return [
465
- groupByMethod ? '' : method,
466
461
  isAutogen500 ? '' : status,
467
462
  ext === 'empty' || ext === 'unknown' ? '' : ext,
468
463
  isAutogen500 ? Strings.auto500 : comments.join(' ')
@@ -553,26 +548,29 @@ function ProxyToggler(broker) {
553
548
  /** # StaticFilesList */
554
549
 
555
550
  function StaticFilesList() {
556
- const { staticBrokers, canProxy } = state
551
+ const { staticBrokers, canProxy, groupByMethod } = state
557
552
  if (!Object.keys(staticBrokers).length)
558
553
  return null
559
554
  const dp = dittoSplitPaths(Object.keys(staticBrokers)).map(([ditto, tail]) => ditto
560
555
  ? [r('span', className(CSS.dittoDir), ditto), tail]
561
556
  : tail)
562
557
  return (
563
- r('table', className(CSS.StaticFilesList),
564
- r('thead', null,
558
+ Fragment(
559
+ r('tr', null,
560
+ r('th', { colspan: (2 + Number(!groupByMethod)) + Number(canProxy) }),
561
+ r('th', null, Strings.static_get)),
562
+ Object.values(staticBrokers).map((broker, i) =>
565
563
  r('tr', null,
566
- r('th', { colspan: 2 + Number(canProxy) }),
567
- r('th', null, Strings.static_get))),
568
- r('tbody', null,
569
- Object.values(staticBrokers).map((broker, i) =>
570
- r('tr', null,
571
- canProxy && r('td', null, ProxyStaticToggler()),
572
- r('td', null, DelayStaticRouteToggler(broker)),
573
- r('td', null, NotFoundToggler(broker)),
574
- r('td', null, r('a', { href: broker.route, target: '_blank' }, dp[i]))
575
- )))))
564
+ canProxy && r('td', null, ProxyStaticToggler()),
565
+ r('td', null, DelayStaticRouteToggler(broker)),
566
+ r('td', null, NotFoundToggler(broker)),
567
+ !groupByMethod && r('td', className(CSS.Method), 'GET'),
568
+ r('td', null, r('a', {
569
+ href: broker.route,
570
+ target: '_blank',
571
+ className: CSS.StaticFileLink
572
+ }, dp[i]))
573
+ ))))
576
574
  }
577
575
 
578
576
  /** @param {ClientStaticBroker} broker */
@@ -934,6 +932,16 @@ function useRef() {
934
932
  return { current: null }
935
933
  }
936
934
 
935
+ function Fragment(...args) {
936
+ const frag = new DocumentFragment()
937
+ for (const arg of args)
938
+ if (Array.isArray(arg))
939
+ frag.append(...arg)
940
+ else
941
+ frag.appendChild(arg)
942
+ return frag
943
+ }
944
+
937
945
 
938
946
  /**
939
947
  * Think of this as a way of printing a directory tree in which
@@ -994,7 +1002,7 @@ function dittoSplitPaths(paths) {
994
1002
  function syntaxJSON(json) {
995
1003
  const MAX_NODES = 50_000
996
1004
  let nNodes = 0
997
- const frag = document.createDocumentFragment()
1005
+ const frag = new DocumentFragment()
998
1006
 
999
1007
  function span(className, textContent) {
1000
1008
  nNodes++
@@ -1042,7 +1050,7 @@ syntaxJSON.regex = /("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|([{}\[\],:\s
1042
1050
  function syntaxXML(xml) {
1043
1051
  const MAX_NODES = 50_000
1044
1052
  let nNodes = 0
1045
- const frag = document.createDocumentFragment()
1053
+ const frag = new DocumentFragment()
1046
1054
 
1047
1055
  function span(className, textContent) {
1048
1056
  nNodes++