Rename *GlobalState* to *SettingsAuth* (#1689)
This commit is contained in:
@ -22,7 +22,7 @@ import { getNormalisedCoordinates } from './lib/utils'
|
|||||||
import { useLoaderData, useNavigate } from 'react-router-dom'
|
import { useLoaderData, useNavigate } from 'react-router-dom'
|
||||||
import { type IndexLoaderData } from 'lib/types'
|
import { type IndexLoaderData } from 'lib/types'
|
||||||
import { paths } from 'lib/paths'
|
import { paths } from 'lib/paths'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { onboardingPaths } from 'routes/Onboarding/paths'
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
||||||
import { CodeMenu } from 'components/CodeMenu'
|
import { CodeMenu } from 'components/CodeMenu'
|
||||||
import { TextEditor } from 'components/TextEditor'
|
import { TextEditor } from 'components/TextEditor'
|
||||||
@ -53,7 +53,7 @@ export function App() {
|
|||||||
streamDimensions: s.streamDimensions,
|
streamDimensions: s.streamDimensions,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const { settings } = useGlobalStateContext()
|
const { settings } = useSettingsAuthContext()
|
||||||
const { showDebugPanel, onboardingStatus, theme } = settings?.context || {}
|
const { showDebugPanel, onboardingStatus, theme } = settings?.context || {}
|
||||||
const { state, send } = useModelingContext()
|
const { state, send } = useModelingContext()
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Loading from './components/Loading'
|
import Loading from './components/Loading'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
|
|
||||||
// Wrapper around protected routes, used in src/Router.tsx
|
// Wrapper around protected routes, used in src/Router.tsx
|
||||||
export const Auth = ({ children }: React.PropsWithChildren) => {
|
export const Auth = ({ children }: React.PropsWithChildren) => {
|
||||||
const { auth } = useGlobalStateContext()
|
const { auth } = useSettingsAuthContext()
|
||||||
const isLoggingIn = auth?.state.matches('checkIfLoggedIn')
|
const isLoggingIn = auth?.state.matches('checkIfLoggedIn')
|
||||||
|
|
||||||
return isLoggingIn ? (
|
return isLoggingIn ? (
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
import { metadata } from 'tauri-plugin-fs-extra-api'
|
import { metadata } from 'tauri-plugin-fs-extra-api'
|
||||||
import DownloadAppBanner from './components/DownloadAppBanner'
|
import DownloadAppBanner from './components/DownloadAppBanner'
|
||||||
import { WasmErrBanner } from './components/WasmErrBanner'
|
import { WasmErrBanner } from './components/WasmErrBanner'
|
||||||
import { GlobalStateProvider } from './components/GlobalStateProvider'
|
import { SettingsAuthProvider } from './components/SettingsAuthProvider'
|
||||||
import {
|
import {
|
||||||
SETTINGS_PERSIST_KEY,
|
SETTINGS_PERSIST_KEY,
|
||||||
settingsMachine,
|
settingsMachine,
|
||||||
@ -52,7 +52,7 @@ const addGlobalContextToElements = (
|
|||||||
...route,
|
...route,
|
||||||
element: (
|
element: (
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
<GlobalStateProvider>{route.element}</GlobalStateProvider>
|
<SettingsAuthProvider>{route.element}</SettingsAuthProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { useRef, useEffect, useState } from 'react'
|
|||||||
import { useModelingContext } from 'hooks/useModelingContext'
|
import { useModelingContext } from 'hooks/useModelingContext'
|
||||||
|
|
||||||
import { cameraMouseDragGuards } from 'lib/cameraControls'
|
import { cameraMouseDragGuards } from 'lib/cameraControls'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { useStore } from 'useStore'
|
import { useStore } from 'useStore'
|
||||||
import { DEBUG_SHOW_BOTH_SCENES, sceneInfra } from './sceneInfra'
|
import { DEBUG_SHOW_BOTH_SCENES, sceneInfra } from './sceneInfra'
|
||||||
import { ReactCameraProperties } from './CameraControls'
|
import { ReactCameraProperties } from './CameraControls'
|
||||||
@ -35,7 +35,7 @@ export const ClientSideScene = ({
|
|||||||
cameraControls,
|
cameraControls,
|
||||||
}: {
|
}: {
|
||||||
cameraControls: ReturnType<
|
cameraControls: ReturnType<
|
||||||
typeof useGlobalStateContext
|
typeof useSettingsAuthContext
|
||||||
>['settings']['context']['cameraControls']
|
>['settings']['context']['cameraControls']
|
||||||
}) => {
|
}) => {
|
||||||
const canvasRef = useRef<HTMLDivElement>(null)
|
const canvasRef = useRef<HTMLDivElement>(null)
|
||||||
|
@ -2,7 +2,7 @@ import { Toolbar } from '../Toolbar'
|
|||||||
import UserSidebarMenu from './UserSidebarMenu'
|
import UserSidebarMenu from './UserSidebarMenu'
|
||||||
import { type IndexLoaderData } from 'lib/types'
|
import { type IndexLoaderData } from 'lib/types'
|
||||||
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import styles from './AppHeader.module.css'
|
import styles from './AppHeader.module.css'
|
||||||
import { NetworkHealthIndicator } from './NetworkHealthIndicator'
|
import { NetworkHealthIndicator } from './NetworkHealthIndicator'
|
||||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||||
@ -25,7 +25,7 @@ export const AppHeader = ({
|
|||||||
}: AppHeaderProps) => {
|
}: AppHeaderProps) => {
|
||||||
const platform = usePlatform()
|
const platform = usePlatform()
|
||||||
const { commandBarSend } = useCommandsContext()
|
const { commandBarSend } = useCommandsContext()
|
||||||
const { auth } = useGlobalStateContext()
|
const { auth } = useSettingsAuthContext()
|
||||||
const user = auth?.context?.user
|
const user = auth?.context?.user
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -2,7 +2,7 @@ import { Completion } from '@codemirror/autocomplete'
|
|||||||
import { EditorState, EditorView, useCodeMirror } from '@uiw/react-codemirror'
|
import { EditorState, EditorView, useCodeMirror } from '@uiw/react-codemirror'
|
||||||
import { CustomIcon } from 'components/CustomIcon'
|
import { CustomIcon } from 'components/CustomIcon'
|
||||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { CommandArgument, KclCommandValue } from 'lib/commandTypes'
|
import { CommandArgument, KclCommandValue } from 'lib/commandTypes'
|
||||||
import { getSystemTheme } from 'lib/theme'
|
import { getSystemTheme } from 'lib/theme'
|
||||||
import { useCalculateKclExpression } from 'lib/useCalculateKclExpression'
|
import { useCalculateKclExpression } from 'lib/useCalculateKclExpression'
|
||||||
@ -29,7 +29,7 @@ function CommandBarKclInput({
|
|||||||
const previouslySetValue = commandBarState.context.argumentsToSubmit[
|
const previouslySetValue = commandBarState.context.argumentsToSubmit[
|
||||||
arg.name
|
arg.name
|
||||||
] as KclCommandValue | undefined
|
] as KclCommandValue | undefined
|
||||||
const { settings } = useGlobalStateContext()
|
const { settings } = useSettingsAuthContext()
|
||||||
const defaultValue = (arg.defaultValue as string) || ''
|
const defaultValue = (arg.defaultValue as string) || ''
|
||||||
const [value, setValue] = useState(
|
const [value, setValue] = useState(
|
||||||
previouslySetValue?.valueText || defaultValue || ''
|
previouslySetValue?.valueText || defaultValue || ''
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from 'xstate'
|
} from 'xstate'
|
||||||
import { SetSelections, modelingMachine } from 'machines/modelingMachine'
|
import { SetSelections, modelingMachine } from 'machines/modelingMachine'
|
||||||
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { isCursorInSketchCommandRange } from 'lang/util'
|
import { isCursorInSketchCommandRange } from 'lang/util'
|
||||||
import { engineCommandManager } from 'lang/std/engineConnection'
|
import { engineCommandManager } from 'lang/std/engineConnection'
|
||||||
import { kclManager, useKclContext } from 'lang/KclSingleton'
|
import { kclManager, useKclContext } from 'lang/KclSingleton'
|
||||||
@ -63,7 +63,7 @@ export const ModelingMachineProvider = ({
|
|||||||
settings: {
|
settings: {
|
||||||
context: { baseUnit },
|
context: { baseUnit },
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
const { code } = useKclContext()
|
const { code } = useKclContext()
|
||||||
const token = auth?.context?.token
|
const token = auth?.context?.token
|
||||||
const streamRef = useRef<HTMLDivElement>(null)
|
const streamRef = useRef<HTMLDivElement>(null)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { fireEvent, render, screen } from '@testing-library/react'
|
import { fireEvent, render, screen } from '@testing-library/react'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
import { GlobalStateProvider } from './GlobalStateProvider'
|
import { SettingsAuthProvider } from './SettingsAuthProvider'
|
||||||
import CommandBarProvider from './CommandBar/CommandBar'
|
import CommandBarProvider from './CommandBar/CommandBar'
|
||||||
import {
|
import {
|
||||||
NETWORK_HEALTH_TEXT,
|
NETWORK_HEALTH_TEXT,
|
||||||
@ -13,7 +13,7 @@ function TestWrap({ children }: { children: React.ReactNode }) {
|
|||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
<GlobalStateProvider>{children}</GlobalStateProvider>
|
<SettingsAuthProvider>{children}</SettingsAuthProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react'
|
|||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
||||||
import { type ProjectWithEntryPointMetadata } from 'lib/types'
|
import { type ProjectWithEntryPointMetadata } from 'lib/types'
|
||||||
import { GlobalStateProvider } from './GlobalStateProvider'
|
import { SettingsAuthProvider } from './SettingsAuthProvider'
|
||||||
import { APP_NAME } from 'lib/constants'
|
import { APP_NAME } from 'lib/constants'
|
||||||
import { vi } from 'vitest'
|
import { vi } from 'vitest'
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders the project name', () => {
|
test('Renders the project name', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<GlobalStateProvider>
|
<SettingsAuthProvider>
|
||||||
<ProjectSidebarMenu project={projectWellFormed} />
|
<ProjectSidebarMenu project={projectWellFormed} />
|
||||||
</GlobalStateProvider>
|
</SettingsAuthProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders app name if given no project', () => {
|
test('Renders app name if given no project', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<GlobalStateProvider>
|
<SettingsAuthProvider>
|
||||||
<ProjectSidebarMenu />
|
<ProjectSidebarMenu />
|
||||||
</GlobalStateProvider>
|
</SettingsAuthProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,9 +74,9 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders as a link if set to do so', () => {
|
test('Renders as a link if set to do so', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<GlobalStateProvider>
|
<SettingsAuthProvider>
|
||||||
<ProjectSidebarMenu project={projectWellFormed} renderAsLink={true} />
|
<ProjectSidebarMenu project={projectWellFormed} renderAsLink={true} />
|
||||||
</GlobalStateProvider>
|
</SettingsAuthProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ type GlobalContext = {
|
|||||||
let settingsStateRef: (typeof settingsMachine)['context'] | undefined
|
let settingsStateRef: (typeof settingsMachine)['context'] | undefined
|
||||||
export const getSettingsState = () => settingsStateRef
|
export const getSettingsState = () => settingsStateRef
|
||||||
|
|
||||||
export const GlobalStateContext = createContext({} as GlobalContext)
|
export const SettingsAuthContext = createContext({} as GlobalContext)
|
||||||
|
|
||||||
export const GlobalStateProvider = ({
|
export const SettingsAuthProvider = ({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
@ -133,7 +133,7 @@ export const GlobalStateProvider = ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GlobalStateContext.Provider
|
<SettingsAuthContext.Provider
|
||||||
value={{
|
value={{
|
||||||
auth: {
|
auth: {
|
||||||
state: authState,
|
state: authState,
|
||||||
@ -148,11 +148,11 @@ export const GlobalStateProvider = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</GlobalStateContext.Provider>
|
</SettingsAuthContext.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GlobalStateProvider
|
export default SettingsAuthProvider
|
||||||
|
|
||||||
export function logout() {
|
export function logout() {
|
||||||
localStorage.removeItem(TOKEN_PERSIST_KEY)
|
localStorage.removeItem(TOKEN_PERSIST_KEY)
|
@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'
|
|||||||
import { useStore } from '../useStore'
|
import { useStore } from '../useStore'
|
||||||
import { getNormalisedCoordinates } from '../lib/utils'
|
import { getNormalisedCoordinates } from '../lib/utils'
|
||||||
import Loading from './Loading'
|
import Loading from './Loading'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { engineCommandManager } from '../lang/std/engineConnection'
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
import { useModelingContext } from 'hooks/useModelingContext'
|
import { useModelingContext } from 'hooks/useModelingContext'
|
||||||
@ -28,7 +28,7 @@ export const Stream = ({ className = '' }: { className?: string }) => {
|
|||||||
setDidDragInStream: s.setDidDragInStream,
|
setDidDragInStream: s.setDidDragInStream,
|
||||||
streamDimensions: s.streamDimensions,
|
streamDimensions: s.streamDimensions,
|
||||||
}))
|
}))
|
||||||
const { settings } = useGlobalStateContext()
|
const { settings } = useSettingsAuthContext()
|
||||||
const { state } = useModelingContext()
|
const { state } = useModelingContext()
|
||||||
const { isExecuting } = useKclContext()
|
const { isExecuting } = useKclContext()
|
||||||
const { overallState } = useNetworkStatus()
|
const { overallState } = useNetworkStatus()
|
||||||
|
@ -9,7 +9,7 @@ import Server from '../editor/plugins/lsp/server'
|
|||||||
import Client from '../editor/plugins/lsp/client'
|
import Client from '../editor/plugins/lsp/client'
|
||||||
import { TEST } from 'env'
|
import { TEST } from 'env'
|
||||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { useConvertToVariable } from 'hooks/useToolbarGuards'
|
import { useConvertToVariable } from 'hooks/useToolbarGuards'
|
||||||
import { Themes } from 'lib/theme'
|
import { Themes } from 'lib/theme'
|
||||||
import { useEffect, useMemo, useRef } from 'react'
|
import { useEffect, useMemo, useRef } from 'react'
|
||||||
@ -108,7 +108,7 @@ export const TextEditor = ({
|
|||||||
state,
|
state,
|
||||||
} = useModelingContext()
|
} = useModelingContext()
|
||||||
|
|
||||||
const { settings, auth } = useGlobalStateContext()
|
const { settings, auth } = useSettingsAuthContext()
|
||||||
const textWrapping = settings.context?.textWrapping ?? 'On'
|
const textWrapping = settings.context?.textWrapping ?? 'On'
|
||||||
const { commandBarSend } = useCommandsContext()
|
const { commandBarSend } = useCommandsContext()
|
||||||
const {
|
const {
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
createRoutesFromElements,
|
createRoutesFromElements,
|
||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { GlobalStateProvider } from './GlobalStateProvider'
|
import { SettingsAuthProvider } from './SettingsAuthProvider'
|
||||||
import CommandBarProvider from './CommandBar/CommandBar'
|
import CommandBarProvider from './CommandBar/CommandBar'
|
||||||
|
|
||||||
type User = Models['User_type']
|
type User = Models['User_type']
|
||||||
@ -113,7 +113,7 @@ function TestWrap({ children }: { children: React.ReactNode }) {
|
|||||||
path="/file/:id"
|
path="/file/:id"
|
||||||
element={
|
element={
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
<GlobalStateProvider>{children}</GlobalStateProvider>
|
<SettingsAuthProvider>{children}</SettingsAuthProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -6,7 +6,7 @@ import { useLocation, useNavigate } from 'react-router-dom'
|
|||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { paths } from 'lib/paths'
|
import { paths } from 'lib/paths'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
||||||
|
|
||||||
type User = Models['User_type']
|
type User = Models['User_type']
|
||||||
@ -17,7 +17,7 @@ const UserSidebarMenu = ({ user }: { user?: User }) => {
|
|||||||
const displayedName = getDisplayName(user)
|
const displayedName = getDisplayName(user)
|
||||||
const [imageLoadFailed, setImageLoadFailed] = useState(false)
|
const [imageLoadFailed, setImageLoadFailed] = useState(false)
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const send = useGlobalStateContext()?.auth?.send
|
const send = useSettingsAuthContext()?.auth?.send
|
||||||
|
|
||||||
// Fallback logic for displaying user's "name":
|
// Fallback logic for displaying user's "name":
|
||||||
// 1. user.name
|
// 1. user.name
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import { GlobalStateContext } from 'components/GlobalStateProvider'
|
|
||||||
import { useContext } from 'react'
|
|
||||||
|
|
||||||
export const useGlobalStateContext = () => {
|
|
||||||
return useContext(GlobalStateContext)
|
|
||||||
}
|
|
6
src/hooks/useSettingsAuthContext.ts
Normal file
6
src/hooks/useSettingsAuthContext.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { SettingsAuthContext } from 'components/SettingsAuthProvider'
|
||||||
|
import { useContext } from 'react'
|
||||||
|
|
||||||
|
export const useSettingsAuthContext = () => {
|
||||||
|
return useContext(SettingsAuthContext)
|
||||||
|
}
|
@ -136,7 +136,7 @@ export const executor = async (
|
|||||||
return _programMemory
|
return _programMemory
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSettingsState = import('components/GlobalStateProvider').then(
|
const getSettingsState = import('components/SettingsAuthProvider').then(
|
||||||
(module) => module.getSettingsState
|
(module) => module.getSettingsState
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import {
|
|||||||
getSortIcon,
|
getSortIcon,
|
||||||
} from '../lib/sorting'
|
} from '../lib/sorting'
|
||||||
import useStateMachineCommands from '../hooks/useStateMachineCommands'
|
import useStateMachineCommands from '../hooks/useStateMachineCommands'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||||
import { DEFAULT_PROJECT_NAME } from 'machines/settingsMachine'
|
import { DEFAULT_PROJECT_NAME } from 'machines/settingsMachine'
|
||||||
import { sep } from '@tauri-apps/api/path'
|
import { sep } from '@tauri-apps/api/path'
|
||||||
@ -50,7 +50,7 @@ const Home = () => {
|
|||||||
context: { defaultDirectory, defaultProjectName },
|
context: { defaultDirectory, defaultProjectName },
|
||||||
send: sendToSettings,
|
send: sendToSettings,
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
// Set the default directory if it's been updated
|
// Set the default directory if it's been updated
|
||||||
// during the loading of the home page. This is wrapped
|
// during the loading of the home page. This is wrapped
|
||||||
|
@ -2,7 +2,7 @@ import { OnboardingButtons, useDismiss, useNextClick } from '.'
|
|||||||
import { onboardingPaths } from 'routes/Onboarding/paths'
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
||||||
import { useStore } from '../../useStore'
|
import { useStore } from '../../useStore'
|
||||||
import { SettingsSection } from 'routes/Settings'
|
import { SettingsSection } from 'routes/Settings'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import {
|
import {
|
||||||
CameraSystem,
|
CameraSystem,
|
||||||
cameraMouseDragGuards,
|
cameraMouseDragGuards,
|
||||||
@ -22,7 +22,7 @@ export default function Units() {
|
|||||||
context: { cameraControls },
|
context: { cameraControls },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-50 grid items-end justify-start px-4 pointer-events-none">
|
<div className="fixed inset-0 z-50 grid items-end justify-start px-4 pointer-events-none">
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
useNextClick,
|
useNextClick,
|
||||||
} from '.'
|
} from '.'
|
||||||
import { onboardingPaths } from 'routes/Onboarding/paths'
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { Themes, getSystemTheme } from 'lib/theme'
|
import { Themes, getSystemTheme } from 'lib/theme'
|
||||||
import { bracket } from 'lib/exampleKcl'
|
import { bracket } from 'lib/exampleKcl'
|
||||||
import {
|
import {
|
||||||
@ -31,7 +31,7 @@ function OnboardingWithNewFile() {
|
|||||||
settings: {
|
settings: {
|
||||||
context: { defaultDirectory },
|
context: { defaultDirectory },
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
async function createAndOpenNewProject() {
|
async function createAndOpenNewProject() {
|
||||||
const projects = await getProjectsInDir(defaultDirectory)
|
const projects = await getProjectsInDir(defaultDirectory)
|
||||||
@ -111,7 +111,7 @@ export default function Introduction() {
|
|||||||
context: { theme },
|
context: { theme },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
const getLogoTheme = () =>
|
const getLogoTheme = () =>
|
||||||
theme === Themes.Light ||
|
theme === Themes.Light ||
|
||||||
(theme === Themes.System && getSystemTheme() === Themes.Light)
|
(theme === Themes.System && getSystemTheme() === Themes.Light)
|
||||||
|
@ -3,7 +3,7 @@ import { onboardingPaths } from 'routes/Onboarding/paths'
|
|||||||
import { useStore } from '../../useStore'
|
import { useStore } from '../../useStore'
|
||||||
import { useBackdropHighlight } from 'hooks/useBackdropHighlight'
|
import { useBackdropHighlight } from 'hooks/useBackdropHighlight'
|
||||||
import { Themes, getSystemTheme } from 'lib/theme'
|
import { Themes, getSystemTheme } from 'lib/theme'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
|
|
||||||
export default function ParametricModeling() {
|
export default function ParametricModeling() {
|
||||||
const { buttonDownInStream } = useStore((s) => ({
|
const { buttonDownInStream } = useStore((s) => ({
|
||||||
@ -13,7 +13,7 @@ export default function ParametricModeling() {
|
|||||||
settings: {
|
settings: {
|
||||||
context: { theme },
|
context: { theme },
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
const getImageTheme = () =>
|
const getImageTheme = () =>
|
||||||
theme === Themes.Light ||
|
theme === Themes.Light ||
|
||||||
(theme === Themes.System && getSystemTheme() === Themes.Light)
|
(theme === Themes.System && getSystemTheme() === Themes.Light)
|
||||||
|
@ -5,7 +5,7 @@ import { SettingsSection } from '../Settings'
|
|||||||
import { Toggle } from '../../components/Toggle/Toggle'
|
import { Toggle } from '../../components/Toggle/Toggle'
|
||||||
import { useDismiss, useNextClick } from '.'
|
import { useDismiss, useNextClick } from '.'
|
||||||
import { onboardingPaths } from 'routes/Onboarding/paths'
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { UnitSystem } from 'machines/settingsMachine'
|
import { UnitSystem } from 'machines/settingsMachine'
|
||||||
|
|
||||||
export default function Units() {
|
export default function Units() {
|
||||||
@ -16,7 +16,7 @@ export default function Units() {
|
|||||||
send,
|
send,
|
||||||
context: { unitSystem, baseUnit },
|
context: { unitSystem, baseUnit },
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed grid place-content-center inset-0 bg-chalkboard-110/50 z-50">
|
<div className="fixed grid place-content-center inset-0 bg-chalkboard-110/50 z-50">
|
||||||
|
@ -5,7 +5,7 @@ import Camera from './Camera'
|
|||||||
import Sketching from './Sketching'
|
import Sketching from './Sketching'
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
import makeUrlPathRelative from '../../lib/makeUrlPathRelative'
|
import makeUrlPathRelative from '../../lib/makeUrlPathRelative'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import Streaming from './Streaming'
|
import Streaming from './Streaming'
|
||||||
import CodeEditor from './CodeEditor'
|
import CodeEditor from './CodeEditor'
|
||||||
import ParametricModeling from './ParametricModeling'
|
import ParametricModeling from './ParametricModeling'
|
||||||
@ -80,7 +80,7 @@ export function useNextClick(newStatus: string) {
|
|||||||
const filePath = useAbsoluteFilePath()
|
const filePath = useAbsoluteFilePath()
|
||||||
const {
|
const {
|
||||||
settings: { send },
|
settings: { send },
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
return useCallback(() => {
|
return useCallback(() => {
|
||||||
@ -96,7 +96,7 @@ export function useDismiss() {
|
|||||||
const filePath = useAbsoluteFilePath()
|
const filePath = useAbsoluteFilePath()
|
||||||
const {
|
const {
|
||||||
settings: { send },
|
settings: { send },
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
return useCallback(() => {
|
return useCallback(() => {
|
||||||
|
@ -13,7 +13,7 @@ import { useHotkeys } from 'react-hotkeys-hook'
|
|||||||
import { type IndexLoaderData } from 'lib/types'
|
import { type IndexLoaderData } from 'lib/types'
|
||||||
import { paths } from 'lib/paths'
|
import { paths } from 'lib/paths'
|
||||||
import { Themes } from '../lib/theme'
|
import { Themes } from '../lib/theme'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import {
|
import {
|
||||||
CameraSystem,
|
CameraSystem,
|
||||||
cameraSystems,
|
cameraSystems,
|
||||||
@ -55,7 +55,7 @@ export const Settings = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
async function handleDirectorySelection() {
|
async function handleDirectorySelection() {
|
||||||
const newDirectory = await open({
|
const newDirectory = await open({
|
||||||
|
@ -4,7 +4,7 @@ import { invoke } from '@tauri-apps/api/tauri'
|
|||||||
import { VITE_KC_SITE_BASE_URL, VITE_KC_API_BASE_URL } from '../env'
|
import { VITE_KC_SITE_BASE_URL, VITE_KC_API_BASE_URL } from '../env'
|
||||||
import { Themes, getSystemTheme } from '../lib/theme'
|
import { Themes, getSystemTheme } from '../lib/theme'
|
||||||
import { paths } from 'lib/paths'
|
import { paths } from 'lib/paths'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import { APP_NAME } from 'lib/constants'
|
import { APP_NAME } from 'lib/constants'
|
||||||
|
|
||||||
const SignIn = () => {
|
const SignIn = () => {
|
||||||
@ -20,7 +20,7 @@ const SignIn = () => {
|
|||||||
context: { theme },
|
context: { theme },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useSettingsAuthContext()
|
||||||
|
|
||||||
const signInTauri = async () => {
|
const signInTauri = async () => {
|
||||||
// We want to invoke our command to login via device auth.
|
// We want to invoke our command to login via device auth.
|
||||||
|
Reference in New Issue
Block a user