Skip to content

Commit 210842b

Browse files
removes url generator from page and replaces with 'copy as url' button.
1 parent 808781b commit 210842b

9 files changed

Lines changed: 78 additions & 155 deletions

File tree

src/App.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,23 @@ function App() {
125125
namespace={namespace}
126126
option={option}
127127
setGeneratedURI={setGeneratedURI}
128+
generatedURI={generatedURI}
128129
mode={mode}
129130
/>
130131

131132
{/* divider */}
132-
<Or />
133+
{/* <Or /> */}
133134

134135
{/* URI Generated so that user can revisit with the same options selected */}
135-
<GeneratedURI
136+
{/* <GeneratedURI
136137
selectedDeployment={selectedDeployment}
137138
selectedAction={selectedAction}
138139
namespace={namespace}
139140
option={option}
140141
generatedURI={generatedURI}
141142
setGeneratedURI={setGeneratedURI}
142143
mode={mode}
143-
/>
144+
/> */}
144145
</div>
145146
</div>
146147
);

src/Components/Command/Command.css

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/Components/Command/Command.jsx

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/Components/Command/GeneratedCommand.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
display: flex;
3636
flex-flow: row nowrap;
3737
justify-content: space-between;
38+
/* border: 1px solid white; */
3839
}

src/Components/Command/GeneratedCommand.jsx

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,57 @@
11
import { useState, useEffect } from 'react';
22

33
import CopyBtn from '../UI/CopyBtn';
4+
import CopyURLBtn from '../UI/CopyURLBtn';
45

56
import './GeneratedCommand.css';
67

78
export default function GeneratedCommand({
89
selectedDeployment,
910
selectedAction,
1011
command,
12+
generatedURI,
1113
mode
1214
}) {
13-
1415
const [commandCopied, setCommandCopied] = useState(false);
16+
const [urlCopied, setUrlCopied] = useState(false);
17+
18+
console.log("command copied: ", commandCopied);
19+
console.log("url copied: ", urlCopied);
1520

1621
const copyCommand = () => {
1722
navigator.clipboard.writeText(command);
1823
setCommandCopied(true);
24+
setUrlCopied(false);
1925
}
2026

27+
const copyUrl = () => {
28+
navigator.clipboard.writeText(generatedURI)
29+
setUrlCopied(true);
30+
setCommandCopied(false);
31+
}
32+
33+
console.log(copyUrl);
34+
2135
useEffect(() => {
2236
if (commandCopied) {
37+
setUrlCopied(false);
2338
setTimeout(() => {
2439
setCommandCopied(false);
2540
}, 3000);
2641
}
27-
}, [commandCopied, setCommandCopied]);
42+
43+
if (urlCopied) {
44+
setCommandCopied(false)
45+
setTimeout(() => {
46+
setUrlCopied(false);
47+
}, 3000);
48+
}
49+
}, [
50+
commandCopied,
51+
setCommandCopied,
52+
urlCopied,
53+
setUrlCopied
54+
]);
2855

2956
return (
3057
<div className="generated-command-container">
@@ -40,14 +67,23 @@ export default function GeneratedCommand({
4067
)}
4168
</div>
4269
<div className="btns-container">
43-
<p className={`copied-message ${commandCopied && "show"} ${mode === "dark" ? "dark" : "light"}`}>
44-
Command copied to clipboard.
70+
<p className={`copied-message ${(commandCopied || urlCopied) && "show"} ${mode === "dark" ? "dark" : "light"}`}>
71+
{urlCopied && <>URL copied to clipboard.</>}
72+
{commandCopied && <>Command copied to clipboard.</>}
4573
</p>
46-
<CopyBtn
47-
selectedAction={selectedAction}
48-
copyCommand={copyCommand}
49-
mode={mode}
50-
/>
74+
<div>
75+
<CopyBtn
76+
selectedAction={selectedAction}
77+
copyCommand={copyCommand}
78+
mode={mode}
79+
/>
80+
<CopyURLBtn
81+
selectedAction={selectedAction}
82+
copyUrl={copyUrl}
83+
mode={mode}
84+
/>
85+
</div>
86+
5187
</div>
5288
</div >
5389
)

src/Components/UI/CopyBtn.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import './CopyBtn.css';
33

44
export default function CopyBtn({ selectedAction, copyCommand, mode }) {
5+
console.log(copyCommand);
56
return (
67
<>
78
{selectedAction === "Function" ? (

src/Components/UI/CopyURLBtn.css

Whitespace-only changes.

src/Components/UI/CopyURLBtn.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// import "./CopyURLBtn.css"
2+
3+
export default function CopyURLBtn({ selectedAction, mode, copyUrl }) {
4+
return (
5+
<>
6+
{selectedAction === "Function" ? (
7+
<button
8+
className={`btn w-margin ${mode === "dark" ? "dark" : "light"}`}
9+
onClick={copyUrl}
10+
disabled
11+
>
12+
Copy as URL
13+
</button>
14+
) : (
15+
<button
16+
className={`btn w-margin ${mode === "dark" ? "dark" : "light"}`}
17+
onClick={copyUrl}
18+
>
19+
Copy as URL
20+
</button>
21+
)}
22+
</>
23+
)
24+
}

src/Components/UI/GeneratedURI.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ export default function GeneratedURI({
4848
readOnly
4949
/>
5050
<div className="copied-url-container">
51+
{/* turn into seperate component */}
5152
<p className={`copied-message ${copiedUrl && "show"} ${mode === "dark" ? "dark" : "light"}`}>
5253
URL copied to clipboard
5354
</p>
55+
56+
5457
<div className="btns-container-2">
5558
<GenerateLink
5659
deployment={selectedDeployment}

0 commit comments

Comments
 (0)