@revenexx/integrations-node-devkit 0.5.0 → 0.5.1
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 +1 -1
- package/preview-host/pages/nodes.vue +50 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/integrations-node-devkit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Local development kit for Revenexx integration node packages — a mock Integrations API for previewing nodes/credentials/templates in the Cockpit UI, plus a unit-testing harness. Dev/CI only, never bundled.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"revenexx",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
On Save the dialog is kept OPEN and the verdict shown: a success strip, or
|
|
10
10
|
per-field errors fed back through the inspector's `refusedFields` prop so the
|
|
11
11
|
wrong fields highlight in place, plus an explicit list (a refused field can be
|
|
12
|
-
scrolled out of view).
|
|
12
|
+
scrolled out of view). Cancel, the header ✕, Esc and the backdrop all close.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
That split relies on Save always emitting `update` before `close`, which the
|
|
15
|
+
inspector only does while it considers itself dirty — see `keepInspectorDirty`.
|
|
16
16
|
-->
|
|
17
17
|
<template>
|
|
18
18
|
<div class="ndx-page">
|
|
@@ -44,15 +44,9 @@
|
|
|
44
44
|
classes, so the preview looks identical to the canvas. -->
|
|
45
45
|
<Dialog :open="!!selection" @update:open="(v) => { if (!v) closeDialog() }">
|
|
46
46
|
<DialogContent
|
|
47
|
+
:show-close-button="false"
|
|
47
48
|
class="flex h-[min(680px,86vh)] w-[min(1100px,94vw)] max-w-none flex-col gap-0 overflow-hidden rounded-lg p-0 sm:max-w-none"
|
|
48
49
|
>
|
|
49
|
-
<!-- The inspector's own footer/header buttons all emit the same `close`,
|
|
50
|
-
which this page turns into "validate" (see onInspectorClose) — so say
|
|
51
|
-
so, and say where the real close is. -->
|
|
52
|
-
<div class="ndx-strip ndx-strip-info">
|
|
53
|
-
Devkit-Preview: <strong>Save</strong> und <strong>Cancel</strong> prüfen die Config gegen den Mock,
|
|
54
|
-
ohne zu schließen. Schließen: <strong>✕ oben rechts</strong> oder <strong>Esc</strong>.
|
|
55
|
-
</div>
|
|
56
50
|
<div v-if="result === 'ok'" class="ndx-strip ndx-strip-ok">✓ Payload gültig — alles gut.</div>
|
|
57
51
|
<div v-else-if="result === 'err'" class="ndx-strip ndx-strip-err">
|
|
58
52
|
<div>✗ Payload ungültig — {{ errorCount }} Feld(er) prüfen (rot markiert):</div>
|
|
@@ -63,11 +57,12 @@
|
|
|
63
57
|
<div v-else-if="formError" class="ndx-strip ndx-strip-err">{{ formError }}</div>
|
|
64
58
|
<IntegrationsNodeInspector
|
|
65
59
|
v-if="selection"
|
|
60
|
+
ref="inspector"
|
|
66
61
|
:selection="selection"
|
|
67
62
|
:secret-keys="secretKeys"
|
|
68
63
|
:refused-fields="refused"
|
|
69
64
|
@update="onSubmit"
|
|
70
|
-
@close="
|
|
65
|
+
@close="requestClose"
|
|
71
66
|
/>
|
|
72
67
|
</DialogContent>
|
|
73
68
|
</Dialog>
|
|
@@ -75,7 +70,7 @@
|
|
|
75
70
|
</template>
|
|
76
71
|
|
|
77
72
|
<script setup lang="ts">
|
|
78
|
-
import { computed, onMounted, ref } from 'vue'
|
|
73
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
79
74
|
import { Dialog, DialogContent } from '@revenexx/studio'
|
|
80
75
|
|
|
81
76
|
interface ApiNode {
|
|
@@ -104,9 +99,39 @@ const refused = ref<Record<string, string>>({})
|
|
|
104
99
|
const result = ref<string | null>(null)
|
|
105
100
|
const formError = ref<string | null>(null)
|
|
106
101
|
// Set synchronously in onSubmit so the `close` the inspector emits right after an
|
|
107
|
-
// `update` (Save
|
|
102
|
+
// `update` (i.e. Save) does NOT close the dialog — we keep it open for the verdict.
|
|
108
103
|
const validating = ref(false)
|
|
109
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Key stamped onto `selection` to hold the inspector permanently "dirty".
|
|
107
|
+
*
|
|
108
|
+
* `NodeInspector.save()` emits `update` only when its draft differs from
|
|
109
|
+
* `selection` (a JSON string compare), then always emits `close`. On an untouched
|
|
110
|
+
* form — exactly the "is this field required?" case — Save therefore emits nothing
|
|
111
|
+
* but `close`, which is byte-for-byte what Cancel emits, and the page cannot tell
|
|
112
|
+
* them apart: it either closes on both (the old bug) or on neither (Cancel stops
|
|
113
|
+
* working). Making the comparison permanently unequal restores the distinction —
|
|
114
|
+
* Save always emits `update` first, so a bare `close` can only be Cancel, the
|
|
115
|
+
* header ✕, Esc or the backdrop.
|
|
116
|
+
*
|
|
117
|
+
* The inspector clones its draft from `selection` in setup and renders from that
|
|
118
|
+
* clone alone, so the key is stamped on afterwards (once the component ref exists),
|
|
119
|
+
* never appears in the form, and never reaches a validated payload. Its one visible
|
|
120
|
+
* trace is a permanent "Unsaved changes" in the footer — which in a preview that
|
|
121
|
+
* persists nothing is not even wrong.
|
|
122
|
+
*
|
|
123
|
+
* The proper fix belongs upstream: a `save` event on the inspector that fires
|
|
124
|
+
* regardless of `dirty`. Until studio-integrations has one, this stays.
|
|
125
|
+
*/
|
|
126
|
+
const ALWAYS_DIRTY = '__devkitPreviewProbe'
|
|
127
|
+
|
|
128
|
+
const inspector = ref<unknown>(null)
|
|
129
|
+
watch(inspector, (instance) => {
|
|
130
|
+
if (instance && selection.value && !(ALWAYS_DIRTY in selection.value)) {
|
|
131
|
+
selection.value = { ...selection.value, [ALWAYS_DIRTY]: true }
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
110
135
|
const errorCount = computed(() => Object.keys(refused.value).length)
|
|
111
136
|
|
|
112
137
|
function label(n: ApiNode): string {
|
|
@@ -159,10 +184,9 @@ async function onSubmit(draft: any) {
|
|
|
159
184
|
refused.value = {}
|
|
160
185
|
result.value = null
|
|
161
186
|
formError.value = null
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
selection.value = JSON.parse(JSON.stringify(draft))
|
|
187
|
+
// `selection` is deliberately NOT updated from the draft: it carries the
|
|
188
|
+
// ALWAYS_DIRTY key, and adopting the draft would drop it and silence the next
|
|
189
|
+
// Save. The draft arrives here on every Save anyway, so there is nothing to sync.
|
|
166
190
|
try {
|
|
167
191
|
const slug = encodeURIComponent(draft.nodeSlug)
|
|
168
192
|
const version = encodeURIComponent(draft.nodeVersion || 'latest')
|
|
@@ -192,24 +216,18 @@ async function onSubmit(draft: any) {
|
|
|
192
216
|
}
|
|
193
217
|
|
|
194
218
|
/**
|
|
195
|
-
* The inspector
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* There is nothing to persist in this preview, so both footer buttons mean the
|
|
201
|
-
* same thing: check this config. A `close` therefore validates and KEEPS THE
|
|
202
|
-
* DIALOG OPEN; leaving is the dialog's own X / Esc / backdrop.
|
|
203
|
-
*
|
|
204
|
-
* `validating` guards the Save-with-changes path, where `update` fired first
|
|
205
|
-
* (synchronously, before this `close`) and its validation is already in flight.
|
|
219
|
+
* The inspector emits `close` on Save, on Cancel and on its header ✕. Save is the
|
|
220
|
+
* only one that emits `update` first — synchronously, and ALWAYS, because
|
|
221
|
+
* ALWAYS_DIRTY keeps it dirty — so `validating` is already set by the time this
|
|
222
|
+
* runs and marks the close as Save's. Hold it, and the dialog stays open for the
|
|
223
|
+
* verdict. Anything else is a genuine close.
|
|
206
224
|
*/
|
|
207
|
-
function
|
|
208
|
-
if (validating.value
|
|
209
|
-
|
|
225
|
+
function requestClose() {
|
|
226
|
+
if (validating.value) return
|
|
227
|
+
closeDialog()
|
|
210
228
|
}
|
|
211
229
|
|
|
212
|
-
/**
|
|
230
|
+
/** Esc, the backdrop, Cancel, the header ✕ — discards the draft. */
|
|
213
231
|
function closeDialog() {
|
|
214
232
|
selection.value = null
|
|
215
233
|
refused.value = {}
|
|
@@ -235,7 +253,6 @@ function closeDialog() {
|
|
|
235
253
|
|
|
236
254
|
/* Verdict strip shown at the top of the reused dialog content (does not close). */
|
|
237
255
|
.ndx-strip { flex: 0 0 auto; padding: .5rem 1rem; font-size: .85rem; font-weight: 600; }
|
|
238
|
-
.ndx-strip-info { background: #f3f4f6; color: #4b5563; font-weight: 400; }
|
|
239
256
|
.ndx-strip-ok { background: #dcfce7; color: #166534; }
|
|
240
257
|
.ndx-strip-err { background: #fee2e2; color: #991b1b; }
|
|
241
258
|
.ndx-errs { margin: .35rem 0 0; padding-left: 1.1rem; font-weight: 400; }
|