2024-04-19 10:50:58 -04:00
|
|
|
import { APP_VERSION } from 'routes/Settings'
|
|
|
|
import { CustomIcon } from 'components/CustomIcon'
|
|
|
|
import Tooltip from 'components/Tooltip'
|
|
|
|
import { paths } from 'lib/paths'
|
|
|
|
import { NetworkHealthIndicator } from 'components/NetworkHealthIndicator'
|
|
|
|
import { HelpMenu } from './HelpMenu'
|
|
|
|
import { Link, useLocation } from 'react-router-dom'
|
|
|
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
2024-06-28 18:06:40 -07:00
|
|
|
import { coreDump } from 'lang/wasm'
|
|
|
|
import toast from 'react-hot-toast'
|
|
|
|
import { CoreDumpManager } from 'lib/coredump'
|
|
|
|
import openWindow from 'lib/openWindow'
|
2024-04-19 10:50:58 -04:00
|
|
|
|
2024-06-28 18:06:40 -07:00
|
|
|
export function LowerRightControls({
|
|
|
|
children,
|
|
|
|
coreDumpManager,
|
|
|
|
}: {
|
|
|
|
children?: React.ReactNode
|
|
|
|
coreDumpManager?: CoreDumpManager
|
|
|
|
}) {
|
2024-04-19 10:50:58 -04:00
|
|
|
const location = useLocation()
|
|
|
|
const filePath = useAbsoluteFilePath()
|
|
|
|
const linkOverrideClassName =
|
|
|
|
'!text-chalkboard-70 hover:!text-chalkboard-80 dark:!text-chalkboard-40 dark:hover:!text-chalkboard-30'
|
|
|
|
|
2024-05-24 21:59:51 +10:00
|
|
|
const isPlayWright = window?.localStorage.getItem('playwright') === 'true'
|
|
|
|
|
2024-06-28 18:06:40 -07:00
|
|
|
async function reportbug(event: { preventDefault: () => void }) {
|
|
|
|
event?.preventDefault()
|
|
|
|
|
|
|
|
if (!coreDumpManager) {
|
|
|
|
// open default reporting option
|
|
|
|
openWindow('https://github.com/KittyCAD/modeling-app/issues/new/choose')
|
|
|
|
} else {
|
|
|
|
toast
|
|
|
|
.promise(
|
|
|
|
coreDump(coreDumpManager, true),
|
|
|
|
{
|
|
|
|
loading: 'Preparing bug report...',
|
|
|
|
success: 'Bug report opened in new window',
|
|
|
|
error: 'Unable to export a core dump. Using default reporting.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
success: {
|
|
|
|
// Note: this extended duration is especially important for Playwright e2e testing
|
|
|
|
// default duration is 2000 - https://react-hot-toast.com/docs/toast#default-durations
|
|
|
|
duration: 6000,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.catch((err: Error) => {
|
|
|
|
if (err) {
|
|
|
|
openWindow(
|
|
|
|
'https://github.com/KittyCAD/modeling-app/issues/new/choose'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-19 10:50:58 -04:00
|
|
|
return (
|
2024-05-24 20:54:42 +10:00
|
|
|
<section className="fixed bottom-2 right-2 flex flex-col items-end gap-3 pointer-events-none">
|
2024-06-28 18:06:40 -07:00
|
|
|
{children}
|
2024-05-24 20:54:42 +10:00
|
|
|
<menu className="flex items-center justify-end gap-3 pointer-events-auto">
|
2024-04-19 10:50:58 -04:00
|
|
|
<a
|
|
|
|
href={`https://github.com/KittyCAD/modeling-app/releases/tag/v${APP_VERSION}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
className={'!no-underline font-mono text-xs ' + linkOverrideClassName}
|
|
|
|
>
|
2024-05-24 21:59:51 +10:00
|
|
|
v{isPlayWright ? '11.22.33' : APP_VERSION}
|
2024-04-19 10:50:58 -04:00
|
|
|
</a>
|
|
|
|
<a
|
2024-06-28 18:06:40 -07:00
|
|
|
onClick={reportbug}
|
2024-04-19 10:50:58 -04:00
|
|
|
href="https://github.com/KittyCAD/modeling-app/issues/new/choose"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<CustomIcon
|
2024-06-11 14:37:15 -04:00
|
|
|
name="bug"
|
2024-04-19 10:50:58 -04:00
|
|
|
className={`w-5 h-5 ${linkOverrideClassName}`}
|
|
|
|
/>
|
|
|
|
<Tooltip position="top">Report a bug</Tooltip>
|
|
|
|
</a>
|
|
|
|
<Link
|
|
|
|
to={
|
|
|
|
location.pathname.includes(paths.FILE)
|
|
|
|
? filePath + paths.SETTINGS
|
|
|
|
: paths.HOME + paths.SETTINGS
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<CustomIcon
|
|
|
|
name="settings"
|
|
|
|
className={`w-5 h-5 ${linkOverrideClassName}`}
|
|
|
|
/>
|
|
|
|
<Tooltip position="top">Settings</Tooltip>
|
|
|
|
</Link>
|
|
|
|
<NetworkHealthIndicator />
|
|
|
|
<HelpMenu />
|
|
|
|
</menu>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|