UI: Clear code and rename state action

This commit is contained in:
Vladyslav_Prykhodko 2023-07-28 15:51:21 +03:00
parent 2d2117e9ac
commit b71ae531bb
7 changed files with 13 additions and 18 deletions

View File

@ -27,7 +27,7 @@ export enum AuthActionTypes {
UPDATE_LAST_PUBLIC_DASHBOARD_ID = '[Auth] Update Last Public Dashboard Id',
UPDATE_HAS_REPOSITORY = '[Auth] Change Has Repository',
UPDATE_OPENED_MENU_SECTION = '[Preferences] Update Opened Menu Section',
UPDATE_USER_SETTINGS = '[Preferences] Update user settings',
PUT_USER_SETTINGS = '[Preferences] Put user settings',
DELETE_USER_SETTINGS = '[Preferences] Delete user settings',
}
@ -71,8 +71,8 @@ export class ActionPreferencesUpdateOpenedMenuSection implements Action {
constructor(readonly payload: { path: string; opened: boolean }) {}
}
export class ActionPreferencesUpdateUserSettings implements Action {
readonly type = AuthActionTypes.UPDATE_USER_SETTINGS;
export class ActionPreferencesPutUserSettings implements Action {
readonly type = AuthActionTypes.PUT_USER_SETTINGS;
constructor(readonly payload: Partial<UserSettings>) {}
}
@ -85,4 +85,4 @@ export class ActionPreferencesDeleteUserSettings implements Action {
export type AuthActions = ActionAuthAuthenticated | ActionAuthUnauthenticated |
ActionAuthLoadUser | ActionAuthUpdateUserDetails | ActionAuthUpdateLastPublicDashboardId | ActionAuthUpdateHasRepository |
ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesUpdateUserSettings | ActionPreferencesDeleteUserSettings;
ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings;

View File

@ -40,9 +40,9 @@ export class AuthEffects {
mergeMap(([action, state]) => this.userSettingsService.putUserSettings({ openedMenuSections: state.userSettings.openedMenuSections }))
), {dispatch: false});
updatedUserSettings = createEffect(() => this.actions$.pipe(
putUserSettings = createEffect(() => this.actions$.pipe(
ofType(
AuthActionTypes.UPDATE_USER_SETTINGS,
AuthActionTypes.PUT_USER_SETTINGS,
),
mergeMap((state) => this.userSettingsService.putUserSettings(state.payload))
), {dispatch: false});

View File

@ -76,7 +76,7 @@ export const authReducer = (
userSettings = {...state.userSettings, ...{ openedMenuSections: Array.from(openedMenuSections)}};
return { ...state, ...{ userSettings }};
case AuthActionTypes.UPDATE_USER_SETTINGS:
case AuthActionTypes.PUT_USER_SETTINGS:
userSettings = {...state.userSettings, ...action.payload};
return { ...state, ...{ userSettings }};

View File

@ -355,7 +355,9 @@ const SNAKE_CASE_REGEXP = /[A-Z]/g;
export function snakeCase(name: string, separator: string): string {
separator = separator || '_';
return name.replace(SNAKE_CASE_REGEXP, (letter, pos) => (pos ? separator : '') + letter.toLowerCase());
return name.replace(SNAKE_CASE_REGEXP, (letter, pos) => {
return (pos ? separator : '') + letter.toLowerCase();
});
}
export function getDescendantProp(obj: any, path: string): any {

View File

@ -40,7 +40,7 @@ import {
NetworkTransportType,
PublishTelemetryCommand
} from '@shared/models/device.models';
import { ActionPreferencesUpdateUserSettings } from '@core/auth/auth.actions';
import { ActionPreferencesPutUserSettings } from '@core/auth/auth.actions';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { getOS } from '@core/utils';
@ -121,7 +121,7 @@ export class DeviceCheckConnectivityDialogComponent extends
close(): void {
if (this.notShowAgain && this.showDontShowAgain) {
this.store.dispatch(new ActionPreferencesUpdateUserSettings({ notDisplayConnectivityAfterAddDevice: true }));
this.store.dispatch(new ActionPreferencesPutUserSettings({ notDisplayConnectivityAfterAddDevice: true }));
this.dialogRef.close(null);
} else {
this.dialogRef.close(null);

View File

@ -88,7 +88,7 @@
}
}
a:not(.ignore-style-a) {
a {
font-weight: 500;
color: #2a7dec;
text-decoration: none;

View File

@ -152,13 +152,6 @@
&.space-between {
justify-content: space-between;
}
&.no-border {
border: none;
border-radius: 0;
}
&.no-padding {
padding: 0;
}
.mat-divider-vertical {
height: 56px;
margin-top: -7px;