Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { extendedPythonGenerator } from './editor/extended_python_generator';

import * as commonStorage from './storage/common_storage';
import * as storageModule from './storage/module';
import * as storageProject from './storage/project';
import * as clientSideStorage from './storage/client_side_storage';

import * as CustomBlocks from './blocks/setup_custom_blocks';
Expand Down Expand Up @@ -130,7 +131,7 @@ const App: React.FC = (): React.JSX.Element => {
* App wrapper that manages project state and provides it to UserSettingsProvider.
*/
const AppWithUserSettings: React.FC<{ storage: commonStorage.Storage }> = ({ storage }) => {
const [project, setProject] = React.useState<commonStorage.Project | null>(null);
const [project, setProject] = React.useState<storageProject.Project | null>(null);

return (
<UserSettingsProvider
Expand All @@ -146,8 +147,8 @@ const AppWithUserSettings: React.FC<{ storage: commonStorage.Storage }> = ({ sto
* Inner application content component that has access to UserSettings context.
*/
interface AppContentProps {
project: commonStorage.Project | null;
setProject: React.Dispatch<React.SetStateAction<commonStorage.Project | null>>;
project: storageProject.Project | null;
setProject: React.Dispatch<React.SetStateAction<storageProject.Project | null>>;
}

const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.JSX.Element => {
Expand Down Expand Up @@ -360,7 +361,7 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
};

/** Creates tab items from project data. */
const createTabItemsFromProject = (projectData: commonStorage.Project): Tabs.TabItem[] => {
const createTabItemsFromProject = (projectData: storageProject.Project): Tabs.TabItem[] => {
const tabs: Tabs.TabItem[] = [
{
key: projectData.robot.modulePath,
Expand Down
5 changes: 3 additions & 2 deletions src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeneratorContext } from './generator_context';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageNames from '../storage/names';
import * as storageProject from '../storage/project';
import * as eventHandler from '../blocks/mrc_event_handler';
import * as classMethodDef from '../blocks/mrc_class_method_def';
import * as mechanismComponentHolder from '../blocks/mrc_mechanism_component_holder';
Expand All @@ -48,7 +49,7 @@ export class Editor {
private generatorContext: GeneratorContext;
private storage: commonStorage.Storage;
private currentModule: storageModule.Module | null = null;
private currentProject: commonStorage.Project | null = null;
private currentProject: storageProject.Project | null = null;
private modulePath: string = '';
private robotPath: string = '';
private moduleContentText: string = '';
Expand Down Expand Up @@ -122,7 +123,7 @@ export class Editor {

public async loadModuleBlocks(
currentModule: storageModule.Module | null,
currentProject: commonStorage.Project | null) {
currentProject: storageProject.Project | null) {
this.generatorContext.setModule(currentModule);
this.currentModule = currentModule;
this.currentProject = currentProject;
Expand Down
9 changes: 5 additions & 4 deletions src/reactComponents/AddTabDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as I18Next from 'react-i18next';
import * as React from 'react';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageProject from '../storage/project';
import ClassNameComponent from './ClassNameComponent';

/** Represents a module item in the dialog. */
Expand All @@ -39,8 +40,8 @@ interface AddTabDialogProps {
isOpen: boolean;
onOk: (newTabs: TabItem[]) => void;
onCancel: () => void;
project: commonStorage.Project | null;
setProject: (project: commonStorage.Project | null) => void;
project: storageProject.Project | null;
setProject: (project: storageProject.Project | null) => void;
currentTabs: TabItem[];
storage: commonStorage.Storage | null;
}
Expand Down Expand Up @@ -132,10 +133,10 @@ export default function AddTabDialog(props: AddTabDialogProps) {
storageModule.MODULE_TYPE_MECHANISM :
storageModule.MODULE_TYPE_OPMODE;

await commonStorage.addModuleToProject(
await storageProject.addModuleToProject(
props.storage, props.project, storageType, newClassName);

const newModule = commonStorage.findModuleByClassName(props.project, newClassName);
const newModule = storageProject.findModuleByClassName(props.project, newClassName);
if (newModule) {
const module: Module = {
path: newModule.modulePath,
Expand Down
5 changes: 3 additions & 2 deletions src/reactComponents/ClassNameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import * as Antd from 'antd';
import * as I18Next from 'react-i18next';
import * as React from 'react';
import * as commonStorage from '../storage/common_storage';
import * as storageProject from '../storage/project';

/** Props for the ClassNameComponent. */
interface ClassNameComponentProps {
tabType: TabType;
newItemName: string;
setNewItemName: (name: string) => void;
onAddNewItem: () => void;
project: commonStorage.Project | null;
project: storageProject.Project | null;
storage: commonStorage.Storage | null;
buttonLabel: string;
}
Expand Down Expand Up @@ -65,7 +66,7 @@ export default function ClassNameComponent(props: ClassNameComponentProps): Reac
return;
}

const {ok, error} = commonStorage.isClassNameOk(props.project, newClassName);
const {ok, error} = storageProject.isClassNameOk(props.project, newClassName);
if (ok) {
clearError();
props.onAddNewItem();
Expand Down
15 changes: 8 additions & 7 deletions src/reactComponents/FileManageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as I18Next from 'react-i18next';
import * as React from 'react';
import * as commonStorage from '../storage/common_storage';
import * as storageModule from '../storage/module';
import * as storageProject from '../storage/project';
import {EditOutlined, DeleteOutlined, CopyOutlined} from '@ant-design/icons';
import ClassNameComponent from './ClassNameComponent';

Expand All @@ -38,8 +39,8 @@ interface Module {
interface FileManageModalProps {
isOpen: boolean;
onCancel: () => void;
project: commonStorage.Project | null;
setProject: (project: commonStorage.Project | null) => void;
project: storageProject.Project | null;
setProject: (project: storageProject.Project | null) => void;
gotoTab: (path: string) => void;
setAlertErrorMessage: (message: string) => void;
storage: commonStorage.Storage | null;
Expand Down Expand Up @@ -107,7 +108,7 @@ export default function FileManageModal(props: FileManageModalProps) {
}

try {
const newModulePath = await commonStorage.renameModuleInProject(
const newModulePath = await storageProject.renameModuleInProject(
props.storage,
props.project,
newClassName,
Expand Down Expand Up @@ -138,7 +139,7 @@ export default function FileManageModal(props: FileManageModalProps) {
}

try {
const newModulePath = await commonStorage.copyModuleInProject(
const newModulePath = await storageProject.copyModuleInProject(
props.storage,
props.project,
newClassName,
Expand Down Expand Up @@ -180,14 +181,14 @@ export default function FileManageModal(props: FileManageModalProps) {
storageModule.MODULE_TYPE_MECHANISM :
storageModule.MODULE_TYPE_OPMODE;

await commonStorage.addModuleToProject(
await storageProject.addModuleToProject(
props.storage,
props.project,
storageType,
newClassName
);

const newModule = commonStorage.findModuleByClassName(props.project, newClassName);
const newModule = storageProject.findModuleByClassName(props.project, newClassName);
if (newModule) {
const module: Module = {
path: newModule.modulePath,
Expand All @@ -206,7 +207,7 @@ export default function FileManageModal(props: FileManageModalProps) {
setModules(newModules);

if (props.storage && props.project) {
await commonStorage.removeModuleFromProject(
await storageProject.removeModuleFromProject(
props.storage,
props.project,
record.path
Expand Down
4 changes: 2 additions & 2 deletions src/reactComponents/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author [email protected] (Alan Smith)
*/
import * as Antd from 'antd';
import * as commonStorage from '../storage/common_storage';
import * as storageProject from '../storage/project';
import * as React from 'react';
import { useTranslation } from 'react-i18next';

Expand All @@ -30,7 +30,7 @@ type StringFunction = (input: string) => void;
interface HeaderProps {
alertErrorMessage: string;
setAlertErrorMessage: StringFunction;
project: commonStorage.Project | null;
project: storageProject.Project | null;
}

/** Height of the logo image in pixels. */
Expand Down
15 changes: 8 additions & 7 deletions src/reactComponents/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import * as React from 'react';
import { RcFile, UploadRequestOption } from 'rc-upload/lib/interface';
import * as commonStorage from '../storage/common_storage';
import * as storageNames from '../storage/names';
import * as storageProject from '../storage/project';
import * as createPythonFiles from '../storage/create_python_files';
import * as I18Next from 'react-i18next';
import {TabType } from '../types/TabType';
Expand Down Expand Up @@ -56,9 +57,9 @@ export interface MenuProps {
setAlertErrorMessage: (message: string) => void;
storage: commonStorage.Storage | null;
gotoTab: (tabKey: string) => void;
project: commonStorage.Project | null;
project: storageProject.Project | null;
openWPIToolboxSettings: () => void;
setProject: (project: commonStorage.Project | null) => void;
setProject: (project: storageProject.Project | null) => void;
theme: string;
setTheme: (theme: string) => void;
}
Expand Down Expand Up @@ -100,7 +101,7 @@ function getDivider(): MenuItem {
/**
* Generates menu items for a given project.
*/
function getMenuItems(t: (key: string) => string, project: commonStorage.Project, currentLanguage: string): MenuItem[] {
function getMenuItems(t: (key: string) => string, project: storageProject.Project, currentLanguage: string): MenuItem[] {
const mechanisms: MenuItem[] = [];
const opmodes: MenuItem[] = [];

Expand Down Expand Up @@ -176,7 +177,7 @@ function getMenuItems(t: (key: string) => string, project: commonStorage.Project
export function Component(props: MenuProps): React.JSX.Element {
const {t, i18n} = I18Next.useTranslation();

const [projects, setProjects] = React.useState<commonStorage.Project[]>([]);
const [projects, setProjects] = React.useState<storageProject.Project[]>([]);
const [menuItems, setMenuItems] = React.useState<MenuItem[]>([]);
const [fileModalOpen, setFileModalOpen] = React.useState<boolean>(false);
const [projectModalOpen, setProjectModalOpen] = React.useState<boolean>(false);
Expand All @@ -191,7 +192,7 @@ export function Component(props: MenuProps): React.JSX.Element {
};

/** Fetches the list of projects from storage. */
const fetchListOfProjects = async (): Promise<commonStorage.Project[]> => {
const fetchListOfProjects = async (): Promise<storageProject.Project[]> => {
return new Promise(async (resolve, reject) => {
if (!props.storage) {
reject(new Error('Storage not available'));
Expand Down Expand Up @@ -252,7 +253,7 @@ export function Component(props: MenuProps): React.JSX.Element {
/** Handles menu item clicks. */
const handleClick: Antd.MenuProps['onClick'] = ({key}): void => {
const newModule = props.project ?
commonStorage.findModuleByModulePath(props.project, key) :
storageProject.findModuleByModulePath(props.project, key) :
null;

if (newModule) {
Expand Down Expand Up @@ -386,7 +387,7 @@ export function Component(props: MenuProps): React.JSX.Element {
existingProjectNames.push(project.projectName);
});
const file = options.file as RcFile;
const uploadProjectName = commonStorage.makeUploadProjectName(file.name, existingProjectNames);
const uploadProjectName = storageProject.makeUploadProjectName(file.name, existingProjectNames);
if (props.storage) {
props.storage.uploadProject(uploadProjectName, dataUrl);
}
Expand Down
Loading