mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 20:27:43 +00:00
feat: added banner to notify user doesn't have permission to read tags
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { ClipboardEvent } from "react";
|
import { ClipboardEvent } from "react";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -16,7 +18,7 @@ import { PopUpNames, usePopUpAction } from "../../SecretMainPage.store";
|
|||||||
const typeSchema = z.object({
|
const typeSchema = z.object({
|
||||||
key: z.string().trim().min(1, { message: "Secret key is required" }),
|
key: z.string().trim().min(1, { message: "Secret key is required" }),
|
||||||
value: z.string().optional(),
|
value: z.string().optional(),
|
||||||
tags: z.array(z.object({ label: z.string().trim(), value: z.string().trim() })).min(1)
|
tags: z.array(z.object({ label: z.string().trim(), value: z.string().trim() })).optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
type TFormSchema = z.infer<typeof typeSchema>;
|
type TFormSchema = z.infer<typeof typeSchema>;
|
||||||
@@ -64,7 +66,7 @@ export const CreateSecretForm = ({
|
|||||||
secretValue: value || "",
|
secretValue: value || "",
|
||||||
secretComment: "",
|
secretComment: "",
|
||||||
type: SecretType.Shared,
|
type: SecretType.Shared,
|
||||||
tagIds: tags.map((el) => el.value)
|
tagIds: tags?.map((el) => el.value)
|
||||||
});
|
});
|
||||||
closePopUp(PopUpNames.CreateSecretForm);
|
closePopUp(PopUpNames.CreateSecretForm);
|
||||||
reset();
|
reset();
|
||||||
@@ -135,6 +137,16 @@ export const CreateSecretForm = ({
|
|||||||
label="Tags"
|
label="Tags"
|
||||||
isError={Boolean(errors?.value)}
|
isError={Boolean(errors?.value)}
|
||||||
errorText={errors?.value?.message}
|
errorText={errors?.value?.message}
|
||||||
|
helperText={
|
||||||
|
!canReadTags ? (
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<FontAwesomeIcon icon={faTriangleExclamation} className="text-yellow-400" />
|
||||||
|
<span>User lacks permission to read tags. Please grant access.</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
|||||||
+14
-4
@@ -1,7 +1,7 @@
|
|||||||
import { ClipboardEvent } from "react";
|
import { ClipboardEvent } from "react";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import { subject } from "@casl/ability";
|
import { subject } from "@casl/ability";
|
||||||
import { faWarning } from "@fortawesome/free-solid-svg-icons";
|
import { faTriangleExclamation, faWarning } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -37,7 +37,7 @@ const typeSchema = z
|
|||||||
key: z.string().trim().min(1, "Key is required"),
|
key: z.string().trim().min(1, "Key is required"),
|
||||||
value: z.string().optional(),
|
value: z.string().optional(),
|
||||||
environments: z.record(z.boolean().optional()),
|
environments: z.record(z.boolean().optional()),
|
||||||
tags: z.array(z.object({ label: z.string().trim(), value: z.string().trim() })).min(1)
|
tags: z.array(z.object({ label: z.string().trim(), value: z.string().trim() })).optional()
|
||||||
})
|
})
|
||||||
.refine((data) => data.key !== undefined, {
|
.refine((data) => data.key !== undefined, {
|
||||||
message: "Please enter secret name"
|
message: "Please enter secret name"
|
||||||
@@ -122,7 +122,7 @@ export const CreateSecretForm = ({ secretPath = "/", getSecretByKey, onClose }:
|
|||||||
secretKey: key,
|
secretKey: key,
|
||||||
secretValue: value || "",
|
secretValue: value || "",
|
||||||
type: SecretType.Shared,
|
type: SecretType.Shared,
|
||||||
tagIds: tags.map((el) => el.value)
|
tagIds: tags?.map((el) => el.value)
|
||||||
})),
|
})),
|
||||||
environment
|
environment
|
||||||
};
|
};
|
||||||
@@ -137,7 +137,7 @@ export const CreateSecretForm = ({ secretPath = "/", getSecretByKey, onClose }:
|
|||||||
secretValue: value || "",
|
secretValue: value || "",
|
||||||
secretComment: "",
|
secretComment: "",
|
||||||
type: SecretType.Shared,
|
type: SecretType.Shared,
|
||||||
tagIds: tags.map((el) => el.value)
|
tagIds: tags?.map((el) => el.value)
|
||||||
})),
|
})),
|
||||||
environment
|
environment
|
||||||
};
|
};
|
||||||
@@ -238,6 +238,16 @@ export const CreateSecretForm = ({ secretPath = "/", getSecretByKey, onClose }:
|
|||||||
label="Tags"
|
label="Tags"
|
||||||
isError={Boolean(errors?.value)}
|
isError={Boolean(errors?.value)}
|
||||||
errorText={errors?.value?.message}
|
errorText={errors?.value?.message}
|
||||||
|
helperText={
|
||||||
|
!canReadTags ? (
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<FontAwesomeIcon icon={faTriangleExclamation} className="text-yellow-400" />
|
||||||
|
<span>User lacks permission to read tags. Please grant access.</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
|||||||
Reference in New Issue
Block a user