-
Notifications
You must be signed in to change notification settings - Fork 254
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
Install npm packages after plan ran. External link option #410
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
CircleAlertIcon, | ||
PanelBottomOpenIcon, | ||
PanelBottomCloseIcon, | ||
ExternalLinkIcon, | ||
} from 'lucide-react'; | ||
import { Link } from 'react-router-dom'; | ||
import { SrcbookLogo } from '@/components/logos'; | ||
|
@@ -46,7 +47,7 @@ type PropsType = { | |
|
||
export default function EditorHeader(props: PropsType) { | ||
const { app, updateApp } = useApp(); | ||
const { start: startPreview, stop: stopPreview, status: previewStatus } = usePreview(); | ||
const { url, start: startPreview, stop: stopPreview, status: previewStatus } = usePreview(); | ||
const { status: npmInstallStatus, nodeModulesExists } = usePackageJson(); | ||
const [isExporting, setIsExporting] = useState(false); | ||
const { open, togglePane, panelIcon } = useLogs(); | ||
|
@@ -170,25 +171,46 @@ export default function EditorHeader(props: PropsType) { | |
</TooltipProvider> | ||
) : null} | ||
{props.tab === 'preview' && previewStatus !== 'stopped' ? ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button | ||
variant="icon" | ||
size="icon" | ||
onClick={() => { | ||
stopPreview(); | ||
props.onChangeTab('code'); | ||
}} | ||
className="active:translate-y-0" | ||
disabled={previewStatus === 'booting' || previewStatus === 'connecting'} | ||
> | ||
<StopCircleIcon size={18} /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent>Stop dev server</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
<> | ||
{url && ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button | ||
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. This should be a link rather than a button with window.open |
||
variant="icon" | ||
size="icon" | ||
onClick={() => window.open(url as string, '_blank')} | ||
className="active:translate-y-0" | ||
disabled={previewStatus === 'booting' || previewStatus === 'connecting'} | ||
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. nit but probs better to do |
||
> | ||
<ExternalLinkIcon size={18} /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent>Open in new tab</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
)} | ||
|
||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button | ||
variant="icon" | ||
size="icon" | ||
onClick={() => { | ||
stopPreview(); | ||
props.onChangeTab('code'); | ||
}} | ||
className="active:translate-y-0" | ||
disabled={previewStatus === 'booting' || previewStatus === 'connecting'} | ||
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. same re: previewStatus !== running |
||
> | ||
<StopCircleIcon size={18} /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent>Stop dev server</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</> | ||
) : null} | ||
|
||
<div | ||
|
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.
.map().flat() can be expressed in one iteration using
flatMap()
.