dazscript-framework 1.0.24 → 1.0.25

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -12,7 +12,7 @@ import { TreeNode } from '@dsf/lib/tree-node'
12
12
  import { promptKeyboardShortcut } from '@dsf/shared/set-keyboard-shortcut'
13
13
  import { readFromFile, saveToFile } from './file-helper'
14
14
  import { getCanonicalInstallerEntry, toActionKey } from './custom-action-installer-entries'
15
- import { canResetSetupShortcut, getDisplayedSetupShortcut, resetSetupShortcut, setSetupShortcut, updateShortcutOverrideState } from './custom-action-installer-shortcuts'
15
+ import { canResetSetupShortcut, getDisplayedSetupShortcut, resetSetupShortcut, resetSetupShortcuts, setSetupShortcut, updateShortcutOverrideState } from './custom-action-installer-shortcuts'
16
16
  import { getScriptPath } from './script-helper'
17
17
 
18
18
  type InstallerEntry = {
@@ -397,6 +397,7 @@ class InstallerSelectionDialog extends BasicDialog {
397
397
  debug(`[Setup] context menu row resolved item="${this.safeListItemText(contextItem, 1)}" entry="${entry?.action?.text ?? ''}"`)
398
398
  const canSetShortcut = Boolean(entry)
399
399
  const canResetShortcut = Boolean(entry && canResetSetupShortcut(entry))
400
+ const canResetAllShortcuts = this.entries.some(canResetSetupShortcut)
400
401
 
401
402
  const items = [
402
403
  {
@@ -413,6 +414,10 @@ class InstallerSelectionDialog extends BasicDialog {
413
414
  this.resetDefaultShortcut(entry)
414
415
  }
415
416
  },
417
+ {
418
+ text: 'Reset All Shortcuts to Defaults',
419
+ activated: () => this.resetAllDefaultShortcuts()
420
+ },
416
421
  {},
417
422
  { text: 'Check All', activated: () => this.checkVisible(listView, true) },
418
423
  { text: 'Uncheck All', activated: () => this.checkVisible(listView, false) }
@@ -421,6 +426,7 @@ class InstallerSelectionDialog extends BasicDialog {
421
426
  return new PopupMenuBuilder(this.builder.context).items(...items).build((menu) => {
422
427
  menu.setItemEnabled(0, canSetShortcut)
423
428
  menu.setItemEnabled(1, canResetShortcut)
429
+ menu.setItemEnabled(2, canResetAllShortcuts)
424
430
  })
425
431
  }
426
432
 
@@ -498,6 +504,15 @@ class InstallerSelectionDialog extends BasicDialog {
498
504
  this.refreshListEvent$.trigger()
499
505
  }
500
506
 
507
+ private resetAllDefaultShortcuts() {
508
+ const resettableEntries = this.entries.filter(canResetSetupShortcut)
509
+ if (resettableEntries.length === 0) return
510
+
511
+ resetSetupShortcuts(resettableEntries)
512
+ debug(`[Setup] reset ${resettableEntries.length} shortcuts to defaults`)
513
+ this.refreshListEvent$.trigger()
514
+ }
515
+
501
516
  private checkVisible(listView: DzListView, onOff: boolean) {
502
517
  if (!this.keywords$.value?.trim()) {
503
518
  checkAll(listView, onOff)
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
2
2
  import {
3
3
  canResetSetupShortcut,
4
4
  getDisplayedSetupShortcut,
5
+ resetSetupShortcuts,
5
6
  resetSetupShortcut,
6
7
  setSetupShortcut,
7
8
  updateShortcutOverrideState
@@ -80,6 +81,29 @@ describe('setup shortcut state', () => {
80
81
  expect(canResetSetupShortcut(entry)).toBe(false)
81
82
  })
82
83
 
84
+ it('resets all shortcut entries to their defaults', () => {
85
+ const installed = shortcutState({
86
+ installedActionName: 'installed-guid',
87
+ defaultShortcut: 'Ctrl+P',
88
+ installedShortcut: 'F12',
89
+ effectiveShortcut: 'F12',
90
+ isShortcutOverridden: true
91
+ })
92
+ const pending = shortcutState({
93
+ defaultShortcut: '',
94
+ effectiveShortcut: 'Ctrl+Alt+K'
95
+ })
96
+
97
+ resetSetupShortcuts([installed, pending])
98
+
99
+ expect(installed.installedShortcut).toBe('Ctrl+P')
100
+ expect(installed.effectiveShortcut).toBe('Ctrl+P')
101
+ expect(installed.isShortcutOverridden).toBe(false)
102
+ expect(pending.installedShortcut).toBe('')
103
+ expect(pending.effectiveShortcut).toBe('')
104
+ expect(pending.isShortcutOverridden).toBe(false)
105
+ })
106
+
83
107
  it('displays custom marker when installed shortcut was changed outside setup', () => {
84
108
  const entry = shortcutState({
85
109
  installedActionName: 'installed-guid',
@@ -47,3 +47,7 @@ export const resetSetupShortcut = (entry: InstallerShortcutState): void => {
47
47
  entry.effectiveShortcut = defaultShortcut
48
48
  updateShortcutOverrideState(entry)
49
49
  }
50
+
51
+ export const resetSetupShortcuts = (entries: InstallerShortcutState[]): void => {
52
+ entries.forEach(resetSetupShortcut)
53
+ }