Skip to content

Commit 6392c7b

Browse files
committed
fix(settings): updated settings
1 parent 7324a40 commit 6392c7b

13 files changed

Lines changed: 37 additions & 33 deletions

File tree

src/app/core/services/user.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
UserSettingsGetResponse,
1616
} from '@osf/shared/models';
1717

18-
import { JsonApiService } from '../../shared/services/json-api.service';
18+
import { JsonApiService } from '../../shared/services';
1919

2020
import { environment } from 'src/environments/environment';
2121

src/app/core/store/user/user.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const USER_STATE_INITIAL: UserStateModel = {
1616
data: null,
1717
isLoading: false,
1818
isSubmitting: false,
19-
error: '',
19+
error: null,
2020
},
2121
activeFlags: [],
2222
};

src/app/core/store/user/user.state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export class UserState {
232232
})
233233
);
234234
}
235+
235236
@Action(SetUserAsModerator)
236237
setUserAsModerator(ctx: StateContext<UserStateModel>) {
237238
const state = ctx.getState();

src/app/features/settings/account-settings/components/change-password/change-password.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ <h2>{{ 'settings.accountSettings.changePassword.title' | translate }}</h2>
133133
<div class="flex justify-content-end mt-4">
134134
<p-button
135135
[label]="'settings.accountSettings.changePassword.buttons.update' | translate"
136-
(click)="changePassword()"
136+
(onClick)="changePassword()"
137137
[disabled]="passwordForm.invalid"
138138
>
139139
</p-button>

src/app/features/settings/account-settings/components/change-password/change-password.component.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
Validators,
2020
} from '@angular/forms';
2121

22+
import { AuthService } from '@core/services';
2223
import { CustomValidators, FormValidationHelper } from '@osf/shared/helpers';
2324
import { LoaderService, ToastService } from '@osf/shared/services';
2425

