Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user settings part 1 - setting SSH key and impersistent blocking toast notifications #1088

Merged
merged 3 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 31 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,13 +14,16 @@ import {
SET_DEFAULT_TIMEZONE,
SET_USB_AUTOSHARE,
SET_USB_FILTER,
SET_USER,
SET_USER_FILTER_PERMISSION,
SET_USER_GROUPS,
SET_USER_SESSION_TIMEOUT_INTERVAL,
SET_WEBSOCKET,
SHOW_TOKEN_EXPIRED_MSG,
START_SCHEDULER_FIXED_DELAY,
START_SCHEDULER_FOR_RESUMING_NOTIFICATIONS,
STOP_SCHEDULER_FIXED_DELAY,
STOP_SCHEDULER_FOR_RESUMING_NOTIFICATIONS,
UPDATE_PAGING_DATA,
} from '_/constants'

Expand Down Expand Up @@ -67,6 +71,19 @@ export function stopSchedulerFixedDelay () {
return { type: STOP_SCHEDULER_FIXED_DELAY }
}

export function startSchedulerForResumingNotifications (delayInSeconds) {
return {
type: START_SCHEDULER_FOR_RESUMING_NOTIFICATIONS,
payload: {
delayInSeconds,
},
}
}

export function stopSchedulerForResumingNotifications () {
return { type: STOP_SCHEDULER_FOR_RESUMING_NOTIFICATIONS }
}

export function setUserFilterPermission (filter) {
return {
type: SET_USER_FILTER_PERMISSION,
Expand Down Expand Up @@ -194,6 +211,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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could inline the argument type in most of these actions just fine.

And the response could be a "GenericActionType".

I'm ok with generic Object, but some extra type info could be helpful...

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,
sjd78 marked this conversation as resolved.
Show resolved Hide resolved
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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the exact object type here as you do below.

userOptions: UserOptionsType
}
}

export type SaveGlobalOptionsActionType = {
type: C.SAVE_GLOBAL_OPTIONS,
payload: {|
updateRate?: number,
language?: string,
showNotifications?: boolean,
notificationSnoozeDuration?: number,
sshKey?: string
|},
meta: {|
transactionId: string
|}
}
10 changes: 10 additions & 0 deletions src/actions/userMessages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ADD_USER_MESSAGE,
AUTO_ACKNOWLEDGE,
CLEAR_USER_MSGS,
DISMISS_EVENT,
DISMISS_USER_MSG,
Expand All @@ -23,6 +24,15 @@ export function clearUserMessages () {
return { type: CLEAR_USER_MSGS }
}

export function setAutoAcknowledge (autoAcknowledge) {
return {
type: AUTO_ACKNOWLEDGE,
payload: {
autoAcknowledge,
},
}
}

export function setNotificationNotified ({ eventId }) {
return {
type: SET_USERMSG_NOTIFIED,
Expand Down
11 changes: 8 additions & 3 deletions src/components/CounterAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,35 @@ class CounterAlert extends React.Component {
this.timer = null
}
this.setState({ showAlert: false })
this.props.onDismiss()
}

render () {
const { title, type } = this.props
const { title, type, children } = this.props
return this.state.showAlert &&
<Alert type={type} onDismiss={this.handleDismiss} className={style['text-align-left']}>
{title}
{children}
</Alert>
}
}

CounterAlert.propTypes = {
title: PropTypes.string.isRequired,

title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
children: PropTypes.node,
/**
* A timeout of <= 0 will force a manual dismiss of the alert.
*/
timeout: PropTypes.number,

type: PropTypes.string,

onDismiss: PropTypes.func,
}

CounterAlert.defaultProps = {
type: 'success',
onDismiss: () => {},
}

export default CounterAlert
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.

Loading