Skip to content

Commit

Permalink
Add Account Settings
Browse files Browse the repository at this point in the history
Summary:
1. Remove existing Options dialog
   a) move SSH Key to Account Settings
   b) continue using existing REST endpoint: users/${id}/sshpublickeys
2. support following (local) settings via Redux-store:
   a) showNotifications (do not disturb)
   b) notificationSnoozeDuration (do not disturb for)
3. add typing for user settings related entities
4. in Settings use data-driven 3-way diff for change detection.
   Change is detected by comparing current content of Redux store
   with user changes(draft values) and base values(store content
   before at the beginning of user settings updates)
  • Loading branch information
rszwajko committed Nov 26, 2020
1 parent 5b5a864 commit 7abd886
Show file tree
Hide file tree
Showing 38 changed files with 1,122 additions and 258 deletions.
2 changes: 2 additions & 0 deletions packaging/ovirt-web-ui.war/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<servlet-name>logout</servlet-name>
<servlet-class>org.ovirt.engine.core.aaa.servlet.SsoLogoutServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>logout</servlet-name>
<url-pattern>/sso/logout</url-pattern>
Expand Down Expand Up @@ -124,6 +125,7 @@
<servlet-name>index</servlet-name>
<url-pattern>/vm/*</url-pattern>
<url-pattern>/pool/*</url-pattern>
<url-pattern>/settings/*</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
Expand Down
17 changes: 16 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import AppConfiguration from '../config'
import AppConfiguration from '_/config'
import {
APP_CONFIGURED,
CHANGE_PAGE,
CHECK_TOKEN_EXPIRED,
GET_BY_PAGE,
GET_OPTION,
GET_USER,
GET_USER_GROUPS,
MANUAL_REFRESH,
SET_ADMINISTRATOR,
Expand All @@ -13,6 +14,7 @@ import {
SET_DEFAULT_TIMEZONE,
SET_USB_AUTOSHARE,
SET_USB_FILTER,
SET_USER,
SET_USER_FILTER_PERMISSION,
SET_USER_GROUPS,
SET_USER_SESSION_TIMEOUT_INTERVAL,
Expand Down Expand Up @@ -194,6 +196,19 @@ export function getUserGroups () {
return { type: GET_USER_GROUPS }
}

export function setUser ({ user }) {
return {
type: SET_USER,
payload: {
user,
},
}
}

export function getUser () {
return { type: GET_USER }
}

export function setCpuTopologyOptions ({
maxNumberOfSockets,
maxNumberOfCores,
Expand Down
107 changes: 104 additions & 3 deletions src/actions/options.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
// @flow

import type { UserOptionsType, SshKeyType } from '_/ovirtapi/types'
import type { LoadUserOptionsActionType, SaveGlobalOptionsActionType } from '_/actions/types'

import {
GET_CONSOLE_OPTIONS,
SAVE_CONSOLE_OPTIONS,
SET_CONSOLE_OPTIONS,
GET_SSH_KEY,
SAVE_GLOBAL_OPTIONS,
SAVE_SSH_KEY,
SET_SSH_KEY,
SET_OPTION,
LOAD_USER_OPTIONS,
LOAD_USER_OPTIONS_IN_PROGRESS,
LOAD_USER_OPTIONS_FINISHED,
PERSIST_OPTIONS,
} from '_/constants'

export function setConsoleOptions ({ vmId, options }) {
export function setConsoleOptions ({ vmId, options }: Object): Object {
return {
type: SET_CONSOLE_OPTIONS,
payload: {
Expand All @@ -14,7 +28,7 @@ export function setConsoleOptions ({ vmId, options }) {
}
}

export function getConsoleOptions ({ vmId }) {
export function getConsoleOptions ({ vmId }: Object): Object {
return {
type: GET_CONSOLE_OPTIONS,
payload: {
Expand All @@ -23,7 +37,7 @@ export function getConsoleOptions ({ vmId }) {
}
}

export function saveConsoleOptions ({ vmId, options }) {
export function saveConsoleOptions ({ vmId, options }: Object): Object {
return {
type: SAVE_CONSOLE_OPTIONS,
payload: {
Expand All @@ -32,3 +46,90 @@ export function saveConsoleOptions ({ vmId, options }) {
},
}
}

export function getSSHKey ({ userId }: Object): Object {
return {
type: GET_SSH_KEY,
payload: {
userId,
},
}
}

export function setSSHKey ({ key, id }: SshKeyType): Object {
return {
type: SET_SSH_KEY,
payload: {
key,
id,
},
}
}

export function setOption ({ key, value }: Object): Object {
return {
type: SET_OPTION,
payload: {
key,
value,
},
}
}

export function loadUserOptions (userOptions: UserOptionsType): LoadUserOptionsActionType {
return {
type: LOAD_USER_OPTIONS,
payload: {
userOptions,
},
}
}

export function loadingUserOptionsInProgress (): Object {
return {
type: LOAD_USER_OPTIONS_IN_PROGRESS,
}
}

export function loadingUserOptionsFinished (): Object {
return {
type: LOAD_USER_OPTIONS_FINISHED,
}
}

export function saveGlobalOptions ({ values: { sshKey, language, showNotifications, notificationSnoozeDuration, updateRate } = {} }: Object, { transactionId }: Object): SaveGlobalOptionsActionType {
return {
type: SAVE_GLOBAL_OPTIONS,
payload: {
sshKey,
language,
showNotifications,
notificationSnoozeDuration,
updateRate,
},
meta: {
transactionId,
},
}
}

export function saveSSHKey ({ key, userId, sshId }: Object): Object {
return {
type: SAVE_SSH_KEY,
payload: {
key,
userId,
sshId,
},
}
}

export function persistUserOptions ({ options, userId }: Object): Object {
return {
type: PERSIST_OPTIONS,
payload: {
options,
userId,
},
}
}
24 changes: 24 additions & 0 deletions src/actions/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @flow
import * as C from '_/constants'
import type { UserOptionsType } from '_/ovirtapi/types'

export type LoadUserOptionsActionType = {
type: C.LOAD_USER_OPTIONS,
payload: {
userOptions: UserOptionsType
}
}

export type SaveGlobalOptionsActionType = {
type: C.SAVE_GLOBAL_OPTIONS,
payload: {|
updateRate?: number,
language?: string,
showNotifications?: boolean,
notificationSnoozeDuration?: number,
sshKey?: string
|},
meta: {|
transactionId: string
|}
}
35 changes: 0 additions & 35 deletions src/components/OptionsDialog/actions.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/OptionsDialog/constants.js

This file was deleted.

122 changes: 0 additions & 122 deletions src/components/OptionsDialog/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/components/OptionsDialog/reducer.js

This file was deleted.

Loading

0 comments on commit 7abd886

Please sign in to comment.