@@ -37,6 +38,7 @@ export class ChangePasswordComponent implements OnInit {
3738
private readonly loaderService = inject(LoaderService);
3839
private readonly toastService = inject(ToastService);
3940
private readonly destroyRef = inject(DestroyRef);
41+
private readonly authService = inject(AuthService);
4042

4143
readonly passwordForm: AccountSettingsPasswordForm = new FormGroup({
4244
[AccountSettingsPasswordFormControls.OldPassword]: new FormControl('', {
@@ -57,10 +59,10 @@ export class ChangePasswordComponent implements OnInit {
5759
}),
5860
});
5961

60-
protected readonly AccountSettingsPasswordFormControls = AccountSettingsPasswordFormControls;
61-
protected readonly FormValidationHelper = FormValidationHelper;
62+
readonly AccountSettingsPasswordFormControls = AccountSettingsPasswordFormControls;
63+
readonly FormValidationHelper = FormValidationHelper;
6264

63-
protected errorMessage = signal('');
65+
errorMessage = signal('');
6466

6567
ngOnInit(): void {
6668
this.setupFormValidation();
@@ -101,11 +103,11 @@ export class ChangePasswordComponent implements OnInit {
101103
.subscribe(() => this.passwordForm.updateValueAndValidity());
102104
}
103105

104-
protected getFormControl(controlName: string): AbstractControl | null {
106+
getFormControl(controlName: string): AbstractControl | null {
105107
return FormValidationHelper.getFormControl(this.passwordForm, controlName);
106108
}
107109

108-
protected getFormErrors(): Record<string, boolean> {
110+
getFormErrors(): Record<string, boolean> {
109111
const errors: Record<string, boolean> = {};
110112

111113
if (this.passwordForm.errors?.['sameAsOldPassword']) {
@@ -141,6 +143,7 @@ export class ChangePasswordComponent implements OnInit {
141143

142144
this.loaderService.hide();
143145
this.toastService.showSuccess('settings.accountSettings.changePassword.messages.success');
146+
this.authService.logout();
144147
},
145148
error: (error: HttpErrorResponse) => {
146149
if (error.error?.errors?.[0]?.detail) {

src/app/features/settings/account-settings/components/deactivate-account/deactivate-account.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { provideHttpClientTesting } from '@angular/common/http/testing';
1212
import { ComponentFixture, TestBed } from '@angular/core/testing';
1313
import { provideNoopAnimations } from '@angular/platform-browser/animations';
1414

15-
import { AccountSettingsService } from '@osf/features/settings/account-settings/services';
16-
import { AccountSettingsSelectors } from '@osf/features/settings/account-settings/store';
17-
import { MOCK_STORE } from '@shared/mocks';
18-
import { ToastService } from '@shared/services';
15+
import { MOCK_STORE } from '@osf/shared/mocks';
16+
import { ToastService } from '@osf/shared/services';
1917

18+
import { AccountSettingsService } from '../../services';
19+
import { AccountSettingsSelectors } from '../../store';
2020
import { CancelDeactivationComponent } from '../cancel-deactivation/cancel-deactivation.component';
2121
import { DeactivationWarningComponent } from '../deactivation-warning/deactivation-warning.component';
2222

src/app/features/settings/account-settings/components/deactivate-account/deactivate-account.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class DeactivateAccountComponent {
3535
deactivateAccount: DeactivateAccount,
3636
});
3737

38-
protected accountSettings = select(AccountSettingsSelectors.getAccountSettings);
38+
accountSettings = select(AccountSettingsSelectors.getAccountSettings);
3939

4040
deactivateAccount() {
4141
this.dialogService
@@ -51,11 +51,10 @@ export class DeactivateAccountComponent {
5151
.subscribe(() => {
5252
this.loaderService.show();
5353

54-
// [NS] Hidden to avoid issues with development
55-
// this.action.deactivateAccount().subscribe(() => {
56-
this.toastService.showSuccess('settings.accountSettings.deactivateAccount.successDeactivation');
57-
this.loaderService.hide();
58-
// });
54+
this.action.deactivateAccount().subscribe(() => {
55+
this.toastService.showSuccess('settings.accountSettings.deactivateAccount.successDeactivation');
56+
this.loaderService.hide();
57+
});
5958
});
6059
}
6160

src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export class DefaultStorageLocationComponent {
2929
private readonly loaderService = inject(LoaderService);
3030
private readonly toastService = inject(ToastService);
3131

32-
protected readonly currentUser = select(UserSelectors.getCurrentUser);
33-
protected readonly regions = select(AccountSettingsSelectors.getRegions);
34-
protected selectedRegion = signal<IdName | undefined>(undefined);
32+
readonly currentUser = select(UserSelectors.getCurrentUser);
33+
readonly regions = select(AccountSettingsSelectors.getRegions);
34+
selectedRegion = signal<IdName | undefined>(undefined);
3535

3636
constructor() {
3737
effect(() => {

src/app/features/settings/account-settings/components/share-indexing/share-indexing.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ShareIndexingComponent {
2929
private readonly toastService = inject(ToastService);
3030

3131
private readonly indexing = select(UserSelectors.getShareIndexing);
32-
protected readonly currentUser = select(UserSelectors.getCurrentUser);
32+
readonly currentUser = select(UserSelectors.getCurrentUser);
3333

3434
selectedOption = this.indexing();
3535

src/app/shared/components/add-project-form/add-project-form.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import { FormGroup, ReactiveFormsModule } from '@angular/forms';
1515
import { ProjectFormControls } from '@osf/shared/enums';
1616
import { Institution, ProjectForm } from '@osf/shared/models';
1717
import { Project } from '@osf/shared/models/projects';
18-
import { AffiliatedInstitutionSelectComponent } from '@shared/components/affiliated-institution-select/affiliated-institution-select.component';
19-
import { ProjectSelectorComponent } from '@shared/components/project-selector/project-selector.component';
20-
import { FetchUserInstitutions, InstitutionsSelectors } from '@shared/stores/institutions';
21-
import { FetchRegions, RegionsSelectors } from '@shared/stores/regions';
18+
import { FetchRegions, RegionsSelectors } from '@osf/shared/stores';
19+
import { FetchUserInstitutions, InstitutionsSelectors } from '@osf/shared/stores/institutions';
20+
21+
import { AffiliatedInstitutionSelectComponent } from '../affiliated-institution-select/affiliated-institution-select.component';
22+
import { ProjectSelectorComponent } from '../project-selector/project-selector.component';
2223

2324
@Component({
2425
selector: 'osf-add-project-form',

0 commit comments

Comments
 (0)