@orsetra/shared-ui 1.4.0 → 1.4.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.
@@ -9,23 +9,20 @@ export interface SecretEntry {
9
9
  }
10
10
 
11
11
  interface SecretContextValue {
12
- templateId?: string
13
- fetchSecrets: (templateId?: string) => Promise<SecretEntry[]>
12
+ secretsMap: Map<string, SecretEntry[]>
14
13
  }
15
14
 
16
15
  const SecretContext = createContext<SecretContextValue | null>(null)
17
16
 
18
17
  export function SecretContextProvider({
19
18
  children,
20
- templateId,
21
- fetchSecrets,
19
+ secretsMap,
22
20
  }: {
23
21
  children: ReactNode
24
- templateId?: string
25
- fetchSecrets: (templateId?: string) => Promise<SecretEntry[]>
22
+ secretsMap: Map<string, SecretEntry[]>
26
23
  }) {
27
24
  return (
28
- <SecretContext.Provider value={{ templateId, fetchSecrets }}>
25
+ <SecretContext.Provider value={{ secretsMap }}>
29
26
  {children}
30
27
  </SecretContext.Provider>
31
28
  )
@@ -1,10 +1,7 @@
1
1
  "use client"
2
2
 
3
- import { useState, useEffect } from "react"
4
- import { Loader2 } from "lucide-react"
5
3
  import { SelectInput } from "./select-input"
6
4
  import { useSecretContext } from "./secret-context"
7
- import type { SecretEntry } from "./secret-context"
8
5
 
9
6
  interface SecretInputProps {
10
7
  id?: string
@@ -26,26 +23,6 @@ export function SecretInput({
26
23
  placeholder = "Select a secret",
27
24
  }: SecretInputProps) {
28
25
  const ctx = useSecretContext()
29
- const [secrets, setSecrets] = useState<SecretEntry[]>([])
30
- const [loading, setLoading] = useState(false)
31
-
32
- useEffect(() => {
33
- if (!ctx) return
34
- setLoading(true)
35
- ctx.fetchSecrets(type === "configs" ? ctx.templateId : type)
36
- .then(setSecrets)
37
- .catch(() => setSecrets([]))
38
- .finally(() => setLoading(false))
39
- }, [ctx?.templateId])
40
-
41
- if (loading) {
42
- return (
43
- <div className="flex items-center gap-2 h-10 px-3 border border-ibm-gray-30 bg-white text-sm text-ibm-gray-60">
44
- <Loader2 className="h-4 w-4 animate-spin flex-shrink-0" />
45
- Loading secrets…
46
- </div>
47
- )
48
- }
49
26
 
50
27
  if (!ctx) {
51
28
  return (
@@ -54,7 +31,7 @@ export function SecretInput({
54
31
  </div>
55
32
  )
56
33
  }
57
-
34
+ const secrets = ctx.secretsMap.get(type || 'configs') || []
58
35
  return (
59
36
  <SelectInput
60
37
  id={id}
@@ -63,7 +40,7 @@ export function SecretInput({
63
40
  disabled={disabled}
64
41
  className={className}
65
42
  placeholder={placeholder}
66
- options={secrets.map((s) => ({ label: s.description || s.name, value: s.name }))}
43
+ options={secrets.map((s) => ({ label: s.description || s.name, value: `secret:${s.name}` }))}
67
44
  />
68
45
  )
69
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",