fix(extraSidebarComponent): change variable name from hasApiKey to hasApiKey for consistency
fix(nodeToolbarComponent): add condition to show Share option only if `hasApiKey` is true
This commit is contained in:
parent
5dc419e25f
commit
bd74a16e47
2 changed files with 11 additions and 5 deletions
|
|
@ -23,12 +23,14 @@ import {
|
||||||
} from "../../../../utils/utils";
|
} from "../../../../utils/utils";
|
||||||
import DisclosureComponent from "../DisclosureComponent";
|
import DisclosureComponent from "../DisclosureComponent";
|
||||||
import SidebarDraggableComponent from "./sideBarDraggableComponent";
|
import SidebarDraggableComponent from "./sideBarDraggableComponent";
|
||||||
|
import { StoreContext } from "../../../../contexts/storeContext";
|
||||||
|
|
||||||
export default function ExtraSidebar(): JSX.Element {
|
export default function ExtraSidebar(): JSX.Element {
|
||||||
const { data, templates, getFilterEdge, setFilterEdge, reactFlowInstance } =
|
const { data, templates, getFilterEdge, setFilterEdge, reactFlowInstance } =
|
||||||
useContext(typesContext);
|
useContext(typesContext);
|
||||||
const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt, version } =
|
const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt, version } =
|
||||||
useContext(FlowsContext);
|
useContext(FlowsContext);
|
||||||
|
const {hasApiKey} = useContext(StoreContext)
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const [dataFilter, setFilterData] = useState(data);
|
const [dataFilter, setFilterData] = useState(data);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
@ -48,6 +50,8 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
event.dataTransfer.setData("nodedata", JSON.stringify(data));
|
event.dataTransfer.setData("nodedata", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle showing components after use search input
|
// Handle showing components after use search input
|
||||||
function handleSearchInput(e: string) {
|
function handleSearchInput(e: string) {
|
||||||
if (e === "") {
|
if (e === "") {
|
||||||
|
|
@ -195,9 +199,9 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
() => (
|
() => (
|
||||||
<ExportModal>
|
<ExportModal>
|
||||||
<ShadTooltip content="Export" side="top">
|
<ShadTooltip content="Export" side="top">
|
||||||
<div className={classNames("extra-side-bar-buttons")}>
|
<button disabled={!hasApiKey} className={classNames("extra-side-bar-buttons")}>
|
||||||
<IconComponent name="FileDown" className="side-bar-button-size" />
|
<IconComponent name="FileDown" className="side-bar-button-size" />
|
||||||
</div>
|
</button>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</ExportModal>
|
</ExportModal>
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import {
|
||||||
updateFlowPosition,
|
updateFlowPosition,
|
||||||
} from "../../../../utils/reactflowUtils";
|
} from "../../../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../../../utils/utils";
|
import { classNames } from "../../../../utils/utils";
|
||||||
|
import { StoreContext } from "../../../../contexts/storeContext";
|
||||||
|
|
||||||
export default function NodeToolbarComponent({
|
export default function NodeToolbarComponent({
|
||||||
data,
|
data,
|
||||||
|
|
@ -50,6 +51,7 @@ export default function NodeToolbarComponent({
|
||||||
);
|
);
|
||||||
const updateNodeInternals = useUpdateNodeInternals();
|
const updateNodeInternals = useUpdateNodeInternals();
|
||||||
const { getNodeId } = useContext(FlowsContext);
|
const { getNodeId } = useContext(FlowsContext);
|
||||||
|
const {hasApiKey} = useContext(StoreContext)
|
||||||
|
|
||||||
function canMinimize() {
|
function canMinimize() {
|
||||||
let countHandles: number = 0;
|
let countHandles: number = 0;
|
||||||
|
|
@ -87,7 +89,7 @@ export default function NodeToolbarComponent({
|
||||||
downloadNode(createFlowComponent(cloneDeep(data), version));
|
downloadNode(createFlowComponent(cloneDeep(data), version));
|
||||||
break;
|
break;
|
||||||
case "Share":
|
case "Share":
|
||||||
setShowconfirmShare(true);
|
if(hasApiKey) setShowconfirmShare(true);
|
||||||
break;
|
break;
|
||||||
case "SaveAll":
|
case "SaveAll":
|
||||||
saveComponent(cloneDeep(data));
|
saveComponent(cloneDeep(data));
|
||||||
|
|
@ -211,7 +213,7 @@ export default function NodeToolbarComponent({
|
||||||
Save{" "}
|
Save{" "}
|
||||||
</div>{" "}
|
</div>{" "}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
<SelectItem value={"Share"}>
|
{hasApiKey && <SelectItem value={"Share"}>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Share2"
|
name="Share2"
|
||||||
|
|
@ -219,7 +221,7 @@ export default function NodeToolbarComponent({
|
||||||
/>{" "}
|
/>{" "}
|
||||||
Share{" "}
|
Share{" "}
|
||||||
</div>{" "}
|
</div>{" "}
|
||||||
</SelectItem>
|
</SelectItem>}
|
||||||
<SelectItem value={"Download"}>
|
<SelectItem value={"Download"}>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<IconComponent
|
<IconComponent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue