fix(storeContext.tsx): set initial value of hasStore to false instead of true to fix incorrect initial state
fix(shareModal/index.tsx): import has function from lodash to fix missing import error fix(shareModal/index.tsx): add hasStore to the list of dependencies in useEffect to fix missing dependency warning fix(extraSidebarComponent/index.tsx): add hasStore to the list of dependencies in useEffect to fix missing dependency warning fix(extraSidebarComponent/index.tsx): disable share button if hasStore is false to prevent sharing without a store fix(extraSidebarComponent/index.tsx): disable share button in ShareModal if hasStore is false to prevent sharing without a store fix(extraSidebarComponent/index.tsx): disable share button in ShareModal if hasStore is false to prevent sharing without a store fix(nodeToolbarComponent/index.tsx): add hasStore to the list of dependencies to fix missing dependency warning fix(nodeToolbarComponent/index.tsx): disable share option in SelectItem if hasStore is false to prevent sharing without a store
This commit is contained in:
parent
2d21535e2a
commit
14cd1b30fd
4 changed files with 37 additions and 24 deletions
|
|
@ -17,7 +17,7 @@ const initialValue = {
|
||||||
export const StoreContext = createContext<storeContextType>(initialValue);
|
export const StoreContext = createContext<storeContextType>(initialValue);
|
||||||
|
|
||||||
export function StoreProvider({ children }) {
|
export function StoreProvider({ children }) {
|
||||||
const [hasStore, setHasStore] = useState(true);
|
const [hasStore, setHasStore] = useState(false);
|
||||||
const [loadingApiKey, setLoadingApiKey] = useState(true);
|
const [loadingApiKey, setLoadingApiKey] = useState(true);
|
||||||
const [hasApiKey, setHasApiKey] = useState(true);
|
const [hasApiKey, setHasApiKey] = useState(true);
|
||||||
const [validApiKey, setValidApiKey] = useState(false);
|
const [validApiKey, setValidApiKey] = useState(false);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default function ShareModal({
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const { version, addFlow } = useContext(FlowsContext);
|
const { version, addFlow } = useContext(FlowsContext);
|
||||||
const { hasApiKey } = useContext(StoreContext);
|
const { hasApiKey, hasStore } = useContext(StoreContext);
|
||||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||||
const [checked, setChecked] = useState(false);
|
const [checked, setChecked] = useState(false);
|
||||||
const [name, setName] = useState(component?.name ?? "");
|
const [name, setName] = useState(component?.name ?? "");
|
||||||
|
|
@ -51,12 +51,12 @@ export default function ShareModal({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open || internalOpen) {
|
if (open || internalOpen) {
|
||||||
if (hasApiKey) {
|
if (hasApiKey && hasStore) {
|
||||||
handleGetTags();
|
handleGetTags();
|
||||||
handleGetNames();
|
handleGetNames();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [open, internalOpen, hasApiKey]);
|
}, [open, internalOpen, hasApiKey, hasStore]);
|
||||||
|
|
||||||
function handleGetTags() {
|
function handleGetTags() {
|
||||||
setLoadingTags(true);
|
setLoadingTags(true);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
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, validApiKey } = useContext(StoreContext);
|
const { hasApiKey, validApiKey, hasStore } = 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("");
|
||||||
|
|
@ -183,17 +183,21 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
() =>
|
() =>
|
||||||
!hasApiKey || !validApiKey ? (
|
!hasApiKey || !validApiKey ? (
|
||||||
<button
|
<button
|
||||||
disabled={!hasApiKey || !validApiKey}
|
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"extra-side-bar-buttons",
|
"extra-side-bar-buttons",
|
||||||
!hasApiKey || !validApiKey ? "button-disable cursor-default" : ""
|
!hasApiKey || !validApiKey || !hasStore
|
||||||
|
? "button-disable cursor-default"
|
||||||
|
: ""
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Share2"
|
name="Share2"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"side-bar-button-size",
|
"side-bar-button-size",
|
||||||
!hasApiKey || !validApiKey ? "extra-side-bar-save-disable" : ""
|
!hasApiKey || !validApiKey || !hasStore
|
||||||
|
? "extra-side-bar-save-disable"
|
||||||
|
: ""
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -201,26 +205,30 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
<ShareModal
|
<ShareModal
|
||||||
is_component={false}
|
is_component={false}
|
||||||
component={flow!}
|
component={flow!}
|
||||||
disabled={!hasApiKey || !validApiKey}
|
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
disabled={!hasApiKey || !validApiKey}
|
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"extra-side-bar-buttons",
|
"extra-side-bar-buttons",
|
||||||
!hasApiKey || !validApiKey ? "button-disable cursor-default" : ""
|
!hasApiKey || !validApiKey || !hasStore
|
||||||
|
? "button-disable cursor-default"
|
||||||
|
: ""
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Share2"
|
name="Share2"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"side-bar-button-size",
|
"side-bar-button-size",
|
||||||
!hasApiKey || !validApiKey ? "extra-side-bar-save-disable" : ""
|
!hasApiKey || !validApiKey || !hasStore
|
||||||
|
? "extra-side-bar-save-disable"
|
||||||
|
: ""
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</ShareModal>
|
</ShareModal>
|
||||||
),
|
),
|
||||||
[hasApiKey, validApiKey, flow]
|
[hasApiKey, validApiKey, flow, hasStore]
|
||||||
);
|
);
|
||||||
|
|
||||||
const ExportMemo = useMemo(
|
const ExportMemo = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ export default function NodeToolbarComponent({
|
||||||
);
|
);
|
||||||
const updateNodeInternals = useUpdateNodeInternals();
|
const updateNodeInternals = useUpdateNodeInternals();
|
||||||
const { getNodeId } = useContext(FlowsContext);
|
const { getNodeId } = useContext(FlowsContext);
|
||||||
const { hasApiKey, validApiKey } = useContext(StoreContext);
|
const { hasApiKey, validApiKey, hasStore } = useContext(StoreContext);
|
||||||
|
|
||||||
function canMinimize() {
|
function canMinimize() {
|
||||||
let countHandles: number = 0;
|
let countHandles: number = 0;
|
||||||
|
|
@ -93,7 +93,7 @@ export default function NodeToolbarComponent({
|
||||||
downloadNode(createFlowComponent(cloneDeep(data), version));
|
downloadNode(createFlowComponent(cloneDeep(data), version));
|
||||||
break;
|
break;
|
||||||
case "Share":
|
case "Share":
|
||||||
if (hasApiKey) setShowconfirmShare(true);
|
if (hasApiKey || hasStore) setShowconfirmShare(true);
|
||||||
break;
|
break;
|
||||||
case "SaveAll":
|
case "SaveAll":
|
||||||
saveComponent(cloneDeep(data), false);
|
saveComponent(cloneDeep(data), false);
|
||||||
|
|
@ -235,15 +235,20 @@ export default function NodeToolbarComponent({
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<SelectItem disabled={!hasApiKey || !validApiKey} value={"Share"}>
|
{hasStore && (
|
||||||
<div className="flex">
|
<SelectItem
|
||||||
<IconComponent
|
disabled={!hasApiKey || !validApiKey}
|
||||||
name="Share2"
|
value={"Share"}
|
||||||
className="relative top-0.5 mr-2 h-4 w-4"
|
>
|
||||||
/>{" "}
|
<div className="flex">
|
||||||
Share{" "}
|
<IconComponent
|
||||||
</div>{" "}
|
name="Share2"
|
||||||
</SelectItem>
|
className="relative top-0.5 mr-2 h-4 w-4"
|
||||||
|
/>{" "}
|
||||||
|
Share{" "}
|
||||||
|
</div>{" "}
|
||||||
|
</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