Skip to content

Commit ceed3b8

Browse files
authored
Change new projects to have Teleop as default OpMode (#178)
1 parent 3ef6c75 commit ceed3b8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/modules/opmode_start.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"fields": {
1212
"NAME": "",
1313
"GROUP": "",
14-
"TYPE": "Auto",
14+
"TYPE": "Teleop",
1515
"ENABLED": true
1616
}
1717
},

src/storage/client_side_storage.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,12 @@ class ClientSideStorage implements commonStorage.Storage {
240240
});
241241
}
242242

243-
async createProject(projectName: string, robotContent: string): Promise<void> {
243+
async createProject(projectName: string, robotContent: string, opmodeContent : string): Promise<void> {
244244
const modulePath = commonStorage.makeRobotPath(projectName);
245-
return this._saveModule(commonStorage.MODULE_TYPE_ROBOT, modulePath, robotContent);
245+
const opmodePath = commonStorage.makeModulePath(projectName, 'Teleop');
246+
247+
await this._saveModule(commonStorage.MODULE_TYPE_ROBOT, modulePath, robotContent);
248+
await this._saveModule(commonStorage.MODULE_TYPE_OPMODE, opmodePath, opmodeContent);
246249
}
247250

248251
async createModule(moduleType: string, modulePath: string, moduleContent: string): Promise<void> {

src/storage/common_storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export interface Storage {
106106
fetchEntry(entryKey: string, defaultValue: string): Promise<string>;
107107
listProjects(): Promise<Project[]>;
108108
fetchModuleContent(modulePath: string): Promise<string>;
109-
createProject(projectName: string, robotContent: string): Promise<void>;
109+
createProject(projectName: string, robotContent: string, opmodeContent: string): Promise<void>;
110110
createModule(moduleType: string, modulePath: string, moduleContent: string): Promise<void>;
111111
saveModule(modulePath: string, moduleContent: string): Promise<void>;
112112
renameProject(oldProjectName: string, newProjectName: string): Promise<void>;
@@ -129,7 +129,8 @@ export async function createProject(
129129
storage: Storage, proposedUserVisibleName: string): Promise<void> {
130130
const newProjectName = pascalCaseToSnakeCase(proposedUserVisibleName);
131131
const robotContent = newRobotContent(newProjectName);
132-
await storage.createProject(newProjectName, robotContent);
132+
const opmodeContent = newOpModeContent(newProjectName, 'Teleop');
133+
await storage.createProject(newProjectName, robotContent, opmodeContent);
133134
}
134135

135136
/**

0 commit comments

Comments
 (0)