Skip to content

Commit

Permalink
Saves entry point file name pref in global state
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 10, 2024
1 parent 47965ac commit f37915e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/settings.mts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type GlobalStateType = Memento & {
};

const LAST_PROJECT_ROOT_STATE_KEY = "lastProjectRoot";
const ENTRY_POINT_NAMING_PREF = "entryPointNamingPref";

export default class Settings {
private static instance?: Settings;
Expand Down Expand Up @@ -140,4 +141,12 @@ export default class Settings {

return Uri.file(fsPath);
}

public async setEntryPointNamingPref(useProjectName: boolean): Promise<void> {
await this.globalState.update(ENTRY_POINT_NAMING_PREF, useProjectName);
}

public getEntryPointNamingPref(): boolean {
return this.globalState.get<boolean>(ENTRY_POINT_NAMING_PREF, true);
}
}
13 changes: 12 additions & 1 deletion src/webview/newProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,11 @@ export class NewProjectPanel {

if (example === undefined && !this._isProjectImport) {
const theData = data as SubmitMessageValue;

await this._settings.setEntryPointNamingPref(
theData.entryPointProjectName
);

const args: NewProjectOptions = {
name: theData.projectName,
projectRoot: projectPath,
Expand Down Expand Up @@ -1433,6 +1438,8 @@ export class NewProjectPanel {
// Restrict the webview to only load specific scripts
const nonce = getNonce();
const isWindows = process.platform === "win32";
const useProjectNameAsEntryPointFileName =
this._settings.getEntryPointNamingPref();

return `<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -1940,7 +1947,11 @@ export class NewProjectPanel {
</li>
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="entry-project-name-code-gen-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500" checked>
<input id="entry-project-name-code-gen-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500" ${
useProjectNameAsEntryPointFileName
? "checked"
: ""
}>
<label for="entry-project-name-code-gen-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">Use project name as entry point file name</label>
</div>
</li>
Expand Down

0 comments on commit f37915e

Please sign in to comment.