@orsetra/shared-ui 1.5.21 → 1.5.23

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.
@@ -19,7 +19,7 @@ const BASE_PATH = "/etc"
19
19
  function parseItem(item: string): { name: string; path: string } {
20
20
  const raw = item.startsWith(SECRET_PREFIX) ? item.slice(SECRET_PREFIX.length) : item
21
21
  const at = raw.indexOf("@")
22
- if (at === -1) return { name: raw, path: BASE_PATH }
22
+ if (at === -1) return { name: raw, path: `${BASE_PATH}/camel` }
23
23
  return { name: raw.slice(0, at), path: raw.slice(at + 1) }
24
24
  }
25
25
 
@@ -59,7 +59,9 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
59
59
  const handleAdd = () => {
60
60
  if (!draft) return
61
61
  const built = normalize([draft])[0]
62
- if (!built || items.includes(built)) return
62
+ if (!built) return
63
+ const name = parseItem(built).name
64
+ if (items.some(item => parseItem(item).name === name)) return
63
65
  const next = [...items, built]
64
66
  setItems(next)
65
67
  onChange?.(next)
@@ -80,7 +82,7 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
80
82
 
81
83
  const confirmPathEdit = (index: number) => {
82
84
  const { name } = parseItem(items[index])
83
- const fullPath = `${BASE_PATH}/${editingPathSuffix}`
85
+ const fullPath = editingPathSuffix ? `${BASE_PATH}/${editingPathSuffix}` : `${BASE_PATH}/camel`
84
86
  const next = items.map((item, i) => i === index ? buildItem(name, fullPath) : item)
85
87
  setItems(next)
86
88
  onChange?.(next)
@@ -121,7 +123,7 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
121
123
  if (e.key === "Escape") setEditingPathIndex(null)
122
124
  }}
123
125
  className="flex-1 text-sm font-mono text-ibm-gray-100 bg-transparent focus:outline-none min-w-0"
124
- placeholder="/myapp"
126
+ placeholder="camel"
125
127
  />
126
128
  </div>
127
129
  ) : (
@@ -155,7 +157,7 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
155
157
 
156
158
  <div className="flex gap-2">
157
159
  <div className="flex-1">
158
- <SecretInput value={draft} onChange={setDraft} disabled={disabled} type={id} />
160
+ <SecretInput value={draft} onChange={setDraft} disabled={disabled} type={id} exclude={items.map(item => parseItem(item).name)} />
159
161
  </div>
160
162
  <Button
161
163
  type="button"
@@ -12,6 +12,7 @@ interface SecretInputProps {
12
12
  disabled?: boolean
13
13
  className?: string
14
14
  placeholder?: string
15
+ exclude?: string[]
15
16
  }
16
17
 
17
18
  export function SecretInput({
@@ -22,6 +23,7 @@ export function SecretInput({
22
23
  disabled,
23
24
  className,
24
25
  placeholder = "Select a secret",
26
+ exclude = [],
25
27
  }: SecretInputProps) {
26
28
  const ctx = useSecretContext()
27
29
 
@@ -32,8 +34,10 @@ export function SecretInput({
32
34
  </div>
33
35
  )
34
36
  }
35
- console.log(type)
36
- const secrets = ctx.secretsMap.get(type || 'configs') || []
37
+
38
+ const secrets = (ctx.secretsMap.get(type || 'configs') || [])
39
+ .filter(s => !exclude.includes(s.name))
40
+
37
41
  return (
38
42
  <div className="flex items-center gap-2">
39
43
  <SelectInput
@@ -47,8 +47,10 @@ export function SecretsInput({ id, value, onChange, disabled = false, ...rest }:
47
47
 
48
48
  const handleAdd = () => {
49
49
  if (!draft) return
50
- const built = buildItem(draft)
51
- if (items.includes(built)) return
50
+ const built = normalize([draft])[0]
51
+ if (!built) return
52
+ const name = parseName(built)
53
+ if (items.some(item => parseName(item) === name)) return
52
54
  const next = [...items, built]
53
55
  setItems(next)
54
56
  onChange?.(next)
@@ -89,7 +91,7 @@ export function SecretsInput({ id, value, onChange, disabled = false, ...rest }:
89
91
 
90
92
  <div className="flex gap-2">
91
93
  <div className="flex-1">
92
- <SecretInput value={draft} onChange={setDraft} disabled={disabled} type={id} />
94
+ <SecretInput value={draft} onChange={setDraft} disabled={disabled} type={id} exclude={items.map(parseName)} />
93
95
  </div>
94
96
  <Button
95
97
  type="button"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.5.21",
3
+ "version": "1.5.23",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",