mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 08:27:22 +00:00
improvement: update import secret env select
This commit is contained in:
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
FilterableSelect,
|
||||||
FormControl,
|
FormControl,
|
||||||
Modal,
|
Modal,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
@@ -17,7 +18,7 @@ import { useSubscription, useWorkspace } from "@app/context";
|
|||||||
import { useCreateSecretImport } from "@app/hooks/api";
|
import { useCreateSecretImport } from "@app/hooks/api";
|
||||||
|
|
||||||
const typeSchema = z.object({
|
const typeSchema = z.object({
|
||||||
environment: z.string().trim(),
|
environment: z.object({ name: z.string(), slug: z.string() }),
|
||||||
secretPath: z
|
secretPath: z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
@@ -80,7 +81,7 @@ export const CreateSecretImportForm = ({
|
|||||||
path: secretPath,
|
path: secretPath,
|
||||||
isReplication,
|
isReplication,
|
||||||
import: {
|
import: {
|
||||||
environment: importedEnv,
|
environment: importedEnv.slug,
|
||||||
path: importedSecPath
|
path: importedSecPath
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -88,8 +89,9 @@ export const CreateSecretImportForm = ({
|
|||||||
reset();
|
reset();
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: `Successfully linked. ${isReplication ? "Please refresh the dashboard to view changes" : ""
|
text: `Successfully linked. ${
|
||||||
}`
|
isReplication ? "Please refresh the dashboard to view changes" : ""
|
||||||
|
}`
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -118,21 +120,16 @@ export const CreateSecretImportForm = ({
|
|||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="environment"
|
name="environment"
|
||||||
defaultValue={environments?.[0]?.slug}
|
render={({ field: { onChange, value }, fieldState: { error } }) => (
|
||||||
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
|
|
||||||
<FormControl label="Environment" errorText={error?.message} isError={Boolean(error)}>
|
<FormControl label="Environment" errorText={error?.message} isError={Boolean(error)}>
|
||||||
<Select
|
<FilterableSelect
|
||||||
defaultValue={field.value}
|
options={environments}
|
||||||
{...field}
|
getOptionLabel={(option) => option.name}
|
||||||
onValueChange={(e) => onChange(e)}
|
getOptionValue={(option) => option.slug}
|
||||||
className="w-full"
|
placeholder="Select environment..."
|
||||||
>
|
value={value}
|
||||||
{environments.map(({ name, slug }) => (
|
onChange={onChange}
|
||||||
<SelectItem value={slug} key={slug}>
|
/>
|
||||||
{name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -142,7 +139,7 @@ export const CreateSecretImportForm = ({
|
|||||||
defaultValue="/"
|
defaultValue="/"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl label="Secret Path" isError={Boolean(error)} errorText={error?.message}>
|
<FormControl label="Secret Path" isError={Boolean(error)} errorText={error?.message}>
|
||||||
<SecretPathInput {...field} environment={selectedEnvironment} />
|
<SecretPathInput {...field} environment={selectedEnvironment?.slug} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user