diff --git a/.changeset/green-garlics-cheer.md b/.changeset/green-garlics-cheer.md new file mode 100644 index 0000000..fcd194b --- /dev/null +++ b/.changeset/green-garlics-cheer.md @@ -0,0 +1,5 @@ +--- +"specif-ai": patch +--- + +refactor: Consolidate root directory selection into settings modal diff --git a/ui/src/app/components/layout/header/header.component.html b/ui/src/app/components/layout/header/header.component.html index ac91bb9..7974ae2 100644 --- a/ui/src/app/components/layout/header/header.component.html +++ b/ui/src/app/components/layout/header/header.component.html @@ -21,31 +21,15 @@

-
-
- -
- - -
+
diff --git a/ui/src/app/components/layout/header/header.component.ts b/ui/src/app/components/layout/header/header.component.ts index cf8e855..aee7b81 100644 --- a/ui/src/app/components/layout/header/header.component.ts +++ b/ui/src/app/components/layout/header/header.component.ts @@ -1,10 +1,6 @@ import { Component, inject } from '@angular/core'; -import { APP_CONSTANTS } from '../../../constants/app.constants'; -import { SelectRootDirectoryComponent } from '../../select-root-directory/select-root-directory.component'; import { MatDialog } from '@angular/material/dialog'; -import { ElectronService } from '../../../services/electron/electron.service'; -import { NGXLogger } from 'ngx-logger'; -import { Router, RouterLink } from '@angular/router'; +import { RouterLink } from '@angular/router'; import { SettingsComponent } from '../../settings/settings.component'; import { AuthService } from '../../../services/auth/auth.service'; import { environment } from '../../../../environments/environment'; @@ -12,11 +8,7 @@ import { NgIconComponent, provideIcons } from '@ng-icons/core'; import { BreadcrumbsComponent } from '../../core/breadcrumbs/breadcrumbs.component'; import { AsyncPipe, NgIf } from '@angular/common'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { - heroArrowRightOnRectangle, - heroCog8Tooth, - heroFolder, -} from '@ng-icons/heroicons/outline'; +import { heroCog8Tooth } from '@ng-icons/heroicons/outline'; @Component({ selector: 'app-header', @@ -31,55 +23,13 @@ import { AsyncPipe, MatTooltipModule, ], - viewProviders: [ - provideIcons({ heroCog8Tooth, heroFolder, heroArrowRightOnRectangle }), - ], + viewProviders: [provideIcons({ heroCog8Tooth })], }) export class HeaderComponent { protected themeConfiguration = environment.ThemeConfiguration; authService = inject(AuthService); - electronService = inject(ElectronService); - logger = inject(NGXLogger); dialog = inject(MatDialog); - router = inject(Router); - - /** - * Prompts the user to select a root directory, saves the selected directory to local storage, - * and navigates to the '/apps' route or reloads the current page based on the current URL. - * - * @return {Promise} A promise that resolves when the directory selection and navigation are complete. - */ - async selectRootDirectory(): Promise { - const response = await this.electronService.openDirectory(); - this.logger.debug(response); - if (response.length > 0) { - localStorage.setItem(APP_CONSTANTS.WORKING_DIR, response[0]); - const currentConfig = - (await this.electronService.getStoreValue('APP_CONFIG')) || {}; - const updatedConfig = { ...currentConfig, directoryPath: response[0] }; - await this.electronService.setStoreValue('APP_CONFIG', updatedConfig); - - this.logger.debug('===>', this.router.url); - if (this.router.url === '/apps') { - await this.electronService.reloadApp(); - } else { - await this.router.navigate(['/apps']); - } - } - } - - openSelectRootDirectoryModal() { - const modalRef = this.dialog.open(SelectRootDirectoryComponent, { - disableClose: true, - }); - - modalRef.afterClosed().subscribe((res) => { - if (res === true) { - this.selectRootDirectory().then(); - } - }); - } openSettingsModal() { this.dialog.open(SettingsComponent, { diff --git a/ui/src/app/components/select-root-directory/select-root-directory.component.html b/ui/src/app/components/select-root-directory/select-root-directory.component.html deleted file mode 100644 index 9a2c235..0000000 --- a/ui/src/app/components/select-root-directory/select-root-directory.component.html +++ /dev/null @@ -1,35 +0,0 @@ - diff --git a/ui/src/app/components/select-root-directory/select-root-directory.component.scss b/ui/src/app/components/select-root-directory/select-root-directory.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/ui/src/app/components/select-root-directory/select-root-directory.component.spec.ts b/ui/src/app/components/select-root-directory/select-root-directory.component.spec.ts deleted file mode 100644 index cf7ecb1..0000000 --- a/ui/src/app/components/select-root-directory/select-root-directory.component.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { SelectRootDirectoryComponent } from './select-root-directory.component'; - -describe('SelectRootDirectoryComponent', () => { - let component: SelectRootDirectoryComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [SelectRootDirectoryComponent] - }); - fixture = TestBed.createComponent(SelectRootDirectoryComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/ui/src/app/components/select-root-directory/select-root-directory.component.ts b/ui/src/app/components/select-root-directory/select-root-directory.component.ts deleted file mode 100644 index b5a6770..0000000 --- a/ui/src/app/components/select-root-directory/select-root-directory.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; -import { NgIconComponent } from '@ng-icons/core'; -import { environment } from 'src/environments/environment'; -import { APP_CONSTANTS } from '../../constants/app.constants'; -import { NgIf } from '@angular/common'; -import { ButtonComponent } from '../core/button/button.component'; - -@Component({ - selector: 'app-select-root-directory', - templateUrl: './select-root-directory.component.html', - styleUrls: ['./select-root-directory.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [NgIconComponent, ButtonComponent], -}) -export class SelectRootDirectoryComponent { - workingDir: string | null; - appName = environment.ThemeConfiguration.appName; - - constructor(private modalRef: MatDialogRef) { - this.workingDir = localStorage.getItem(APP_CONSTANTS.WORKING_DIR); - } - - openFolderSelector() { - this.modalRef.close(true); - } - - closeModal() { - this.modalRef.close(false); - } -} diff --git a/ui/src/app/components/settings/settings.component.html b/ui/src/app/components/settings/settings.component.html index 30a927a..917afbc 100644 --- a/ui/src/app/components/settings/settings.component.html +++ b/ui/src/app/components/settings/settings.component.html @@ -1,9 +1,9 @@ -

+ +
+ +
+ + +
+
+
} A promise that resolves when the directory selection and navigation are complete. + */ + async selectRootDirectory(): Promise { + const response = await this.electronService.openDirectory(); + this.logger.debug(response); + if (response.length > 0) { + localStorage.setItem(APP_CONSTANTS.WORKING_DIR, response[0]); + const currentConfig = + (await this.electronService.getStoreValue('APP_CONFIG')) || {}; + const updatedConfig = { ...currentConfig, directoryPath: response[0] }; + await this.electronService.setStoreValue('APP_CONFIG', updatedConfig); + + this.logger.debug('===>', this.router.url); + if (this.router.url === '/apps') { + await this.electronService.reloadApp(); + } else { + await this.router.navigate(['/apps']); + } + } + } + + openFolderSelector() { + this.selectRootDirectory().then(); + this.modalRef.close(true); + } ngOnInit(): void { this.subscriptions.add( diff --git a/ui/src/app/pages/create-solution/create-solution.component.ts b/ui/src/app/pages/create-solution/create-solution.component.ts index 84bbbfb..f4f6f6c 100644 --- a/ui/src/app/pages/create-solution/create-solution.component.ts +++ b/ui/src/app/pages/create-solution/create-solution.component.ts @@ -15,7 +15,6 @@ import { NGXLogger } from 'ngx-logger'; import { AppSystemService } from '../../services/app-system/app-system.service'; import { ElectronService } from '../../services/electron/electron.service'; import { ToasterService } from '../../services/toaster/toaster.service'; -import { SelectRootDirectoryComponent } from '../../components/select-root-directory/select-root-directory.component'; import { NgIf } from '@angular/common'; import { NgxLoadingModule } from 'ngx-loading'; import { ButtonComponent } from '../../components/core/button/button.component'; @@ -27,6 +26,7 @@ import { import { InputFieldComponent } from '../../components/core/input-field/input-field.component'; import { TextareaFieldComponent } from '../../components/core/textarea-field/textarea-field.component'; import { ToggleComponent } from '../../components/toggle/toggle.component'; +import { SettingsComponent } from 'src/app/components/settings/settings.component'; @Component({ selector: 'app-create-solution', @@ -116,14 +116,9 @@ export class CreateSolutionComponent implements OnInit { } openSelectRootDirectoryModal() { - const modalRef = this.dialog.open(SelectRootDirectoryComponent, { + this.dialog.open(SettingsComponent, { disableClose: true, }); - modalRef.afterClosed().subscribe((res) => { - if (res === true) { - this.selectRootDirectory().then(); - } - }); } async selectRootDirectory(): Promise {