Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created tab for sharing and tab for creating links #288

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/menu/Share.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ const Share = (props) => {
<Overlay key={props.sessionID} close={props.onClickCloseHandler}>
<div className="tabs-wrapper">
{/* <Tabs defaultActiveKey="share" activeTab={activeTab} id="controlled-tab-example"> */}
<Tabs defaultActiveKey="share" id="controlled-tab-example">
<Tabs defaultActiveKey={props.sessionID ? "share" : "links"} id="controlled-tab-example">
<Tab eventKey="share" title="Share">
<div>
<ShareLink sessionID={props.sessionID} saveSessionToDB={props.saveSessionToDB} />
<ShareLink sessionID={props.sessionID} saveSessionToDB={undefined} />
</div>
</Tab>

<Tab eventKey="links" title="create links">
<div>
<ShareLink sessionID={undefined} saveSessionToDB={props.saveSessionToDB} />
</div>
</Tab>
</Tabs>
Expand Down
17 changes: 10 additions & 7 deletions src/components/menu/ShareLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { useState } from "react";

const ShareLink = (props) => {
const [hasCopied, setHasCopied] = useState(false);
// console.log("ShareLink");
// console.log(props.sessionID);

if (props.sessionID) {
const url = "/shared/" + props.sessionID;
Expand All @@ -12,12 +10,11 @@ const ShareLink = (props) => {
const copyToClipBoard = () => {
navigator.clipboard.writeText(fullUrl);
};
// console.log("hasCopied", hasCopied);

return (
<div className="share-link">
<h2>Share</h2>
<p>Share your current setup:</p>
<p>Share your stored setup:</p>
<a href={url} title="" target="_blank" rel="noopener noreferrer">
{fullUrl}
</a>
Expand All @@ -28,20 +25,26 @@ const ShareLink = (props) => {
}}>
copy
</button>
<button onClick={props.saveSessionToDB}>save new setup</button>
<span className={`message ${hasCopied ? "show" : ""}`}>The link has been copied</span>
</div>
);
} else {
} else if (props.saveSessionToDB) {
return (
<div className="share-link">
<h2>Share</h2>
<p>Share your current setup:</p>
<button onClick={props.saveSessionToDB}>create share link</button>
<span className={`message ${hasCopied ? "show" : ""}`}>The link has been copied</span>
<span>will store online and create a new link for sharing</span>
</div>
);
} else {
return (
<div className="share-link">
<h2>Share</h2>
<p>Create a Share link on the create links tab</p>
</div>
);
// return <div>Could not generate url</div>;
}
};

Expand Down