-
Notifications
You must be signed in to change notification settings - Fork 6
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
Popout changes #7
Open
ranashreyas
wants to merge
7
commits into
yuvipanda:main
Choose a base branch
from
ranashreyas:popout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ea48ce
popout changes
ranashreyas f696fff
pr changes
ranashreyas b7282b3
further changes, usage.md
ranashreyas dbe6c23
final changes
ranashreyas 8c0ef71
rebrand 1
ranashreyas 71a6224
further icon changes
ranashreyas 3da0c0e
minor change
ranashreyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,14 @@ import GitUrlParse from 'git-url-parse'; | |
|
||
import { useState } from 'react'; | ||
|
||
import { Button, Box, Text, Popover, Heading, ThemeProvider, TextInput } from '@primer/components'; | ||
import { CopyIcon } from '@primer/octicons-react'; | ||
import { Button, Box, Text, Popover, Heading, ThemeProvider, TextInput, SelectMenu, DropdownMenu, DropdownButton } from '@primer/components'; | ||
|
||
import { CopyIcon, TabExternalIcon } from '@primer/octicons-react'; | ||
|
||
import { AVAILABLE_APPS, generateRegularUrl } from './generator'; | ||
import { getPref, setPref } from './prefs'; | ||
|
||
function copyGeneratedUrl(hubUrl, app) { | ||
function copyGeneratedUrl(hubUrl, app, open) { | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const query = { active: true, currentWindow: true }; | ||
chrome.tabs.query(query, function (tabs) { | ||
const activeTab = tabs[0]; | ||
|
@@ -21,6 +22,9 @@ function copyGeneratedUrl(hubUrl, app) { | |
const repoUrl = `${parts.protocol}://${parts.source}/${parts.full_name}`; | ||
const url = generateRegularUrl(hubUrl, repoUrl, parts.ref, app, parts.name + '/' + parts.filepath); | ||
navigator.clipboard.writeText(url); | ||
if (open) { | ||
chrome.tabs.create({url: url}); | ||
} | ||
} | ||
}); | ||
} | ||
|
@@ -30,6 +34,8 @@ function Form() { | |
const [app, setApp] = useState(getPref('app', 'classic')); | ||
const [isValidHubUrl, setIsValidHubUrl] = useState(false); | ||
const [finishedCopying, setFinishedCopying] = useState(false); | ||
const [isDropdownOpen, setDropdownOpen] = useState(false); | ||
|
||
|
||
useEffect(() => { | ||
try { | ||
|
@@ -49,27 +55,77 @@ function Form() { | |
setPref('app', app); | ||
}, [app]) | ||
|
||
const menuItems = Object.entries(AVAILABLE_APPS).map(([name, value]) => ({ | ||
text: value.title, | ||
key: name | ||
})); | ||
|
||
const handleMenuChange = (item) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this is so small, I think this can just be inline. |
||
if (item) { | ||
setApp(item.key); | ||
} | ||
}; | ||
|
||
const changeOpenState = (item) => { | ||
if(isDropdownOpen == true){ | ||
document.getElementById("root").className = "normal"; | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
document.getElementById("popoutBody").className = "normal"; | ||
setDropdownOpen(false); | ||
} else { | ||
document.getElementById("root").className = "expanded"; | ||
document.getElementById("popoutBody").className = "expanded"; | ||
setDropdownOpen(true); | ||
} | ||
|
||
}; | ||
|
||
return <Box display="flex" flexDirection="column"> | ||
{/* https://datahub.berkeley.edu */} | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Heading sx={{ fontSize: 2, mb: 1 }}>JupyterHub URL</Heading> | ||
|
||
<TextInput value={hubUrl} onChange={(ev) => setHubUrl(ev.target.value)} placeholder="https://myjupyterhub.org" aria-label="JupyterHub URL" /> | ||
<TextInput | ||
value={hubUrl} | ||
onChange = { | ||
(ev) => setHubUrl(ev.target.value) | ||
} | ||
placeholder="https://myjupyterhub.org" | ||
aria-label="JupyterHub URL" | ||
sx={{ pt: 0.5, pb: 0.5 }} | ||
/> | ||
|
||
<Text color="danger.fg" sx={{ visibility: isValidHubUrl ? "hidden" : "visible" }}>Enter a valid URL</Text> | ||
|
||
<Heading sx={{ fontSize: 2, mb: 1, mt: 2 }}>Open in</Heading> | ||
<select className="form-select mb-1" onChange={(ev) => setApp(ev.target.value)} value={app}> | ||
{Object.entries(AVAILABLE_APPS).map(([name, value]) => { | ||
return <option key={name} value={name}>{value.title}</option> | ||
})}; | ||
</select> | ||
|
||
<Button disabled={!isValidHubUrl || finishedCopying} sx={{ mt: 2 }} onClick={() => { | ||
copyGeneratedUrl(hubUrl, app); | ||
// Flash a 'Copied!' message for 3 seconds after copying | ||
setFinishedCopying(true); | ||
setTimeout(() => setFinishedCopying(false), 3 * 1000) | ||
}}> | ||
<CopyIcon /> {finishedCopying ? "Copied!" : "Copy nbgitpuller link"} | ||
</Button> | ||
<Heading sx={{ fontSize: 2, mb: 1, mt: 3 }}>Open in</Heading> | ||
|
||
<DropdownMenu | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
items={menuItems} | ||
onChange={handleMenuChange} | ||
placeholder={AVAILABLE_APPS[app].title} // Display the value of 'name' or a placeholder | ||
open={isDropdownOpen} | ||
onOpenChange={changeOpenState} | ||
/> | ||
|
||
<div style={{ display: 'flex', gap: '8px', justifyContent: 'center' }}> | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<Button disabled={!isValidHubUrl || finishedCopying} sx={{ mt: 2}} onClick={() => { | ||
copyGeneratedUrl(hubUrl, app, true); | ||
}}> | ||
<TabExternalIcon /> Open in tab | ||
</Button> | ||
|
||
<Button disabled={!isValidHubUrl || finishedCopying} | ||
style={{ flexGrow: 1, backgroundColor: '#52c786', opacity: ((!isValidHubUrl || finishedCopying)?0.6:1), marginTop: '8px' }} | ||
ranashreyas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
onClick={() => { | ||
copyGeneratedUrl(hubUrl, app, false); | ||
// Flash a 'Copied!' message for 3 seconds after copying | ||
setFinishedCopying(true); | ||
setTimeout(() => setFinishedCopying(false), 3 * 1000) | ||
}}> | ||
<CopyIcon /> {finishedCopying ? "Copied!" : "Copy nbgitpuller link"} | ||
</Button> | ||
|
||
</div> | ||
|
||
</Box> | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
<html> | ||
<head> | ||
<title>NBGitPuller</title> | ||
<style> | ||
html { | ||
height: fit-content; | ||
} | ||
|
||
#root { | ||
width:370px; | ||
height:190px; | ||
} | ||
|
||
.normal{ | ||
height: 190px; | ||
} | ||
|
||
.expanded { | ||
height: 340px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="root" style="width:320px; height:200px;"></div> | ||
<body id="popoutBody" class="normal"> | ||
<div id="root" class="normal"></div> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a page on this repository instead? Chrome and firefox both review URLs used in here, and I think they may not be happy with this one :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google Docs is definitely better than notion! However, can you copy the contents into a markdown file in this repository (as part of this PR), and link to that instead?