icex-dsh-fixer 0.2.5 → 0.2.6
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/client.js +73 -0
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -777,6 +777,10 @@ window.__ModuleLoader__.load({
|
|
|
777
777
|
'rail.jump': 'Jump to input {index}: {prompt}',
|
|
778
778
|
'rail.input': 'Input {index}',
|
|
779
779
|
'rail.fallback': 'Turn {turn}',
|
|
780
|
+
'menu.deleteSession': 'Delete session',
|
|
781
|
+
'menu.deleting': 'Deleting…',
|
|
782
|
+
'menu.deleteConfirm': 'Delete this session? Its log moves to the trash folder.',
|
|
783
|
+
'menu.deleteFailed': 'Delete failed: {message}',
|
|
780
784
|
}
|
|
781
785
|
|
|
782
786
|
const zh = {
|
|
@@ -798,6 +802,10 @@ window.__ModuleLoader__.load({
|
|
|
798
802
|
'rail.label': '输入锚点',
|
|
799
803
|
'rail.jump': '跳转到第 {index} 条输入:{prompt}',
|
|
800
804
|
'rail.input': '第 {index} 条输入',
|
|
805
|
+
'menu.deleteSession': '删除会话',
|
|
806
|
+
'menu.deleting': '删除中…',
|
|
807
|
+
'menu.deleteConfirm': '删除这个会话?日志会移到回收站目录,可以再捞回来。',
|
|
808
|
+
'menu.deleteFailed': '删除失败:{message}',
|
|
801
809
|
'rail.fallback': '第 {turn} 轮',
|
|
802
810
|
}
|
|
803
811
|
|
|
@@ -867,6 +875,63 @@ window.__ModuleLoader__.load({
|
|
|
867
875
|
)
|
|
868
876
|
}
|
|
869
877
|
|
|
878
|
+
/**
|
|
879
|
+
* Session row menu item: delete one session by moving its log to the trash.
|
|
880
|
+
* The slot hands over the session id (as a string or a props object).
|
|
881
|
+
*/
|
|
882
|
+
function DeleteSessionItem(props) {
|
|
883
|
+
const t = translator(props !== null && typeof props === 'object' ? props.t : undefined)
|
|
884
|
+
const sessionId = typeof props === 'string'
|
|
885
|
+
? props
|
|
886
|
+
: props !== null && typeof props === 'object'
|
|
887
|
+
? props.sessionId ?? props.id ?? props.value
|
|
888
|
+
: undefined
|
|
889
|
+
const busyState = useState(false)
|
|
890
|
+
const busy = busyState[0]
|
|
891
|
+
if (typeof sessionId !== 'string' || sessionId === '') return null
|
|
892
|
+
|
|
893
|
+
function remove() {
|
|
894
|
+
if (typeof window === 'undefined') return
|
|
895
|
+
if (window.confirm(t('menu.deleteConfirm')) !== true) return
|
|
896
|
+
busyState[1](true)
|
|
897
|
+
fetch('/api/icex-fixer/delete-session', {
|
|
898
|
+
method: 'POST',
|
|
899
|
+
credentials: 'same-origin',
|
|
900
|
+
headers: { 'content-type': 'application/json' },
|
|
901
|
+
body: JSON.stringify({ id: sessionId }),
|
|
902
|
+
}).then(function (response) {
|
|
903
|
+
return response.json().then(function (body) {
|
|
904
|
+
if (body.ok !== true) throw new Error(body.error ?? String(response.status))
|
|
905
|
+
window.location.reload()
|
|
906
|
+
})
|
|
907
|
+
}).catch(function (error) {
|
|
908
|
+
busyState[1](false)
|
|
909
|
+
window.alert(t('menu.deleteFailed', { message: String(error.message ?? error) }))
|
|
910
|
+
})
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
return h('button', {
|
|
914
|
+
type: 'button',
|
|
915
|
+
role: 'menuitem',
|
|
916
|
+
disabled: busy,
|
|
917
|
+
className: 'icex-menu-danger',
|
|
918
|
+
style: {
|
|
919
|
+
display: 'block',
|
|
920
|
+
width: '100%',
|
|
921
|
+
padding: '6px 10px',
|
|
922
|
+
border: 0,
|
|
923
|
+
borderRadius: 'var(--dsw-radius-sm, 6px)',
|
|
924
|
+
background: 'transparent',
|
|
925
|
+
color: 'var(--dsw-alias-state-error-primary)',
|
|
926
|
+
textAlign: 'left',
|
|
927
|
+
font: 'inherit',
|
|
928
|
+
cursor: busy ? 'default' : 'pointer',
|
|
929
|
+
opacity: busy ? 0.6 : 1,
|
|
930
|
+
},
|
|
931
|
+
onClick: remove,
|
|
932
|
+
}, busy ? t('menu.deleting') : t('menu.deleteSession'))
|
|
933
|
+
}
|
|
934
|
+
|
|
870
935
|
function apply(ctx) {
|
|
871
936
|
runtimeContext = ctx
|
|
872
937
|
ctx.effect(installStyles, 'icex-dsh-fixer: styles')
|
|
@@ -899,6 +964,14 @@ window.__ModuleLoader__.load({
|
|
|
899
964
|
locale: NS,
|
|
900
965
|
}, SettingsPage)
|
|
901
966
|
})
|
|
967
|
+
ctx.slots.inject('sidebar.workspaces.session.menu.item', function () {
|
|
968
|
+
return ctx.slots.register({
|
|
969
|
+
name: 'sidebar.workspaces.session.menu.item',
|
|
970
|
+
id: 'icex-fixer-delete-session',
|
|
971
|
+
order: 900,
|
|
972
|
+
locale: NS,
|
|
973
|
+
}, DeleteSessionItem)
|
|
974
|
+
})
|
|
902
975
|
}
|
|
903
976
|
|
|
904
977
|
const plugin = {
|
package/package.json
CHANGED