2024-12-10 16:52:57 -05:00
|
|
|
import { APP_VERSION, getReleaseUrl } from 'routes/Settings'
|
2024-04-19 10:50:58 -04:00
|
|
|
import { CustomIcon } from 'components/CustomIcon'
|
|
|
|
import Tooltip from 'components/Tooltip'
|
2024-08-09 02:47:25 -04:00
|
|
|
import { PATHS } from 'lib/paths'
|
2024-04-19 10:50:58 -04:00
|
|
|
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'
|
2024-08-23 12:00:18 -04:00
|
|
|
import openWindow, { openExternalBrowserIfDesktop } from 'lib/openWindow'
|
2024-08-04 00:51:30 -04:00
|
|
|
import { NetworkMachineIndicator } from './NetworkMachineIndicator'
|
2024-09-04 08:35:40 -04:00
|
|
|
import { ModelStateIndicator } from './ModelStateIndicator'
|
2024-09-09 18:17:45 -04:00
|
|
|
import { reportRejection } from 'lib/trap'
|
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()
|
2024-10-25 19:28:10 -04:00
|
|
|
|
2024-04-19 10:50:58 -04:00
|
|
|
const linkOverrideClassName =
|
|
|
|
'!text-chalkboard-70 hover:!text-chalkboard-80 dark:!text-chalkboard-40 dark:hover:!text-chalkboard-30'
|
|
|
|
|
2024-09-09 18:17:45 -04:00
|
|
|
function reportbug(event: {
|
2024-08-16 07:15:42 -04:00
|
|
|
preventDefault: () => void
|
|
|
|
stopPropagation: () => void
|
|
|
|
}) {
|
2024-06-28 18:06:40 -07:00
|
|
|
event?.preventDefault()
|
2024-08-16 07:15:42 -04:00
|
|
|
event?.stopPropagation()
|
2024-06-28 18:06:40 -07:00
|
|
|
|
|
|
|
if (!coreDumpManager) {
|
|
|
|
// open default reporting option
|
2024-09-09 18:17:45 -04:00
|
|
|
openWindow(
|
|
|
|
'https://github.com/KittyCAD/modeling-app/issues/new/choose'
|
|
|
|
).catch(reportRejection)
|
2024-06-28 18:06:40 -07:00
|
|
|
} 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-09-09 18:17:45 -04:00
|
|
|
).catch(reportRejection)
|
2024-06-28 18:06:40 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-09-04 08:35:40 -04:00
|
|
|
{!location.pathname.startsWith(PATHS.HOME) && <ModelStateIndicator />}
|
2024-04-19 10:50:58 -04:00
|
|
|
<a
|
2024-12-10 16:52:57 -05:00
|
|
|
onClick={openExternalBrowserIfDesktop(getReleaseUrl())}
|
|
|
|
href={getReleaseUrl()}
|
2024-04-19 10:50:58 -04:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
className={'!no-underline font-mono text-xs ' + linkOverrideClassName}
|
|
|
|
>
|
2024-08-20 15:15:25 -07:00
|
|
|
v{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}`}
|
|
|
|
/>
|
2024-07-24 23:33:31 -04:00
|
|
|
<Tooltip position="top" contentClassName="text-xs">
|
|
|
|
Report a bug
|
|
|
|
</Tooltip>
|
2024-04-19 10:50:58 -04:00
|
|
|
</a>
|
2024-11-07 17:23:03 -05:00
|
|
|
<Link
|
|
|
|
to={
|
|
|
|
location.pathname.includes(PATHS.FILE)
|
|
|
|
? filePath + PATHS.TELEMETRY + '?tab=project'
|
|
|
|
: PATHS.HOME + PATHS.TELEMETRY
|
|
|
|
}
|
|
|
|
data-testid="telemetry-link"
|
|
|
|
>
|
|
|
|
<CustomIcon
|
|
|
|
name="stopwatch"
|
|
|
|
className={`w-5 h-5 ${linkOverrideClassName}`}
|
|
|
|
/>
|
|
|
|
<span className="sr-only">Telemetry</span>
|
|
|
|
<Tooltip position="top" contentClassName="text-xs">
|
|
|
|
Telemetry
|
|
|
|
</Tooltip>
|
|
|
|
</Link>
|
2024-04-19 10:50:58 -04:00
|
|
|
<Link
|
|
|
|
to={
|
2024-08-09 02:47:25 -04:00
|
|
|
location.pathname.includes(PATHS.FILE)
|
2024-08-16 07:15:42 -04:00
|
|
|
? filePath + PATHS.SETTINGS + '?tab=project'
|
2024-08-09 02:47:25 -04:00
|
|
|
: PATHS.HOME + PATHS.SETTINGS
|
2024-04-19 10:50:58 -04:00
|
|
|
}
|
2024-08-21 15:02:54 +10:00
|
|
|
data-testid="settings-link"
|
2024-04-19 10:50:58 -04:00
|
|
|
>
|
|
|
|
<CustomIcon
|
|
|
|
name="settings"
|
|
|
|
className={`w-5 h-5 ${linkOverrideClassName}`}
|
|
|
|
/>
|
2024-07-24 23:33:31 -04:00
|
|
|
<span className="sr-only">Settings</span>
|
|
|
|
<Tooltip position="top" contentClassName="text-xs">
|
|
|
|
Settings
|
|
|
|
</Tooltip>
|
2024-04-19 10:50:58 -04:00
|
|
|
</Link>
|
2024-08-04 00:51:30 -04:00
|
|
|
<NetworkMachineIndicator className={linkOverrideClassName} />
|
2024-08-19 08:58:24 -04:00
|
|
|
{!location.pathname.startsWith(PATHS.HOME) && (
|
|
|
|
<NetworkHealthIndicator />
|
|
|
|
)}
|
2024-04-19 10:50:58 -04:00
|
|
|
<HelpMenu />
|
|
|
|
</menu>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|