Make projects watching code not run in web
This commit is contained in:
@ -22,9 +22,10 @@ import {
|
|||||||
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
import useStateMachineCommands from 'hooks/useStateMachineCommands'
|
import useStateMachineCommands from 'hooks/useStateMachineCommands'
|
||||||
import { projectsCommandBarConfig } from 'lib/commandBarConfigs/projectsCommandConfig'
|
import { projectsCommandBarConfig } from 'lib/commandBarConfigs/projectsCommandConfig'
|
||||||
|
import { isDesktop } from 'lib/isDesktop'
|
||||||
|
|
||||||
type MachineContext<T extends AnyStateMachine> = {
|
type MachineContext<T extends AnyStateMachine> = {
|
||||||
state: StateFrom<T>
|
state?: StateFrom<T>
|
||||||
send: Prop<Actor<T>, 'send'>
|
send: Prop<Actor<T>, 'send'>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +33,42 @@ export const ProjectsMachineContext = createContext(
|
|||||||
{} as MachineContext<typeof projectsMachine>
|
{} as MachineContext<typeof projectsMachine>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watches the project directory and provides project management-related commands,
|
||||||
|
* like "Create project", "Open project", "Delete project", etc.
|
||||||
|
*
|
||||||
|
* If in the future we implement full-fledge project management in the web version,
|
||||||
|
* we can unify these components but for now, we need this to be only for the desktop version.
|
||||||
|
*/
|
||||||
export const ProjectsContextProvider = ({
|
export const ProjectsContextProvider = ({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
|
}) => {
|
||||||
|
return isDesktop() ? (
|
||||||
|
<ProjectsContextDesktop>{children}</ProjectsContextDesktop>
|
||||||
|
) : (
|
||||||
|
<ProjectsContextWeb>{children}</ProjectsContextWeb>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<ProjectsMachineContext.Provider
|
||||||
|
value={{
|
||||||
|
state: undefined,
|
||||||
|
send: () => {},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ProjectsMachineContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const ProjectsContextDesktop = ({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
@ -54,10 +54,11 @@ export const projectsCommandBarConfig: StateMachineCommandSetConfig<
|
|||||||
icon: 'close',
|
icon: 'close',
|
||||||
description: 'Delete a project',
|
description: 'Delete a project',
|
||||||
needsReview: true,
|
needsReview: true,
|
||||||
reviewMessage: ({ argumentsToSubmit }) => CommandBarOverwriteWarning({
|
reviewMessage: ({ argumentsToSubmit }) =>
|
||||||
heading: 'Are you sure you want to delete?',
|
CommandBarOverwriteWarning({
|
||||||
message: `This will permanently delete the project "${argumentsToSubmit.name}" and all its contents.`,
|
heading: 'Are you sure you want to delete?',
|
||||||
}),
|
message: `This will permanently delete the project "${argumentsToSubmit.name}" and all its contents.`,
|
||||||
|
}),
|
||||||
args: {
|
args: {
|
||||||
name: {
|
name: {
|
||||||
inputType: 'options',
|
inputType: 'options',
|
||||||
|
@ -206,7 +206,7 @@ export const projectsMachine = setup({
|
|||||||
onDone: [
|
onDone: [
|
||||||
{
|
{
|
||||||
target: '#Home machine.Reading projects',
|
target: '#Home machine.Reading projects',
|
||||||
actions: ['toastSuccess', "navigateToProjectIfNeeded"],
|
actions: ['toastSuccess', 'navigateToProjectIfNeeded'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
onError: [
|
onError: [
|
||||||
|
Reference in New Issue
Block a user