@xen-orchestra/web-core 0.48.2 → 0.49.0
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/lib/assets/creating.svg +566 -0
- package/lib/components/operation-card/VtsOperationCard.vue +51 -0
- package/lib/components/operation-error-card/VtsOperationErrorCard.vue +38 -0
- package/lib/components/operation-pending-card/VtsOperationPendingCard.vue +23 -0
- package/lib/components/state-hero/VtsStateHero.vue +1 -0
- package/lib/locales/cs.json +2 -3
- package/lib/locales/de.json +2 -3
- package/lib/locales/en.json +26 -4
- package/lib/locales/es.json +2 -3
- package/lib/locales/fr.json +26 -4
- package/lib/locales/nl.json +2 -3
- package/lib/locales/pt-BR.json +2 -3
- package/lib/locales/pt.json +2 -3
- package/lib/locales/sv.json +2 -3
- package/lib/locales/zh-Hans.json +2 -3
- package/lib/packages/form-bindings/README.md +102 -0
- package/lib/packages/form-bindings/index.ts +1 -0
- package/lib/packages/form-bindings/use-form-bindings.ts +61 -0
- package/lib/packages/remote-resource/define-remote-resource.ts +6 -1
- package/lib/packages/remote-resource/sse.store.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FormSelectId } from '@core/packages/form-select'
|
|
2
|
+
import { computed, type ComputedRef } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type ModelBinding<T> = {
|
|
5
|
+
modelValue: T
|
|
6
|
+
'onUpdate:modelValue': (value: T) => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type UseFormBindingsReturn<T extends Record<string, unknown>> = {
|
|
10
|
+
useField: {
|
|
11
|
+
<K extends keyof T>(key: K): ComputedRef<ModelBinding<T[K]>>
|
|
12
|
+
<K extends keyof T, E extends Record<string, unknown>>(
|
|
13
|
+
key: K,
|
|
14
|
+
metadata: () => E
|
|
15
|
+
): ComputedRef<ModelBinding<T[K]> & E>
|
|
16
|
+
}
|
|
17
|
+
useSelect: {
|
|
18
|
+
(id: FormSelectId): ComputedRef<{ id: FormSelectId }>
|
|
19
|
+
<E extends Record<string, unknown>>(id: FormSelectId, metadata: () => E): ComputedRef<{ id: FormSelectId } & E>
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useFormBindings<T extends Record<string, unknown>>(source: T): UseFormBindingsReturn<T> {
|
|
24
|
+
function useField<K extends keyof T>(key: K): ComputedRef<ModelBinding<T[K]>>
|
|
25
|
+
function useField<K extends keyof T, E extends Record<string, unknown>>(
|
|
26
|
+
key: K,
|
|
27
|
+
metadata: () => E
|
|
28
|
+
): ComputedRef<ModelBinding<T[K]> & E>
|
|
29
|
+
function useField<K extends keyof T, E extends Record<string, unknown> = Record<string, unknown>>(
|
|
30
|
+
key: K,
|
|
31
|
+
metadata?: () => E
|
|
32
|
+
) {
|
|
33
|
+
return computed(() => ({
|
|
34
|
+
modelValue: source[key],
|
|
35
|
+
'onUpdate:modelValue': (value: T[K]) => {
|
|
36
|
+
source[key] = value
|
|
37
|
+
},
|
|
38
|
+
...metadata?.(),
|
|
39
|
+
}))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function useSelect(id: FormSelectId): ComputedRef<{ id: FormSelectId }>
|
|
43
|
+
function useSelect<E extends Record<string, unknown>>(
|
|
44
|
+
id: FormSelectId,
|
|
45
|
+
metadata: () => E
|
|
46
|
+
): ComputedRef<{ id: FormSelectId } & E>
|
|
47
|
+
function useSelect<E extends Record<string, unknown> = Record<string, unknown>>(
|
|
48
|
+
id: FormSelectId,
|
|
49
|
+
metadata?: () => E
|
|
50
|
+
) {
|
|
51
|
+
return computed(() => ({
|
|
52
|
+
id,
|
|
53
|
+
...metadata?.(),
|
|
54
|
+
}))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
useField,
|
|
59
|
+
useSelect,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
toRef,
|
|
26
26
|
toValue,
|
|
27
27
|
watch,
|
|
28
|
+
effectScope,
|
|
28
29
|
} from 'vue'
|
|
29
30
|
|
|
30
31
|
const DEFAULT_CACHE_EXPIRATION_MS = 10_000
|
|
@@ -106,6 +107,7 @@ export function defineRemoteResource<
|
|
|
106
107
|
pause: VoidFunction
|
|
107
108
|
resume: VoidFunction
|
|
108
109
|
state: object
|
|
110
|
+
stateScope: EffectScope
|
|
109
111
|
isReady: Ref<boolean>
|
|
110
112
|
isFetching: Ref<boolean>
|
|
111
113
|
lastError: Ref<Error | undefined>
|
|
@@ -239,6 +241,7 @@ export function defineRemoteResource<
|
|
|
239
241
|
|
|
240
242
|
if (cacheExpiration !== false) {
|
|
241
243
|
setTimeout(() => {
|
|
244
|
+
cache.get(url)?.stateScope.stop()
|
|
242
245
|
cache.delete(url)
|
|
243
246
|
}, cacheExpiration)
|
|
244
247
|
}
|
|
@@ -340,13 +343,15 @@ export function defineRemoteResource<
|
|
|
340
343
|
resume = timeoutPoll.resume
|
|
341
344
|
}
|
|
342
345
|
|
|
343
|
-
const
|
|
346
|
+
const stateScope = effectScope(true)
|
|
347
|
+
const state = stateScope.run(() => buildState(data, context))!
|
|
344
348
|
|
|
345
349
|
cache.set(url, {
|
|
346
350
|
count: 0,
|
|
347
351
|
pause,
|
|
348
352
|
resume,
|
|
349
353
|
state,
|
|
354
|
+
stateScope,
|
|
350
355
|
isReady,
|
|
351
356
|
isFetching,
|
|
352
357
|
lastError,
|
|
@@ -49,7 +49,7 @@ export const useSseStore = defineStore('sse', () => {
|
|
|
49
49
|
return false
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
return now.value.getTime() - sse.value.lastPing >
|
|
52
|
+
return now.value.getTime() - sse.value.lastPing > 40_000
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
const hasErrorSse = computed(() => isError.value || sse.value.errorSse !== null)
|