diff --git a/README.md b/README.md index 9ccb42bf..0db71dcf 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,4 @@ WARNING! This is not ready for use and is under heavy development of basic featu 1. Mechanisms aren't limited to init 2. Mechanisms aren't limited to only Robot or Mechanism class 3. No way to specify whether an opmode is auto or teleop +4. Since we changed the "Workspace" terminology to "Project", existing Workspaces are no longer supported. They can be deleted via the browser's Developer Tools - Application tab. diff --git a/src/App.tsx b/src/App.tsx index 41f38d9f..ac5d39ad 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,8 +27,8 @@ import { EditOutlined, FileAddOutlined as OpModeAddOutlined, FileOutlined as OpModeOutlined, - FolderAddOutlined as WorkspaceAddOutlined, - FolderOutlined as WorkspaceOutlined, + FolderAddOutlined as ProjectAddOutlined, + FolderOutlined as ProjectOutlined, SaveOutlined, SettingOutlined, UploadOutlined, @@ -60,31 +60,31 @@ import * as ChangeFramework from './blocks/utils/change_framework' import {mutatorOpenListener} from './blocks/mrc_class_method_def' -type NewWorkspaceNameModalProps = { +type NewProjectNameModalProps = { title: string; isOpen: boolean; initialValue: string; - getWorkspaceNames: () => string[]; + getProjectNames: () => string[]; onOk: (newName: string) => void; onCancel: () => void; } -const NewWorkspaceNameModal: React.FC = ({ title, isOpen, initialValue, getWorkspaceNames, onOk, onCancel }) => { +const NewProjectNameModal: React.FC = ({ title, isOpen, initialValue, getProjectNames, onOk, onCancel }) => { const inputRef = useRef(null); const [message, setMessage] = useState(''); const [value, setValue] = useState(''); - const [workspaceNames, setWorkspaceNames] = useState([]); + const [projectNames, setProjectNames] = useState([]); const [alertErrorMessage, setAlertErrorMessage] = useState(''); const [alertErrorVisible, setAlertErrorVisible] = useState(false); const afterOpenChange = (open: boolean) => { if (open) { setValue(initialValue); - const w = getWorkspaceNames(); + const w = getProjectNames(); if (w.length === 0) { - setMessage('Let\'s create your first workspace. You just need to give it a name.'); + setMessage('Let\'s create your first project. You just need to give it a name.'); } - setWorkspaceNames(w); + setProjectNames(w); if (inputRef.current) { inputRef.current.focus(); } @@ -100,8 +100,8 @@ const NewWorkspaceNameModal: React.FC = ({ title, is setAlertErrorVisible(true); return; } - if (workspaceNames.includes(value)) { - setAlertErrorMessage('There is already a workspace named ' + value); + if (projectNames.includes(value)) { + setAlertErrorMessage('There is already a project named ' + value); setAlertErrorVisible(true); return; } @@ -123,7 +123,7 @@ const NewWorkspaceNameModal: React.FC = ({ title, is {message} - Workspace Name + Project Name string; - getModuleNames: (workspaceName: string) => string[]; + getCurrentProjectName: () => string; + getModuleNames: (projectName: string) => string[]; onOk: (newName: string) => void; onCancel: () => void; } -const NewModuleNameModal: React.FC = ({ title, isOpen, initialValue, getCurrentWorkspaceName, getModuleNames, onOk, onCancel }) => { +const NewModuleNameModal: React.FC = ({ title, isOpen, initialValue, getCurrentProjectName, getModuleNames, onOk, onCancel }) => { const inputRef = useRef(null); const [value, setValue] = useState(''); - const [workspaceName, setWorkspaceName] = useState(''); + const [projectName, setProjectName] = useState(''); const [moduleNames, setModuleNames] = useState([]); const [alertErrorMessage, setAlertErrorMessage] = useState(''); const [alertErrorVisible, setAlertErrorVisible] = useState(false); @@ -165,9 +165,9 @@ const NewModuleNameModal: React.FC = ({ title, isOpen, const afterOpenChange = (open: boolean) => { if (open) { setValue(initialValue); - const currentWorkspaceName = getCurrentWorkspaceName(); - setWorkspaceName(currentWorkspaceName); - setModuleNames(getModuleNames(currentWorkspaceName)); + const currentProjectName = getCurrentProjectName(); + setProjectName(currentProjectName); + setModuleNames(getModuleNames(currentProjectName)); if (inputRef.current) { inputRef.current.focus(); } @@ -182,8 +182,8 @@ const NewModuleNameModal: React.FC = ({ title, isOpen, setAlertErrorVisible(true); return; } - if (workspaceName === value) { - setAlertErrorMessage('The workspace is already named ' + value); + if (projectName === value) { + setAlertErrorMessage('The project is already named ' + value); setAlertErrorVisible(true); return; } @@ -240,7 +240,7 @@ const App: React.FC = () => { const [shownPythonToolboxCategories, setShownPythonToolboxCategories] = useState>(new Set()); const [triggerListModules, setTriggerListModules] = useState(false); const afterListModulesSuccess = useRef<() => void>(() => {}); - const [modules, setModules] = useState([]); + const [modules, setModules] = useState([]); const [treeData, setTreeData] = useState([]); const [treeExpandedKeys, setTreeExpandedKeys] = useState([]); const [treeSelectedKey, setTreeSelectedKey] = useState(''); @@ -253,10 +253,10 @@ const App: React.FC = () => { const [triggerPythonRegeneration, setTriggerPythonRegeneration] = useState(false); const blocksEditor = useRef(null); const [generatedCode, setGeneratedCode] = useState(''); - const [newWorkspaceNameModalPurpose, setNewWorkspaceNameModalPurpose] = useState(''); - const [newWorkspaceNameModalInitialValue, setNewWorkspaceNameModalInitialValue] = useState(''); - const [newWorkspaceNameModalTitle, setNewWorkspaceNameModalTitle] = useState(''); - const [newWorkspaceNameModalIsOpen, setNewWorkspaceNameModalIsOpen] = useState(false); + const [newProjectNameModalPurpose, setNewProjectNameModalPurpose] = useState(''); + const [newProjectNameModalInitialValue, setNewProjectNameModalInitialValue] = useState(''); + const [newProjectNameModalTitle, setNewProjectNameModalTitle] = useState(''); + const [newProjectNameModalIsOpen, setNewProjectNameModalIsOpen] = useState(false); const [newModuleNameModalPurpose, setNewModuleNameModalPurpose] = useState(''); const [newModuleNameModalInitialValue, setNewModuleNameModalInitialValue] = useState(''); const [newModuleNameModalTitle, setNewModuleNameModalTitle] = useState(''); @@ -268,11 +268,11 @@ const App: React.FC = () => { const afterPopconfirmOk = useRef<() => void>(() => {}); const [popconfirmLoading, setPopconfirmLoading] = useState(false); - const PURPOSE_NEW_WORKSPACE = 'NewWorkspace'; + const PURPOSE_NEW_PROJECT = 'NewProject'; const PURPOSE_NEW_MECHANISM = 'NewMechanism'; const PURPOSE_NEW_OPMODE = 'NewOpMode'; - const PURPOSE_RENAME_WORKSPACE = 'RenameWorkspace'; - const PURPOSE_COPY_WORKSPACE = 'CopyWorkspace'; + const PURPOSE_RENAME_PROJECT = 'RenameProject'; + const PURPOSE_COPY_PROJECT = 'CopyProject'; const PURPOSE_RENAME_MODULE = 'RenameModule'; const PURPOSE_COPY_MODULE = 'CopyModule'; @@ -344,7 +344,7 @@ const App: React.FC = () => { return; } - storage.listModules((array: commonStorage.Workspace[] | null, errorMessage: string) => { + storage.listModules((array: commonStorage.Project[] | null, errorMessage: string) => { if (errorMessage) { setAlertErrorMessage('Unable to load the list of modules: ' + errorMessage); setAlertErrorVisible(true); @@ -357,10 +357,10 @@ const App: React.FC = () => { callback(); if (array.length === 0) { - setNewWorkspaceNameModalPurpose(PURPOSE_NEW_WORKSPACE); - setNewWorkspaceNameModalInitialValue(''); - setNewWorkspaceNameModalTitle('Welcome to WPILib Blocks!'); - setNewWorkspaceNameModalIsOpen(true); + setNewProjectNameModalPurpose(PURPOSE_NEW_PROJECT); + setNewProjectNameModalInitialValue(''); + setNewProjectNameModalTitle('Welcome to WPILib Blocks!'); + setNewProjectNameModalIsOpen(true); } } }); @@ -378,15 +378,15 @@ const App: React.FC = () => { let foundMostRecentModulePath = false; const data: TreeDataNode[] = []; const expandedKeys: React.Key[] = [] - modules.forEach((workspace) => { - if (workspace.modulePath === currentModulePath) { + modules.forEach((project) => { + if (project.modulePath === currentModulePath) { foundCurrentModulePath = true; } - if (workspace.modulePath === mostRecentModulePath) { + if (project.modulePath === mostRecentModulePath) { foundMostRecentModulePath = true; } const children: TreeDataNode[] = []; - workspace.mechanisms.forEach((mechanism) => { + project.mechanisms.forEach((mechanism) => { if (mechanism.modulePath === currentModulePath) { foundCurrentModulePath = true; } @@ -400,7 +400,7 @@ const App: React.FC = () => { }; children.push(child); }); - workspace.opModes.forEach((opMode) => { + project.opModes.forEach((opMode) => { if (opMode.modulePath === currentModulePath) { foundCurrentModulePath = true; } @@ -415,10 +415,10 @@ const App: React.FC = () => { children.push(child); }); const parent: TreeDataNode = { - key: workspace.modulePath, - title: workspace.workspaceName, + key: project.modulePath, + title: project.projectName, children: children, - icon: , + icon: , }; data.push(parent); expandedKeys.push(parent.key); @@ -451,10 +451,10 @@ const App: React.FC = () => { setCurrentModule(module); if (module != null) { - if (module.moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - setRenameTooltip('Rename Workspace'); - setCopyTooltip('Copy Workspace'); - setDeleteTooltip('Delete Workspace'); + if (module.moduleType == commonStorage.MODULE_TYPE_PROJECT) { + setRenameTooltip('Rename Project'); + setCopyTooltip('Copy Project'); + setDeleteTooltip('Delete Project'); } else if (module.moduleType == commonStorage.MODULE_TYPE_MECHANISM) { setRenameTooltip('Rename Mechanism'); setCopyTooltip('Copy Mechanism'); @@ -575,67 +575,67 @@ const App: React.FC = () => { } }; - const handleNewWorkspaceClicked = () => { + const handleNewProjectClicked = () => { checkIfBlocksWereModified(() => { - setNewWorkspaceNameModalPurpose(PURPOSE_NEW_WORKSPACE); - setNewWorkspaceNameModalInitialValue(''); - setNewWorkspaceNameModalTitle('New Workspace'); - setNewWorkspaceNameModalIsOpen(true); + setNewProjectNameModalPurpose(PURPOSE_NEW_PROJECT); + setNewProjectNameModalInitialValue(''); + setNewProjectNameModalTitle('New Project'); + setNewProjectNameModalIsOpen(true); }); }; - const getWorkspaceNames = (): string[] => { - const workspaceNames: string[] = []; - modules.forEach((workspace) => { - workspaceNames.push(workspace.workspaceName); + const getProjectNames = (): string[] => { + const projectNames: string[] = []; + modules.forEach((project) => { + projectNames.push(project.projectName); }); - return workspaceNames; + return projectNames; }; - const handleNewWorkspaceNameOk = (newWorkspaceName: string) => { - const newWorkspacePath = commonStorage.makeWorkspacePath(newWorkspaceName); - if (newWorkspaceNameModalPurpose === PURPOSE_NEW_WORKSPACE) { - const workspaceContent = commonStorage.newWorkspaceContent(newWorkspaceName); + const handleNewProjectNameOk = (newProjectName: string) => { + const newProjectPath = commonStorage.makeProjectPath(newProjectName); + if (newProjectNameModalPurpose === PURPOSE_NEW_PROJECT) { + const projectContent = commonStorage.newProjectContent(newProjectName); storage.createModule( - commonStorage.MODULE_TYPE_WORKSPACE, newWorkspacePath, workspaceContent, + commonStorage.MODULE_TYPE_PROJECT, newProjectPath, projectContent, (success: boolean, errorMessage: string) => { if (success) { afterListModulesSuccess.current = () => { - setCurrentModulePath(newWorkspacePath); + setCurrentModulePath(newProjectPath); }; setTriggerListModules(!triggerListModules); } else if (errorMessage) { - setAlertErrorMessage('Failed to create a new Workspace: ' + errorMessage); + setAlertErrorMessage('Failed to create a new Project: ' + errorMessage); setAlertErrorVisible(true); } }); - } else if (newWorkspaceNameModalPurpose === PURPOSE_RENAME_WORKSPACE) { + } else if (newProjectNameModalPurpose === PURPOSE_RENAME_PROJECT) { storage.renameModule( - currentModule.moduleType, currentModule.workspaceName, - currentModule.moduleName, newWorkspaceName, + currentModule.moduleType, currentModule.projectName, + currentModule.moduleName, newProjectName, (success: boolean, errorMessage: string) => { if (success) { afterListModulesSuccess.current = () => { - setCurrentModulePath(newWorkspacePath); + setCurrentModulePath(newProjectPath); }; setTriggerListModules(!triggerListModules); } else if (errorMessage) { - setAlertErrorMessage('Failed to rename the Workspace: ' + errorMessage); + setAlertErrorMessage('Failed to rename the Project: ' + errorMessage); setAlertErrorVisible(true); } }); - } else if (newWorkspaceNameModalPurpose === PURPOSE_COPY_WORKSPACE) { + } else if (newProjectNameModalPurpose === PURPOSE_COPY_PROJECT) { storage.copyModule( - currentModule.moduleType, currentModule.workspaceName, - currentModule.moduleName, newWorkspaceName, + currentModule.moduleType, currentModule.projectName, + currentModule.moduleName, newProjectName, (success: boolean, errorMessage: string) => { if (success) { afterListModulesSuccess.current = () => { - setCurrentModulePath(newWorkspacePath); + setCurrentModulePath(newProjectPath); }; setTriggerListModules(!triggerListModules); } else if (errorMessage) { - setAlertErrorMessage('Failed to copy the Workspace: ' + errorMessage); + setAlertErrorMessage('Failed to copy the Project: ' + errorMessage); setAlertErrorVisible(true); } }); @@ -661,21 +661,21 @@ const App: React.FC = () => { }; // Provide a callback so the NewModuleNameModal will know what the current - // workspace name is. - const getCurrentWorkspaceName = (): string => { - return currentModule ? currentModule.workspaceName : ''; + // project name is. + const getCurrentProjectName = (): string => { + return currentModule ? currentModule.projectName : ''; }; // Provide a callback so the NewModuleNameModal will know what the existing - // module names are in the current workspace. - const getModuleNames = (workspaceName: string): string[] => { + // module names are in the current project. + const getModuleNames = (projectName: string): string[] => { const moduleNames: string[] = []; - for (const workspace of modules) { - if (workspace.workspaceName === workspaceName) { - workspace.mechanisms.forEach((mechanism) => { + for (const project of modules) { + if (project.projectName === projectName) { + project.mechanisms.forEach((mechanism) => { moduleNames.push(mechanism.moduleName); }); - workspace.opModes.forEach((opMode) => { + project.opModes.forEach((opMode) => { moduleNames.push(opMode.moduleName); }); break; @@ -685,9 +685,9 @@ const App: React.FC = () => { }; const handleNewModuleNameOk = (newModuleName: string) => { - const newModulePath = commonStorage.makeModulePath(currentModule.workspaceName, newModuleName); + const newModulePath = commonStorage.makeModulePath(currentModule.projectName, newModuleName); if (newModuleNameModalPurpose === PURPOSE_NEW_MECHANISM) { - const mechanismContent = commonStorage.newMechanismContent(currentModule.workspaceName, newModuleName); + const mechanismContent = commonStorage.newMechanismContent(currentModule.projectName, newModuleName); storage.createModule( commonStorage.MODULE_TYPE_MECHANISM, newModulePath, mechanismContent, (success: boolean, errorMessage: string) => { @@ -702,7 +702,7 @@ const App: React.FC = () => { } }); } else if (newModuleNameModalPurpose === PURPOSE_NEW_OPMODE) { - const opModeContent = commonStorage.newOpModeContent(currentModule.workspaceName, newModuleName); + const opModeContent = commonStorage.newOpModeContent(currentModule.projectName, newModuleName); storage.createModule( commonStorage.MODULE_TYPE_OPMODE, newModulePath, opModeContent, (success: boolean, errorMessage: string) => { @@ -718,7 +718,7 @@ const App: React.FC = () => { }); } else if (newModuleNameModalPurpose === PURPOSE_RENAME_MODULE) { storage.renameModule( - currentModule.moduleType, currentModule.workspaceName, + currentModule.moduleType, currentModule.projectName, currentModule.moduleName, newModuleName, (success: boolean, errorMessage: string) => { if (success) { @@ -733,7 +733,7 @@ const App: React.FC = () => { }); } else if (newModuleNameModalPurpose === PURPOSE_COPY_MODULE) { storage.copyModule( - currentModule.moduleType, currentModule.workspaceName, + currentModule.moduleType, currentModule.projectName, currentModule.moduleName, newModuleName, (success: boolean, errorMessage: string) => { if (success) { @@ -775,12 +775,12 @@ const App: React.FC = () => { if (!currentModule) { return; } - if (currentModule.moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - // This is a Workspace. - setNewWorkspaceNameModalPurpose(PURPOSE_RENAME_WORKSPACE); - setNewWorkspaceNameModalInitialValue(currentModule.workspaceName); - setNewWorkspaceNameModalTitle('Rename Workspace'); - setNewWorkspaceNameModalIsOpen(true); + if (currentModule.moduleType == commonStorage.MODULE_TYPE_PROJECT) { + // This is a Project. + setNewProjectNameModalPurpose(PURPOSE_RENAME_PROJECT); + setNewProjectNameModalInitialValue(currentModule.projectName); + setNewProjectNameModalTitle('Rename Project'); + setNewProjectNameModalIsOpen(true); } else if (currentModule.moduleType == commonStorage.MODULE_TYPE_MECHANISM) { // This is a Mechanism. setNewModuleNameModalPurpose(PURPOSE_RENAME_MODULE); @@ -802,12 +802,12 @@ const App: React.FC = () => { if (!currentModule) { return; } - if (currentModule.moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - // This is a Workspace. - setNewWorkspaceNameModalPurpose(PURPOSE_COPY_WORKSPACE); - setNewWorkspaceNameModalInitialValue(currentModule.workspaceName + '_copy'); - setNewWorkspaceNameModalTitle('Copy Workspace'); - setNewWorkspaceNameModalIsOpen(true); + if (currentModule.moduleType == commonStorage.MODULE_TYPE_PROJECT) { + // This is a Project. + setNewProjectNameModalPurpose(PURPOSE_COPY_PROJECT); + setNewProjectNameModalInitialValue(currentModule.projectName + '_copy'); + setNewProjectNameModalTitle('Copy Project'); + setNewProjectNameModalIsOpen(true); } else if (currentModule.moduleType == commonStorage.MODULE_TYPE_MECHANISM) { // This is a Mechanism. setNewModuleNameModalPurpose(PURPOSE_COPY_MODULE); @@ -830,8 +830,8 @@ const App: React.FC = () => { } // Show a bubble confirmation box to ask the user if they are sure. setPopconfirmTitle('Are you sure?'); - if (currentModule.moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - setPopconfirmDescription('Press ok to delete this Workspace'); + if (currentModule.moduleType == commonStorage.MODULE_TYPE_PROJECT) { + setPopconfirmDescription('Press ok to delete this Project'); } else if (currentModule.moduleType == commonStorage.MODULE_TYPE_MECHANISM) { setPopconfirmDescription('Press ok to delete this Mechanism'); } else if (currentModule.moduleType == commonStorage.MODULE_TYPE_OPMODE) { @@ -844,21 +844,21 @@ const App: React.FC = () => { if (!currentModule) { return; } - if (currentModule.moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - // This is a Workspace. - // Before deleting it, select another workspace, if there is one. - // Put the module type and path into local variables before we select another workspace. + if (currentModule.moduleType == commonStorage.MODULE_TYPE_PROJECT) { + // This is a Project. + // Before deleting it, select another project, if there is one. + // Put the module type and path into local variables before we select another project. const moduleTypeToDelete = currentModule.moduleType; const modulePathToDelete = currentModulePath; - let foundAnotherWorkspace = false; - for (const workspace of modules) { - if (workspace.modulePath !== modulePathToDelete) { - setCurrentModulePath(workspace.modulePath); - foundAnotherWorkspace = true; + let foundAnotherProject = false; + for (const project of modules) { + if (project.modulePath !== modulePathToDelete) { + setCurrentModulePath(project.modulePath); + foundAnotherProject = true; break; } } - if (!foundAnotherWorkspace) { + if (!foundAnotherProject) { setCurrentModulePath(''); } storage.deleteModule(moduleTypeToDelete, modulePathToDelete, @@ -866,19 +866,19 @@ const App: React.FC = () => { if (success) { setTriggerListModules(!triggerListModules); } else if (errorMessage) { - setAlertErrorMessage('Failed to delete the Workspace: ' + errorMessage); + setAlertErrorMessage('Failed to delete the Project: ' + errorMessage); setAlertErrorVisible(true); } }); } else if (currentModule.moduleType == commonStorage.MODULE_TYPE_MECHANISM || currentModule.moduleType == commonStorage.MODULE_TYPE_OPMODE) { // This is a Mechanism or an OpMode. - // Before deleting it, select its workspace. - // Put the module type and path into local variables before we select its workspace. + // Before deleting it, select its project. + // Put the module type and path into local variables before we select its project. const moduleTypeToDelete = currentModule.moduleType; const modulePathToDelete = currentModulePath; - const workspacePath = commonStorage.makeWorkspacePath(currentModule.workspaceName); - setCurrentModulePath(workspacePath); + const projectPath = commonStorage.makeProjectPath(currentModule.projectName); + setCurrentModulePath(projectPath); storage.deleteModule(moduleTypeToDelete, modulePathToDelete, (success: boolean, errorMessage: string) => { if (success) { @@ -1008,13 +1008,13 @@ const App: React.FC = () => { > - @@ -1182,22 +1182,22 @@ const App: React.FC = () => { - { - setNewWorkspaceNameModalIsOpen(false); - handleNewWorkspaceNameOk(newName); + setNewProjectNameModalIsOpen(false); + handleNewProjectNameOk(newName); }} - onCancel={() => setNewWorkspaceNameModalIsOpen(false)} + onCancel={() => setNewProjectNameModalIsOpen(false)} /> { setNewModuleNameModalIsOpen(false); diff --git a/src/blocks/mrc_call_python_function.ts b/src/blocks/mrc_call_python_function.ts index 06ed0f47..1f0a1025 100644 --- a/src/blocks/mrc_call_python_function.ts +++ b/src/blocks/mrc_call_python_function.ts @@ -90,7 +90,7 @@ type CallPythonFunctionExtraState = { actualFunctionName?: string, /** * True if this blocks refers to an exported function (for example, from a - * user's Workspace). + * user's Project). */ exportedFunction: boolean, }; diff --git a/src/blocks/mrc_get_python_variable.ts b/src/blocks/mrc_get_python_variable.ts index f4dc97f2..6f631feb 100644 --- a/src/blocks/mrc_get_python_variable.ts +++ b/src/blocks/mrc_get_python_variable.ts @@ -118,7 +118,7 @@ type GetPythonVariableExtraState = { actualVariableName?: string, /** * True if this blocks refers to an exported variable (for example, from a - * user's Workspace). + * user's Project). */ exportedVariable: boolean, }; diff --git a/src/blocks/mrc_set_python_variable.ts b/src/blocks/mrc_set_python_variable.ts index 08e10009..1ef2426b 100644 --- a/src/blocks/mrc_set_python_variable.ts +++ b/src/blocks/mrc_set_python_variable.ts @@ -119,7 +119,7 @@ type SetPythonVariableExtraState = { actualVariableName?: string, /** * True if this blocks refers to an exported variable (for example, from a - * user's Workspace). + * user's Project). */ exportedVariable: boolean, }; diff --git a/src/editor/editor.ts b/src/editor/editor.ts index edf5c66b..34fdf708 100644 --- a/src/editor/editor.ts +++ b/src/editor/editor.ts @@ -36,9 +36,9 @@ export class Editor { private blocklyWorkspace: Blockly.WorkspaceSvg; private currentModule: commonStorage.Module | null = null; private modulePath: string = ''; - private workspacePath: string = ''; + private projectPath: string = ''; private moduleContent: string = ''; - private workspaceContent: string = ''; + private projectContent: string = ''; private bindedOnChange: any = null; private toolbox: Blockly.utils.toolbox.ToolboxDefinition = EMPTY_TOOLBOX; @@ -59,11 +59,11 @@ export class Editor { // TODO(lizlooney): As blocks are loaded, determine whether any blocks // are accessing variable or calling functions thar are defined in another - // blocks file (like a Workspace) and check whether the variable or function + // blocks file (like a Project) and check whether the variable or function // definition has changed. This might happen if the user defines a variable - // or function in the Workspace, uses the variable or function in the + // or function in the Project, uses the variable or function in the // OpMode, and then removes or changes the variable or function in the - // Workspace. + // Project. // TODO(lizlooney): We will need a way to identify which variable or // function, other than by the variable name or function name, because the @@ -74,7 +74,7 @@ export class Editor { // TODO(lizlooney): Look at blocks with type 'mrc_get_python_variable' or // 'mrc_set_python_variable', and where block.mrcExportedVariable === true. // Look at block.mrcImportModule and get the exported blocks for that module. - // (It should be the workspace and we already have the workspace content.) + // (It should be the project and we already have the project content.) // Check whether block.mrcActualVariableName matches any exportedBlock's // extraState.actualVariableName. If there is no match, put a warning on the // block. @@ -82,7 +82,7 @@ export class Editor { // TODO(lizlooney): Look at blocks with type 'mrc_call_python_function' and // where block.mrcExportedFunction === true. // Look at block.mrcImportModule and get the exported blocks for that module. - // (It should be the workspace and we already have the workspace content.) + // (It should be the project and we already have the project content.) // Check whether block.mrcActualFunctionName matches any exportedBlock's // extraState.actualFunctionName. If there is no match, put a warning on the block. // If there is a match, check whether @@ -106,13 +106,13 @@ export class Editor { this.currentModule = currentModule; if (currentModule) { this.modulePath = currentModule.modulePath; - this.workspacePath = commonStorage.makeWorkspacePath(currentModule.workspaceName); + this.projectPath = commonStorage.makeProjectPath(currentModule.projectName); } else { this.modulePath = ''; - this.workspacePath = ''; + this.projectPath = ''; } this.moduleContent = ''; - this.workspaceContent = ''; + this.projectContent = ''; this.clearBlocklyWorkspace(); if (currentModule) { @@ -125,30 +125,30 @@ export class Editor { } if (moduleContent) { this.moduleContent = moduleContent; - if (this.workspacePath === this.modulePath) { - this.workspaceContent = moduleContent + if (this.projectPath === this.modulePath) { + this.projectContent = moduleContent } - // If both the workspace content and the module content have been + // If both the project content and the module content have been // loaded, load the blocks into the blockly workspace. - if (this.workspaceContent) { + if (this.projectContent) { this.loadBlocksIntoBlocklyWorkspace(); } } } ); - if (this.workspacePath !== this.modulePath) { + if (this.projectPath !== this.modulePath) { storage.fetchModuleContent( - this.workspacePath, - (workspaceContent: string | null, errorMessage: string) => { + this.projectPath, + (projectContent: string | null, errorMessage: string) => { if (errorMessage) { alert(errorMessage); return; } - if (workspaceContent) { - this.workspaceContent = workspaceContent; + if (projectContent) { + this.projectContent = projectContent; - // If both the workspace and the module have been loaded, load the + // If both the project and the module have been loaded, load the // blocks into the blockly workspace. if (this.moduleContent) { this.loadBlocksIntoBlocklyWorkspace(); @@ -189,22 +189,22 @@ export class Editor { public updateToolbox(shownPythonToolboxCategories: Set): void { if (this.currentModule) { - if (this.currentModule.moduleType === commonStorage.MODULE_TYPE_WORKSPACE) { - // If we are editing a Workspace, we don't add any additional blocks to + if (this.currentModule.moduleType === commonStorage.MODULE_TYPE_PROJECT) { + // If we are editing a Project, we don't add any additional blocks to // the toolbox. this.setToolbox(getToolboxJSON([], shownPythonToolboxCategories)); return; } - // Otherwise, we add the exported blocks from the Workspace. - if (!this.workspaceContent) { - // The workspace content hasn't been fetched yet. Try again in a bit. + // Otherwise, we add the exported blocks from the Project. + if (!this.projectContent) { + // The Project content hasn't been fetched yet. Try again in a bit. setTimeout(() => { this.updateToolbox(shownPythonToolboxCategories) }, 50); return; } const exportedBlocks = commonStorage.extractExportedBlocks( - this.currentModule.workspaceName, this.workspaceContent); + this.currentModule.projectName, this.projectContent); this.setToolbox(getToolboxJSON(exportedBlocks, shownPythonToolboxCategories)); } } diff --git a/src/editor/extended_python_generator.ts b/src/editor/extended_python_generator.ts index bddddccc..3dbadb30 100644 --- a/src/editor/extended_python_generator.ts +++ b/src/editor/extended_python_generator.ts @@ -160,7 +160,7 @@ export class ExtendedPythonGenerator extends PythonGenerator { } classParentFromModuleType(moduleType : string) : string{ - if(moduleType == commonStorage.MODULE_TYPE_WORKSPACE){ + if(moduleType == commonStorage.MODULE_TYPE_PROJECT){ return "RobotBase"; } if(moduleType == commonStorage.MODULE_TYPE_OPMODE){ diff --git a/src/storage/client_side_storage.ts b/src/storage/client_side_storage.ts index f497adae..9e7cda36 100644 --- a/src/storage/client_side_storage.ts +++ b/src/storage/client_side_storage.ts @@ -25,7 +25,7 @@ import * as commonStorage from './common_storage'; export type BooleanCallback = (success: boolean, error: string) => void; export type StringCallback = (value: string | null, error: string) => void; -export type ModulesCallback = (modules: commonStorage.Workspace[] | null, error: string) => void; +export type ModulesCallback = (modules: commonStorage.Project[] | null, error: string) => void; const databaseName = 'systemcore-blocks-interface'; @@ -149,11 +149,11 @@ export function listModules(callback: ModulesCallback): void { }); return; } - const workspaces: {[key: string]: commonStorage.Workspace} = {}; // key is workspace name, value is Workspace + const projects: {[key: string]: commonStorage.Project} = {}; // key is project name, value is Project // The mechanisms and opModes variables hold any Mechanisms and OpModes that - // are read before the Workspace to which they belong is read. - const mechanisms: {[key: string]: commonStorage.Mechanism[]} = {}; // key is workspace name, value is list of Mechanisms - const opModes: {[key: string]: commonStorage.OpMode[]} = {}; // key is workspace name, value is list of OpModes + // are read before the Project to which they belong is read. + const mechanisms: {[key: string]: commonStorage.Mechanism[]} = {}; // key is project name, value is list of Mechanisms + const opModes: {[key: string]: commonStorage.OpMode[]} = {}; // key is project name, value is list of OpModes const openCursorRequest = db.transaction(['modules'], 'readonly') .objectStore('modules') .openCursor(); @@ -167,72 +167,73 @@ export function listModules(callback: ModulesCallback): void { if (cursor) { const value = cursor.value; const path = value.path; + const moduleType = value.type; const module: commonStorage.Module = { modulePath: path, - moduleType: value.type, - workspaceName: commonStorage.getWorkspaceName(path), + moduleType: moduleType, + projectName: commonStorage.getProjectName(path), moduleName: commonStorage.getModuleName(path), dateModifiedMillis: value.dateModifiedMillis, } - if (value.type === commonStorage.MODULE_TYPE_WORKSPACE) { - const workspace: commonStorage.Workspace = { + if (moduleType === commonStorage.MODULE_TYPE_PROJECT) { + const project: commonStorage.Project = { ...module, mechanisms: [], opModes: [], }; - workspaces[workspace.workspaceName] = workspace; - // Add any Mechanisms that belong to this workspace that have already + projects[project.projectName] = project; + // Add any Mechanisms that belong to this project that have already // been read. - if (workspace.workspaceName in mechanisms) { - workspace.mechanisms = mechanisms[workspace.workspaceName]; - delete mechanisms[workspace.workspaceName]; + if (project.projectName in mechanisms) { + project.mechanisms = mechanisms[project.projectName]; + delete mechanisms[project.projectName]; } - // Add any OpModes that belong to this workspace that have already been + // Add any OpModes that belong to this project that have already been // read. - if (workspace.workspaceName in opModes) { - workspace.opModes = opModes[workspace.workspaceName]; - delete opModes[workspace.workspaceName]; + if (project.projectName in opModes) { + project.opModes = opModes[project.projectName]; + delete opModes[project.projectName]; } - } else if (value.type === commonStorage.MODULE_TYPE_MECHANISM) { + } else if (moduleType === commonStorage.MODULE_TYPE_MECHANISM) { const mechanism: commonStorage.Mechanism = { ...module, }; - if (mechanism.workspaceName in workspaces) { - // If the Workspace to which this Mechanism belongs has already been read, + if (mechanism.projectName in projects) { + // If the Project to which this Mechanism belongs has already been read, // add this Mechanism to it. - workspaces[mechanism.workspaceName].mechanisms.push(mechanism); + projects[mechanism.projectName].mechanisms.push(mechanism); } else { // Otherwise, add this Mechanism to the mechanisms local variable. - if (mechanism.workspaceName in mechanisms) { - mechanisms[mechanism.workspaceName].push(mechanism); + if (mechanism.projectName in mechanisms) { + mechanisms[mechanism.projectName].push(mechanism); } else { - mechanisms[mechanism.workspaceName] = [mechanism]; + mechanisms[mechanism.projectName] = [mechanism]; } } - } else if (value.type === commonStorage.MODULE_TYPE_OPMODE) { + } else if (moduleType === commonStorage.MODULE_TYPE_OPMODE) { const opMode: commonStorage.OpMode = { ...module, }; - if (opMode.workspaceName in workspaces) { - // If the Workspace to which this OpMode belongs has already been read, + if (opMode.projectName in projects) { + // If the Project to which this OpMode belongs has already been read, // add this OpMode to it. - workspaces[opMode.workspaceName].opModes.push(opMode); + projects[opMode.projectName].opModes.push(opMode); } else { // Otherwise, add this OpMode to the opModes local variable. - if (opMode.workspaceName in opModes) { - opModes[opMode.workspaceName].push(opMode); + if (opMode.projectName in opModes) { + opModes[opMode.projectName].push(opMode); } else { - opModes[opMode.workspaceName] = [opMode]; + opModes[opMode.projectName] = [opMode]; } } } cursor.continue(); } else { // The cursor is done. We have finished reading all the modules. - const modules: commonStorage.Workspace[] = []; - const sortedWorkspaceNames = Object.keys(workspaces).sort(); - sortedWorkspaceNames.forEach((workspaceName) => { - modules.push(workspaces[workspaceName]); + const modules: commonStorage.Project[] = []; + const sortedProjectNames = Object.keys(projects).sort(); + sortedProjectNames.forEach((projectName) => { + modules.push(projects[projectName]); }); callback(modules, ''); } @@ -338,16 +339,16 @@ function _saveModule( }; } -function _renameOrCopyWorkspace( - oldWorkspaceName: string, newWorkspaceName: string, +function _renameOrCopyProject( + oldProjectName: string, newProjectName: string, callback: BooleanCallback, copy: boolean): void { const errorMessage = copy - ? 'Copy Workspace failed.' - : 'Rename Workspace failed.' + ? 'Copy Project failed.' + : 'Rename Project failed.' if (!db) { _openDatabase((success: boolean, errorReason: string) => { if (success) { - _renameOrCopyWorkspace(oldWorkspaceName, newWorkspaceName, callback, copy); + _renameOrCopyProject(oldProjectName, newProjectName, callback, copy); } else { callback(false, errorMessage + ' (' + errorReason + ')'); } @@ -360,7 +361,7 @@ function _renameOrCopyWorkspace( callback(true, ''); }; const modulesObjectStore = transaction.objectStore('modules'); - // First get the list of modules in the workspace. + // First get the list of modules in the project. const oldToNewModulePaths: {[key: string]: string} = {}; const openCursorRequest = modulesObjectStore.openCursor(); openCursorRequest.onerror = (event: Event) => { @@ -373,19 +374,20 @@ function _renameOrCopyWorkspace( if (cursor) { const value = cursor.value; const path = value.path; - if (commonStorage.getWorkspaceName(path) === oldWorkspaceName) { + const moduleType = value.type; + if (commonStorage.getProjectName(path) === oldProjectName) { let newPath; - if (value.type === commonStorage.MODULE_TYPE_WORKSPACE) { - newPath = commonStorage.makeModulePath(newWorkspaceName, newWorkspaceName); + if (moduleType === commonStorage.MODULE_TYPE_PROJECT) { + newPath = commonStorage.makeProjectPath(newProjectName); } else { const moduleName = commonStorage.getModuleName(path); - newPath = commonStorage.makeModulePath(newWorkspaceName, moduleName); + newPath = commonStorage.makeModulePath(newProjectName, moduleName); } oldToNewModulePaths[path] = newPath; } cursor.continue(); } else { - // Now rename the workspace for each of the modules. + // Now rename the project for each of the modules. Object.entries(oldToNewModulePaths).forEach(([oldModulePath, newModulePath]) => { const getRequest = modulesObjectStore.get(oldModulePath); getRequest.onerror = (event: Event) => { @@ -395,7 +397,7 @@ function _renameOrCopyWorkspace( }; getRequest.onsuccess = (event: Event) => { if (getRequest.result === undefined) { - callback(false, errorMessage + ' (workspace not found)'); + callback(false, errorMessage + ' (project not found)'); return; } const value = getRequest.result; @@ -426,30 +428,30 @@ function _renameOrCopyWorkspace( } export function renameModule( - moduleType: string, workspaceName: string, + moduleType: string, projectName: string, oldModuleName: string, newModuleName: string, callback: BooleanCallback): void { _renameOrCopyModule( - moduleType, workspaceName, oldModuleName, newModuleName, + moduleType, projectName, oldModuleName, newModuleName, callback, false); } export function copyModule( - moduleType: string, workspaceName: string, + moduleType: string, projectName: string, oldModuleName: string, newModuleName: string, callback: BooleanCallback): void { _renameOrCopyModule( - moduleType, workspaceName, oldModuleName, newModuleName, + moduleType, projectName, oldModuleName, newModuleName, callback, true); } function _renameOrCopyModule( - moduleType: string, workspaceName: string, + moduleType: string, projectName: string, oldModuleName: string, newModuleName: string, callback: BooleanCallback, copy: boolean): void { - if (moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - _renameOrCopyWorkspace(oldModuleName, newModuleName, callback, copy); + if (moduleType == commonStorage.MODULE_TYPE_PROJECT) { + _renameOrCopyProject(oldModuleName, newModuleName, callback, copy); return; } @@ -461,7 +463,7 @@ function _renameOrCopyModule( _openDatabase((success: boolean, errorReason: string) => { if (success) { _renameOrCopyModule( - moduleType, workspaceName, oldModuleName, newModuleName, + moduleType, projectName, oldModuleName, newModuleName, callback, copy); } else { callback(false, errorMessage + '(' + errorReason + ')'); @@ -475,8 +477,8 @@ function _renameOrCopyModule( callback(true, ''); }; const modulesObjectStore = transaction.objectStore('modules'); - const oldModulePath = commonStorage.makeModulePath(workspaceName, oldModuleName); - const newModulePath = commonStorage.makeModulePath(workspaceName, newModuleName); + const oldModulePath = commonStorage.makeModulePath(projectName, oldModuleName); + const newModulePath = commonStorage.makeModulePath(projectName, newModuleName); const getRequest = modulesObjectStore.get(oldModulePath); getRequest.onerror = (event: Event) => { console.log('IndexedDB get request failed:'); @@ -512,14 +514,14 @@ function _renameOrCopyModule( }; } -function _deleteWorkspace( - workspaceName: string, callback: BooleanCallback): void { +function _deleteProject( + projectName: string, callback: BooleanCallback): void { if (!db) { _openDatabase((success: boolean, errorReason: string) => { if (success) { - deleteWorkspace(workspaceName, callback); + deleteProject(projectName, callback); } else { - callback(false, 'Delete workspace failed. (' + errorReason + ')'); + callback(false, 'Delete project failed. (' + errorReason + ')'); } }); return; @@ -530,20 +532,20 @@ function _deleteWorkspace( callback(true, ''); }; const modulesObjectStore = transaction.objectStore('modules'); - // First get the list of modulePaths in the workspace. + // First get the list of modulePaths in the project. const modulePaths: string[] = []; const openCursorRequest = modulesObjectStore.openCursor(); openCursorRequest.onerror = (event: Event) => { console.log('IndexedDB openCursor request failed:'); console.log(openCursorRequest.error); - callback(false, 'Delete workspace failed. Could not open cursor.'); + callback(false, 'Delete project failed. Could not open cursor.'); }; openCursorRequest.onsuccess = (event: Event) => { const cursor = openCursorRequest.result; if (cursor) { const value = cursor.value; const path = value.path; - if (commonStorage.getWorkspaceName(path) === workspaceName) { + if (commonStorage.getProjectName(path) === projectName) { modulePaths.push(path); } cursor.continue(); @@ -554,7 +556,7 @@ function _deleteWorkspace( deleteRequest.onerror = (event: Event) => { console.log('IndexedDB delete request failed:'); console.log(deleteRequest.error); - callback(false, 'Delete workspace failed. (deleteRequest error)'); + callback(false, 'Delete project failed. (deleteRequest error)'); }; deleteRequest.onsuccess = (event: Event) => { }; @@ -567,9 +569,9 @@ export function deleteModule( moduleType: string, modulePath: string, callback: BooleanCallback): void { - if (moduleType == commonStorage.MODULE_TYPE_WORKSPACE) { - const workspaceName = commonStorage.getWorkspaceName(modulePath); - _deleteWorkspace(workspaceName, callback); + if (moduleType == commonStorage.MODULE_TYPE_PROJECT) { + const projectName = commonStorage.getProjectName(modulePath); + _deleteProject(projectName, callback); return; } diff --git a/src/storage/common_storage.ts b/src/storage/common_storage.ts index 0389b88d..14d8a158 100644 --- a/src/storage/common_storage.ts +++ b/src/storage/common_storage.ts @@ -33,7 +33,7 @@ import {extendedPythonGenerator} from '../editor/extended_python_generator'; export type Module = { modulePath: string, moduleType: string, - workspaceName: string, + projectName: string, moduleName: string, dateModifiedMillis: number, }; @@ -41,13 +41,13 @@ export type Module = { export type Mechanism = Module; export type OpMode = Module; -export type Workspace = Module & { +export type Project = Module & { mechanisms: Mechanism[] opModes: OpMode[], }; export const MODULE_TYPE_UNKNOWN = 'unknown'; -export const MODULE_TYPE_WORKSPACE = 'workspace'; +export const MODULE_TYPE_PROJECT = 'project'; export const MODULE_TYPE_MECHANISM = 'mechanism'; export const MODULE_TYPE_OPMODE = 'opmode'; @@ -65,17 +65,17 @@ const NUMBER_OF_PARTS = 3; /** * Returns the module with the given module path, or null if it is not found. */ -export function findModule(modules: Workspace[], modulePath: string): Module | null { - for (const workspace of modules) { - if (workspace.modulePath === modulePath) { - return workspace; +export function findModule(modules: Project[], modulePath: string): Module | null { + for (const project of modules) { + if (project.modulePath === modulePath) { + return project; } - for (const mechanism of workspace.mechanisms) { + for (const mechanism of project.mechanisms) { if (mechanism.modulePath === modulePath) { return mechanism; } } - for (const opMode of workspace.opModes) { + for (const opMode of project.opModes) { if (opMode.modulePath === modulePath) { return opMode; } @@ -96,27 +96,27 @@ export function isValidPythonModuleName(name: string): boolean { } /** - * Returns the module path for the given workspace and module names. + * Returns the module path for the given project and module names. */ -export function makeModulePath(workspaceName: string, moduleName: string): string { - return workspaceName + '/' + moduleName + '.py'; +export function makeModulePath(projectName: string, moduleName: string): string { + return projectName + '/' + moduleName + '.py'; } /** - * Returns the workspace path for the given workspace names. + * Returns the project path for the given project names. */ -export function makeWorkspacePath(workspaceName: string): string { - return makeModulePath(workspaceName, workspaceName); +export function makeProjectPath(projectName: string): string { + return makeModulePath(projectName, projectName); } /** - * Returns the workspace name for given module path. + * Returns the project name for given module path. */ -export function getWorkspaceName(modulePath: string): string { +export function getProjectName(modulePath: string): string { const regex = new RegExp('^([a-z_][a-z0-9_]*)/([a-z_][a-z0-9_]*).py$'); const result = regex.exec(modulePath) if (!result) { - throw new Error('Unable to extract the workspace name.'); + throw new Error('Unable to extract the project name.'); } return result[1]; } @@ -137,28 +137,28 @@ export function getModuleName(modulePath: string): string { * Returns the download file name for the given module path. */ export function makeDownloadFileName(modulePath: string): string { - return getWorkspaceName(modulePath) + '-' + getModuleName(modulePath) + '.wpilib_blocks'; + return getProjectName(modulePath) + '-' + getModuleName(modulePath) + '.wpilib_blocks'; } -export function makeUploadWorkspaceName(uploadFileName: string): string { - // Check if the name is -. +export function makeUploadProjectName(uploadFileName: string): string { + // Check if the name is -. const regex = new RegExp('^([a-z_][a-z0-9_]*)-([a-z_][a-z0-9_]*).wpilib_blocks$'); const result = regex.exec(uploadFileName); if (!result || result[1] !== result[2]) { - throw new Error(uploadFileName + ' is not a valid file name for uploading as a workspace'); + throw new Error(uploadFileName + ' is not a valid file name for uploading as a project'); } return result[2]; } /** - * Returns the module content for a new Workspace. + * Returns the module content for a new Project. */ -export function newWorkspaceContent(workspaceName: string): string { +export function newProjectContent(projectName: string): string { const module: Module = { - modulePath: makeWorkspacePath(workspaceName), - moduleType: MODULE_TYPE_WORKSPACE, - workspaceName: workspaceName, - moduleName: workspaceName, + modulePath: makeProjectPath(projectName), + moduleType: MODULE_TYPE_PROJECT, + projectName: projectName, + moduleName: projectName, dateModifiedMillis: 0, }; @@ -177,11 +177,11 @@ export function newWorkspaceContent(workspaceName: string): string { /** * Returns the module content for a new Mechanism. */ -export function newMechanismContent(workspaceName: string, mechanismName: string): string { +export function newMechanismContent(projectName: string, mechanismName: string): string { const module: Module = { - modulePath: makeModulePath(workspaceName, mechanismName), + modulePath: makeModulePath(projectName, mechanismName), moduleType: MODULE_TYPE_MECHANISM, - workspaceName: workspaceName, + projectName: projectName, moduleName: mechanismName, dateModifiedMillis: 0, }; @@ -201,11 +201,11 @@ export function newMechanismContent(workspaceName: string, mechanismName: string /** * Returns the module content for a new OpMode. */ -export function newOpModeContent(workspaceName: string, opModeName: string): string { +export function newOpModeContent(projectName: string, opModeName: string): string { const module: Module = { - modulePath: makeModulePath(workspaceName, opModeName), + modulePath: makeModulePath(projectName, opModeName), moduleType: MODULE_TYPE_OPMODE, - workspaceName: workspaceName, + projectName: projectName, moduleName: opModeName, dateModifiedMillis: 0, }; @@ -273,7 +273,7 @@ function getParts(moduleContent: string): string { } if (parts.length == 2) { // This module was saved without the module type, which was added to the module content when we introduced mechanisms. - // This module is either a Workspace or an OpMode, but we don't know which from just the content. + // This module is either a Project or an OpMode, but we don't know which from just the content. parts.push(MODULE_TYPE_UNKNOWN); } return parts; diff --git a/src/toolbox/toolbox.ts b/src/toolbox/toolbox.ts index 49536c75..2346398c 100644 --- a/src/toolbox/toolbox.ts +++ b/src/toolbox/toolbox.ts @@ -31,12 +31,12 @@ import {category as mechanismCategory } from './mechanism_category'; import {category as methodsCategory} from './opmode_methods_category'; export function getToolboxJSON( - opt_includeExportedBlocksFromWorkspace: toolboxItems.ContentsType[], + opt_includeExportedBlocksFromProject: toolboxItems.ContentsType[], shownPythonToolboxCategories: Set) { const contents: toolboxItems.ContentsType[] = generatedToolbox.getToolboxCategories(); filterGeneratedCategories(contents, shownPythonToolboxCategories); - if (opt_includeExportedBlocksFromWorkspace.length) { + if (opt_includeExportedBlocksFromProject.length) { contents.push.apply( contents, [ @@ -45,8 +45,8 @@ export function getToolboxJSON( }, { kind: 'category', - name: 'Workspace', - contents: opt_includeExportedBlocksFromWorkspace, + name: 'Project', + contents: opt_includeExportedBlocksFromProject, } ]); }