fix: publish button not redirecting to right path (#7439)
* Added custom link to shareable playground * Added correct tooltip to Shareable Playground button * Fix typo
This commit is contained in:
parent
1cb2e0684b
commit
6e38033a95
1 changed files with 28 additions and 20 deletions
|
|
@ -9,6 +9,7 @@ import {
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { usePatchUpdateFlow } from "@/controllers/API/queries/flows/use-patch-update-flow";
|
import { usePatchUpdateFlow } from "@/controllers/API/queries/flows/use-patch-update-flow";
|
||||||
|
import { CustomLink } from "@/customization/components/custom-link";
|
||||||
import { ENABLE_WIDGET } from "@/customization/feature-flags";
|
import { ENABLE_WIDGET } from "@/customization/feature-flags";
|
||||||
import ApiModal from "@/modals/apiModal/new-api-modal";
|
import ApiModal from "@/modals/apiModal/new-api-modal";
|
||||||
import EmbedModal from "@/modals/EmbedModal/embed-modal";
|
import EmbedModal from "@/modals/EmbedModal/embed-modal";
|
||||||
|
|
@ -18,9 +19,11 @@ import useFlowsManagerStore from "@/stores/flowsManagerStore";
|
||||||
import useFlowStore from "@/stores/flowStore";
|
import useFlowStore from "@/stores/flowStore";
|
||||||
import { cn } from "@/utils/utils";
|
import { cn } from "@/utils/utils";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useHref } from "react-router-dom";
|
||||||
|
|
||||||
export default function PublishDropdown() {
|
export default function PublishDropdown() {
|
||||||
const domain = window.location.origin;
|
const location = useHref("/");
|
||||||
|
const domain = window.location.origin + location;
|
||||||
const [openEmbedModal, setOpenEmbedModal] = useState(false);
|
const [openEmbedModal, setOpenEmbedModal] = useState(false);
|
||||||
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
||||||
const flowId = currentFlow?.id;
|
const flowId = currentFlow?.id;
|
||||||
|
|
@ -134,7 +137,7 @@ export default function PublishDropdown() {
|
||||||
hasIO
|
hasIO
|
||||||
? isPublished
|
? isPublished
|
||||||
? encodeURI(`${domain}/playground/${flowId}`)
|
? encodeURI(`${domain}/playground/${flowId}`)
|
||||||
: "Active to share a public version of this Playground"
|
: "Activate to share a public version of this Playground"
|
||||||
: "Add a Chat Input or Chat Output to access your flow"
|
: "Add a Chat Input or Chat Output to access your flow"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
@ -145,25 +148,30 @@ export default function PublishDropdown() {
|
||||||
)}
|
)}
|
||||||
data-testid="shareable-playground"
|
data-testid="shareable-playground"
|
||||||
>
|
>
|
||||||
<DropdownMenuItem
|
<CustomLink
|
||||||
disabled={!hasIO || !isPublished}
|
className={cn(
|
||||||
className="deploy-dropdown-item group flex-1"
|
"flex-1",
|
||||||
onClick={() => {
|
!hasIO || !isPublished
|
||||||
if (hasIO) {
|
? "pointer-events-none cursor-default"
|
||||||
if (isPublished) {
|
: "",
|
||||||
window.open(`${domain}/playground/${flowId}`, "_blank");
|
)}
|
||||||
}
|
to={`/playground/${flowId}`}
|
||||||
}
|
target="_blank"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div className="group-hover:bg-accent">
|
<DropdownMenuItem
|
||||||
<IconComponent
|
disabled={!hasIO || !isPublished}
|
||||||
name="Globe"
|
className="deploy-dropdown-item group flex-1"
|
||||||
className={`${groupStyle} icon-size mr-2`}
|
onClick={() => {}}
|
||||||
/>
|
>
|
||||||
<span>Shareable Playground</span>
|
<div className="group-hover:bg-accent">
|
||||||
</div>
|
<IconComponent
|
||||||
</DropdownMenuItem>
|
name="Globe"
|
||||||
|
className={`${groupStyle} icon-size mr-2`}
|
||||||
|
/>
|
||||||
|
<span>Shareable Playground</span>
|
||||||
|
</div>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</CustomLink>
|
||||||
<div className={`z-50 mr-2 text-foreground`}>
|
<div className={`z-50 mr-2 text-foreground`}>
|
||||||
<Switch
|
<Switch
|
||||||
data-testid="publish-switch"
|
data-testid="publish-switch"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue