add toast for selections we don't recognise (#6370)
* ad toast for selections we don't recognise * remove log
This commit is contained in:
@ -330,6 +330,13 @@ export const ModelingMachineProvider = ({
|
|||||||
}
|
}
|
||||||
if (setSelections.selectionType === 'singleCodeCursor') {
|
if (setSelections.selectionType === 'singleCodeCursor') {
|
||||||
if (!setSelections.selection && editorManager.isShiftDown) {
|
if (!setSelections.selection && editorManager.isShiftDown) {
|
||||||
|
// if the user is holding shift, but they didn't select anything
|
||||||
|
// don't nuke their other selections (frustrating to have one bad click ruin your
|
||||||
|
// whole selection)
|
||||||
|
selections = {
|
||||||
|
graphSelections: selectionRanges.graphSelections,
|
||||||
|
otherSelections: selectionRanges.otherSelections,
|
||||||
|
}
|
||||||
} else if (
|
} else if (
|
||||||
!setSelections.selection &&
|
!setSelections.selection &&
|
||||||
!editorManager.isShiftDown
|
!editorManager.isShiftDown
|
||||||
|
49
src/components/ToastUnsupportedSelection.tsx
Normal file
49
src/components/ToastUnsupportedSelection.tsx
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import toast from 'react-hot-toast'
|
||||||
|
|
||||||
|
import { openExternalBrowserIfDesktop } from '@src/lib/openWindow'
|
||||||
|
|
||||||
|
export function ToastUnsupportedSelection({
|
||||||
|
toastId,
|
||||||
|
}: {
|
||||||
|
toastId: string
|
||||||
|
}) {
|
||||||
|
const githubIssueUrl = 'https://github.com/KittyCAD/modeling-app/issues/6368'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="inset-0 z-50 grid place-content-center rounded bg-chalkboard-10 dark:bg-chalkboard-90 shadow-md p-3">
|
||||||
|
<section>
|
||||||
|
<p className="text-sm text-chalkboard-70 dark:text-chalkboard-30">
|
||||||
|
Some faces and edges are not currently selectable.{' '}
|
||||||
|
<a
|
||||||
|
href={githubIssueUrl}
|
||||||
|
onClick={openExternalBrowserIfDesktop(githubIssueUrl)}
|
||||||
|
className="underline"
|
||||||
|
>
|
||||||
|
The team is working on it
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a toast notification for when users try to select unsupported faces/edges
|
||||||
|
* @example
|
||||||
|
* // In your component or handler:
|
||||||
|
* import { showUnsupportedSelectionToast } from '@src/components/ToastUnsupportedSelection'
|
||||||
|
*
|
||||||
|
* // When user tries to select an unsupported face/edge
|
||||||
|
* showUnsupportedSelectionToast()
|
||||||
|
*/
|
||||||
|
export function showUnsupportedSelectionToast() {
|
||||||
|
const toastId = toast.custom(
|
||||||
|
(t) => <ToastUnsupportedSelection toastId={t.id} />,
|
||||||
|
{
|
||||||
|
duration: 4_000,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return toastId
|
||||||
|
}
|
@ -45,6 +45,7 @@ import {
|
|||||||
} from '@src/lib/utils'
|
} from '@src/lib/utils'
|
||||||
import { engineStreamActor } from '@src/machines/appMachine'
|
import { engineStreamActor } from '@src/machines/appMachine'
|
||||||
import type { ModelingMachineEvent } from '@src/machines/modelingMachine'
|
import type { ModelingMachineEvent } from '@src/machines/modelingMachine'
|
||||||
|
import { showUnsupportedSelectionToast } from '@src/components/ToastUnsupportedSelection'
|
||||||
|
|
||||||
export const X_AXIS_UUID = 'ad792545-7fd3-482a-a602-a93924e3055b'
|
export const X_AXIS_UUID = 'ad792545-7fd3-482a-a602-a93924e3055b'
|
||||||
export const Y_AXIS_UUID = '680fd157-266f-4b8a-984f-cdf46b8bdf01'
|
export const Y_AXIS_UUID = '680fd157-266f-4b8a-984f-cdf46b8bdf01'
|
||||||
@ -107,6 +108,18 @@ export async function getEventForSelectWithPoint({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _artifact = kclManager.artifactGraph.get(data.entity_id)
|
let _artifact = kclManager.artifactGraph.get(data.entity_id)
|
||||||
|
if (!_artifact) {
|
||||||
|
// if there's no artifact but there is a data.entity_id, it means we don't recognize the engine entity
|
||||||
|
// we should still return an empty singleCodeCursor to plug into the selection logic
|
||||||
|
// (i.e. if the user is holding shift they can keep selecting)
|
||||||
|
// but we should also put up a toast
|
||||||
|
// toast.error('some edges or faces are not currently selectable')
|
||||||
|
showUnsupportedSelectionToast()
|
||||||
|
return {
|
||||||
|
type: 'Set selection',
|
||||||
|
data: { selectionType: 'singleCodeCursor' },
|
||||||
|
}
|
||||||
|
}
|
||||||
const codeRefs = getCodeRefsByArtifactId(
|
const codeRefs = getCodeRefsByArtifactId(
|
||||||
data.entity_id,
|
data.entity_id,
|
||||||
kclManager.artifactGraph
|
kclManager.artifactGraph
|
||||||
|
Reference in New Issue
Block a user