fix: playground page allowing image upload even if feature flag is disabled (#7877)
* Fix use drag and drop to check for playground page * fix chat input to change file only if enable_image_on_playground is enabled and its on playground page * change input wrapper to show upload file if constant is enabled * changed onDrop to not allow sending files if enable_image_on_playground is disabled
This commit is contained in:
parent
2c8e134725
commit
296d285555
4 changed files with 16 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { usePostUploadFile } from "@/controllers/API/queries/files/use-post-upload-file";
|
||||
import { ENABLE_IMAGE_ON_PLAYGROUND } from "@/customization/feature-flags";
|
||||
import useFileSizeValidator from "@/shared/hooks/use-file-size-validator";
|
||||
import useAlertStore from "@/stores/alertStore";
|
||||
import useFlowStore from "@/stores/flowStore";
|
||||
|
|
@ -64,7 +65,7 @@ export default function ChatInput({
|
|||
const handleFileChange = async (
|
||||
event: React.ChangeEvent<HTMLInputElement> | ClipboardEvent,
|
||||
) => {
|
||||
if (playgroundPage) {
|
||||
if (playgroundPage && !ENABLE_IMAGE_ON_PLAYGROUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ const InputWrapper: React.FC<InputWrapperProps> = ({
|
|||
</div>
|
||||
<div className="flex w-full items-end justify-between">
|
||||
<div className={isBuilding ? "cursor-not-allowed" : ""}>
|
||||
{!playgroundPage && ENABLE_IMAGE_ON_PLAYGROUND && (
|
||||
{(!playgroundPage ||
|
||||
(playgroundPage && ENABLE_IMAGE_ON_PLAYGROUND)) && (
|
||||
<UploadFileButton
|
||||
isBuilding={isBuilding}
|
||||
fileInputRef={fileInputRef}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import { ENABLE_IMAGE_ON_PLAYGROUND } from "@/customization/feature-flags";
|
||||
|
||||
const useDragAndDrop = (setIsDragging: (value: boolean) => void) => {
|
||||
const useDragAndDrop = (
|
||||
setIsDragging: (value: boolean) => void,
|
||||
playgroundPage: boolean,
|
||||
) => {
|
||||
const dragOver = (e) => {
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND) return;
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND && playgroundPage) return;
|
||||
e.preventDefault();
|
||||
if (e.dataTransfer.types.some((type) => type === "Files")) {
|
||||
setIsDragging(true);
|
||||
|
|
@ -10,7 +13,7 @@ const useDragAndDrop = (setIsDragging: (value: boolean) => void) => {
|
|||
};
|
||||
|
||||
const dragEnter = (e) => {
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND) return;
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND && playgroundPage) return;
|
||||
if (e.dataTransfer.types.some((type) => type === "Files")) {
|
||||
setIsDragging(true);
|
||||
}
|
||||
|
|
@ -18,6 +21,7 @@ const useDragAndDrop = (setIsDragging: (value: boolean) => void) => {
|
|||
};
|
||||
|
||||
const dragLeave = (e) => {
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND && playgroundPage) return;
|
||||
e.preventDefault();
|
||||
setIsDragging(false);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -148,10 +148,13 @@ export default function ChatView({
|
|||
const { files, setFiles, handleFiles } = useFileHandler(currentFlowId);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
|
||||
const { dragOver, dragEnter, dragLeave } = useDragAndDrop(setIsDragging);
|
||||
const { dragOver, dragEnter, dragLeave } = useDragAndDrop(
|
||||
setIsDragging,
|
||||
!!playgroundPage,
|
||||
);
|
||||
|
||||
const onDrop = (e) => {
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND) {
|
||||
if (!ENABLE_IMAGE_ON_PLAYGROUND && playgroundPage) {
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue