@orsetra/shared-ui 1.5.20 → 1.5.22

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.
@@ -57,8 +57,12 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
57
57
  }, [value])
58
58
 
59
59
  const handleAdd = () => {
60
- if (!draft || items.includes(draft)) return
61
- const next = [...items, draft]
60
+ if (!draft) return
61
+ const built = normalize([draft])[0]
62
+ if (!built) return
63
+ const name = parseItem(built).name
64
+ if (items.some(item => parseItem(item).name === name)) return
65
+ const next = [...items, built]
62
66
  setItems(next)
63
67
  onChange?.(next)
64
68
  setDraft("")
@@ -153,7 +157,7 @@ export function ResourcesInput({ id, value, onChange, disabled = false, ...rest
153
157
 
154
158
  <div className="flex gap-2">
155
159
  <div className="flex-1">
156
- <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)} />
157
161
  </div>
158
162
  <Button
159
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.20",
3
+ "version": "1.5.22",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",