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 function StoreProvider({ children }) {
|
||||
const [hasStore, setHasStore] = useState(true);
|
||||
const [hasStore, setHasStore] = useState(false);
|
||||
const [loadingApiKey, setLoadingApiKey] = useState(true);
|
||||
const [hasApiKey, setHasApiKey] = useState(true);
|
||||
const [validApiKey, setValidApiKey] = useState(false);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export default function ShareModal({
|
|||
disabled?: boolean;
|
||||
}): JSX.Element {
|
||||
const { version, addFlow } = useContext(FlowsContext);
|
||||
const { hasApiKey } = useContext(StoreContext);
|
||||
const { hasApiKey, hasStore } = useContext(StoreContext);
|
||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||
const [checked, setChecked] = useState(false);
|
||||
const [name, setName] = useState(component?.name ?? "");
|
||||
|
|
@ -51,12 +51,12 @@ export default function ShareModal({
|
|||
|
||||
useEffect(() => {
|
||||
if (open || internalOpen) {
|
||||
if (hasApiKey) {
|
||||
if (hasApiKey && hasStore) {
|
||||
handleGetTags();
|
||||
handleGetNames();
|
||||
}
|
||||
}
|
||||
}, [open, internalOpen, hasApiKey]);
|
||||
}, [open, internalOpen, hasApiKey, hasStore]);
|
||||
|
||||
function handleGetTags() {
|
||||
setLoadingTags(true);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
useContext(typesContext);
|
||||
const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt, version } =
|
||||
useContext(FlowsContext);
|
||||
const { hasApiKey, validApiKey } = useContext(StoreContext);
|
||||
const { hasApiKey, validApiKey, hasStore } = useContext(StoreContext);
|
||||
const { setErrorData } = useContext(alertContext);
|
||||
const [dataFilter, setFilterData] = useState(data);
|
||||
const [search, setSearch] = useState("");
|
||||
|
|
@ -183,17 +183,21 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
() =>
|
||||
!hasApiKey || !validApiKey ? (
|
||||
<button
|
||||
disabled={!hasApiKey || !validApiKey}
|
||||
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||
className={classNames(
|
||||
"extra-side-bar-buttons",
|
||||
!hasApiKey || !validApiKey ? "button-disable cursor-default" : ""
|
||||
!hasApiKey || !validApiKey || !hasStore
|
||||
? "button-disable cursor-default"
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
name="Share2"
|
||||
className={classNames(
|
||||
"side-bar-button-size",
|
||||
!hasApiKey || !validApiKey ? "extra-side-bar-save-disable" : ""
|
||||
!hasApiKey || !validApiKey || !hasStore
|
||||
? "extra-side-bar-save-disable"
|
||||
: ""
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
|
|
@ -201,26 +205,30 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
<ShareModal
|
||||
is_component={false}
|
||||
component={flow!}
|
||||
disabled={!hasApiKey || !validApiKey}
|
||||
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||
>
|
||||
<button
|
||||
disabled={!hasApiKey || !validApiKey}
|
||||
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||
className={classNames(
|
||||
"extra-side-bar-buttons",
|
||||
!hasApiKey || !validApiKey ? "button-disable cursor-default" : ""
|
||||
!hasApiKey || !validApiKey || !hasStore
|
||||
? "button-disable cursor-default"
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
name="Share2"
|
||||
className={classNames(
|
||||
"side-bar-button-size",
|
||||
!hasApiKey || !validApiKey ? "extra-side-bar-save-disable" : ""
|
||||
!hasApiKey || !validApiKey || !hasStore
|
||||
? "extra-side-bar-save-disable"
|
||||
: ""
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
</ShareModal>
|
||||
),
|
||||
[hasApiKey, validApiKey, flow]
|
||||
[hasApiKey, validApiKey, flow, hasStore]
|
||||
);
|
||||
|
||||
const ExportMemo = useMemo(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export default function NodeToolbarComponent({
|
|||
);
|
||||
const updateNodeInternals = useUpdateNodeInternals();
|
||||
const { getNodeId } = useContext(FlowsContext);
|
||||
const { hasApiKey, validApiKey } = useContext(StoreContext);
|
||||
const { hasApiKey, validApiKey, hasStore } = useContext(StoreContext);
|
||||
|
||||
function canMinimize() {
|
||||
let countHandles: number = 0;
|
||||
|
|
@ -93,7 +93,7 @@ export default function NodeToolbarComponent({
|
|||
downloadNode(createFlowComponent(cloneDeep(data), version));
|
||||
break;
|
||||
case "Share":
|
||||
if (hasApiKey) setShowconfirmShare(true);
|
||||
if (hasApiKey || hasStore) setShowconfirmShare(true);
|
||||
break;
|
||||
case "SaveAll":
|
||||
saveComponent(cloneDeep(data), false);
|
||||
|
|
@ -235,15 +235,20 @@ export default function NodeToolbarComponent({
|
|||
</SelectItem>
|
||||
)}
|
||||
|
||||
<SelectItem disabled={!hasApiKey || !validApiKey} value={"Share"}>
|
||||
<div className="flex">
|
||||
<IconComponent
|
||||
name="Share2"
|
||||
className="relative top-0.5 mr-2 h-4 w-4"
|
||||
/>{" "}
|
||||
Share{" "}
|
||||
</div>{" "}
|
||||
</SelectItem>
|
||||
{hasStore && (
|
||||
<SelectItem
|
||||
disabled={!hasApiKey || !validApiKey}
|
||||
value={"Share"}
|
||||
>
|
||||
<div className="flex">
|
||||
<IconComponent
|
||||
name="Share2"
|
||||
className="relative top-0.5 mr-2 h-4 w-4"
|
||||
/>{" "}
|
||||
Share{" "}
|
||||
</div>{" "}
|
||||
</SelectItem>
|
||||
)}
|
||||
<SelectItem value={"Download"}>
|
||||
<div className="flex">
|
||||
<IconComponent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue