@xeplr/ui-jobs 1.6.3 → 1.6.5
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 +2 -2
- package/src/api/jobs.js +14 -40
- package/src/pages/Jobs.jsx +3 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeplr/ui-jobs",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "The screens for @xeplr/jobs — schedule, run, pause and watch jobs — as routes a host app registers, or a standalone app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.jsx",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@vitejs/plugin-react": "^5.2.0",
|
|
49
49
|
"@xeplr/ui-account": "^1.0.2",
|
|
50
|
-
"@xeplr/ui-utils": "^1.
|
|
50
|
+
"@xeplr/ui-utils": "^1.1.5",
|
|
51
51
|
"react": "^19.2.4",
|
|
52
52
|
"react-dom": "^19.2.4",
|
|
53
53
|
"react-router-dom": "^7.13.2",
|
package/src/api/jobs.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createOptionSources } from '@xeplr/ui-utils'
|
|
1
2
|
import { authFetch } from '@xeplr/ui-account'
|
|
2
3
|
|
|
3
4
|
// WHERE THE JOBS API LIVES, set once by the host at registration.
|
|
@@ -73,53 +74,26 @@ export async function listOccurrences(jobId) {
|
|
|
73
74
|
// Nothing configured for a kind → the field falls back to a plain text input.
|
|
74
75
|
// That is what keeps standalone jobs honest: an empty dropdown looks broken,
|
|
75
76
|
// while a text box is simply what you have when there is no catalogue.
|
|
76
|
-
|
|
77
|
+
// One copy, in @xeplr/ui-utils (createOptionSources), shared with X-Flow's
|
|
78
|
+
// step editor. These names stay, so nothing that imports them changes.
|
|
79
|
+
let _optionSources = createOptionSources({}, (p) => authFetch(url(p)))
|
|
77
80
|
|
|
78
81
|
export function configureOptionSources(sources) {
|
|
79
|
-
_optionSources = sources
|
|
82
|
+
_optionSources = createOptionSources(sources, (p) => authFetch(url(p)))
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
export function hasOptionSource(kind) {
|
|
83
|
-
return
|
|
86
|
+
return _optionSources.has(kind)
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* Fetch suggestions from an option source, asked with several values at once
|
|
95
|
-
* — `query` is { param: value }. Answers the list of values (strings), empty
|
|
96
|
-
* when the source is not configured or something it needs is not chosen yet.
|
|
97
|
-
*/
|
|
98
|
-
export async function fetchSuggestions(kind, query) {
|
|
99
|
-
const src = _optionSources[kind]
|
|
100
|
-
if (!src) return []
|
|
101
|
-
const pairs = Object.entries(query || {})
|
|
102
|
-
if (pairs.some(([, v]) => v === undefined || v === null || v === '')) return []
|
|
103
|
-
const q = pairs.map(([k, v]) => `&${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('')
|
|
104
|
-
const res = await authFetch(url(`${src.url}?limit=0${q}`))
|
|
105
|
-
const list = (res && res[src.key || 'dataArray']) || []
|
|
106
|
-
return list.map((o) => String(o[src.value || 'value'])).filter(Boolean)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function fetchOptions(kind, filter) {
|
|
110
|
-
const src = _optionSources[kind]
|
|
111
|
-
if (!src) return []
|
|
112
|
-
const q = filter && filter.value ? `&${encodeURIComponent(filter.name)}=${encodeURIComponent(filter.value)}` : ''
|
|
113
|
-
const res = await authFetch(url(`${src.url}?limit=0${q}`))
|
|
114
|
-
// `dataArray` is what genericRoute returns, so it is the default — but a
|
|
115
|
-
// hand-written endpoint answers with whatever it likes (BI's
|
|
116
|
-
// /warehouse/tables says `tables`). The host names the key rather than this
|
|
117
|
-
// package guessing, because guessing wrong yields an empty dropdown and no
|
|
118
|
-
// error, which reads as "you have none of these".
|
|
119
|
-
const rows = res[src.key || 'dataArray'] || []
|
|
120
|
-
return rows
|
|
121
|
-
.filter((r) => (filter && filter.clientKey ? r[filter.clientKey] === filter.value : true))
|
|
122
|
-
.map((r) => ({ value: r[src.value || 'id'], label: r[src.label] || r[src.value || 'id'] }))
|
|
89
|
+
/** Suggestions from an option source, asked with several values at once. */
|
|
90
|
+
export function fetchSuggestions(kind, query) {
|
|
91
|
+
return _optionSources.fetchSuggestions(kind, query)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** One option list; `filter` narrows a dependent one. */
|
|
95
|
+
export function fetchOptions(kind, filter) {
|
|
96
|
+
return _optionSources.fetchOptions(kind, filter)
|
|
123
97
|
}
|
|
124
98
|
|
|
125
99
|
/**
|
package/src/pages/Jobs.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
|
-
import { raiseConfirm, raiseSnackbar } from '@xeplr/ui-utils'
|
|
2
|
+
import { fieldLabel, raiseConfirm, raiseSnackbar } from '@xeplr/ui-utils'
|
|
3
3
|
import { relativeTime } from './relativeTime.js'
|
|
4
4
|
import {
|
|
5
5
|
listJobs, listOccurrences, listJobOccurrences, listJobActions, listActiveRuns,
|
|
@@ -288,32 +288,8 @@ function visibleFields(action, inputs) {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
// ── labels ────────────────────────────────────────────────────────────────
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
// "connectionInfoId", "dbInfoId", "streaming_mode" and "batchSize" in front of
|
|
294
|
-
// people as though those were English.
|
|
295
|
-
//
|
|
296
|
-
// A schema may carry its own `label`; this is the fallback, and it is good
|
|
297
|
-
// enough that most fields will never need one. `Id`/`Info` are suffixes of the
|
|
298
|
-
// storage, not of the thing — you pick a Connection, not a connectionInfoId.
|
|
299
|
-
const LABEL_WORDS = { db: 'Database', sql: 'SQL', url: 'URL', id: 'ID', api: 'API' }
|
|
300
|
-
|
|
301
|
-
function fieldLabel(field) {
|
|
302
|
-
if (field.label) return field.label
|
|
303
|
-
return String(field.name)
|
|
304
|
-
.replace(/Id$/, '')
|
|
305
|
-
.replace(/Info$/, '')
|
|
306
|
-
.replace(/[_-]+/g, ' ')
|
|
307
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
308
|
-
.trim()
|
|
309
|
-
.split(' ')
|
|
310
|
-
.map((w, i) => {
|
|
311
|
-
const known = LABEL_WORDS[w.toLowerCase()]
|
|
312
|
-
if (known) return known
|
|
313
|
-
return i === 0 ? w.charAt(0).toUpperCase() + w.slice(1) : w.toLowerCase()
|
|
314
|
-
})
|
|
315
|
-
.join(' ')
|
|
316
|
-
}
|
|
291
|
+
// A field's name as words ("connectionInfoId" → "Connection") is
|
|
292
|
+
// @xeplr/ui-utils' fieldLabel, shared with X-Flow's step editor.
|
|
317
293
|
|
|
318
294
|
/**
|
|
319
295
|
* Split the fields into what you fill in and what you almost never touch.
|