Skip to content

Commit

Permalink
console: Fix e2e issues
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelJankoski committed Nov 28, 2023
1 parent c19cddc commit c0af2fb
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 36 deletions.
47 changes: 32 additions & 15 deletions pkg/webui/account/containers/collaborators-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { connect, useDispatch } from 'react-redux'
import { defineMessages, useIntl } from 'react-intl'
import { bindActionCreators } from 'redux'
import { createSelector } from 'reselect'

import Icon from '@ttn-lw/components/icon'
Expand All @@ -28,12 +29,10 @@ import FetchTable from '@ttn-lw/containers/fetch-table'
import Message from '@ttn-lw/lib/components/message'

import { getCollaboratorId } from '@ttn-lw/lib/selectors/id'
import PropTypes from '@ttn-lw/lib/prop-types'
import sharedMessages from '@ttn-lw/lib/shared-messages'
import attachPromise from '@ttn-lw/lib/store/actions/attach-promise'
import {
getCollaboratorsList,
deleteCollaborator as deleteCollaboratorAction,
} from '@ttn-lw/lib/store/actions/collaborators'
import { getCollaboratorsList, deleteCollaborator } from '@ttn-lw/lib/store/actions/collaborators'
import {
selectCollaborators,
selectCollaboratorsTotalCount,
Expand All @@ -53,17 +52,9 @@ const m = defineMessages({
})

const CollaboratorsTable = props => {
const { ...rest } = props
const { clientId, currentUserId, handleDeleteCollaborator, ...rest } = props
const dispatch = useDispatch()
const intl = useIntl()
const clientId = useSelector(selectSelectedClientId)
const currentUserId = useSelector(selectUserId)

const handleDeleteCollaborator = React.useCallback(
(collaboratorID, isUsr) =>
dispatch(attachPromise(deleteCollaboratorAction('client', clientId, collaboratorID, isUsr))),
[clientId, dispatch],
)

const deleteCollaborator = React.useCallback(
async ids => {
Expand Down Expand Up @@ -203,4 +194,30 @@ const CollaboratorsTable = props => {
)
}

export default CollaboratorsTable
CollaboratorsTable.propTypes = {
clientId: PropTypes.string.isRequired,
currentUserId: PropTypes.string.isRequired,
handleDeleteCollaborator: PropTypes.func.isRequired,
}

export default connect(
state => ({
clientId: selectSelectedClientId(state),
currentUserId: selectUserId(state),
}),
dispatch => ({
...bindActionCreators(
{
handleDeleteCollaborator: attachPromise(deleteCollaborator),
},
dispatch,
),
}),
(stateProps, dispatchProps, ownProps) => ({
...stateProps,
...dispatchProps,
...ownProps,
handleDeleteCollaborator: (collaboratorID, isUsr) =>
dispatchProps.handleDeleteCollaborator('client', stateProps.clientId, collaboratorID, isUsr),
}),
)(CollaboratorsTable)
1 change: 1 addition & 0 deletions pkg/webui/console/components/pubsub-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ const PubsubForm = props => {
title={sharedMessages.provider}
name="_provider"
component={Radio.Group}
description={natsDisabled || mqttDisabled ? m.providerDescription : undefined}
disabled={natsDisabled || mqttDisabled}
>
<Radio label="NATS" value={providers.NATS} onChange={handleProviderSelect} />
Expand Down
53 changes: 32 additions & 21 deletions pkg/webui/console/containers/applications-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { connect } from 'react-redux'
import { defineMessages, FormattedNumber } from 'react-intl'
import { bindActionCreators } from 'redux'
import { createSelector } from 'reselect'

import Icon from '@ttn-lw/components/icon'
Expand All @@ -31,6 +32,7 @@ import FetchTable from '@ttn-lw/containers/fetch-table'
import Message from '@ttn-lw/lib/components/message'
import DateTime from '@ttn-lw/lib/components/date-time'

import PropTypes from '@ttn-lw/lib/prop-types'
import sharedMessages from '@ttn-lw/lib/shared-messages'
import attachPromise from '@ttn-lw/lib/store/actions/attach-promise'

Expand All @@ -39,7 +41,7 @@ import { isOtherClusterApp } from '@console/lib/application-utils'

import {
deleteApplication,
restoreApplication as restoreApplicationAction,
restoreApplication,
getApplicationsList,
} from '@console/store/actions/applications'

Expand Down Expand Up @@ -75,28 +77,11 @@ const tabs = [
]

const ApplicationsTable = props => {
const { ...rest } = props
const isAdmin = useSelector(selectUserIsAdmin)

const dispatch = useDispatch()
const { isAdmin, restoreApplication, purgeApplication, ...rest } = props

const [tab, setTab] = React.useState(OWNED_TAB)
const isDeletedTab = tab === DELETED_TAB

const purgeApplication = React.useCallback(
id => {
dispatch(attachPromise(deleteApplication(id, { purge: true })))
},
[dispatch],
)

const restoreApplication = React.useCallback(
id => {
dispatch(attachPromise(restoreApplicationAction(id)))
},
[dispatch],
)

const handleRestore = React.useCallback(
async id => {
try {
Expand Down Expand Up @@ -305,4 +290,30 @@ const ApplicationsTable = props => {
)
}

export default ApplicationsTable
ApplicationsTable.propTypes = {
isAdmin: PropTypes.bool.isRequired,
purgeApplication: PropTypes.func.isRequired,
restoreApplication: PropTypes.func.isRequired,
}

export default connect(
state => ({
isAdmin: selectUserIsAdmin(state),
}),
dispatch => ({
...bindActionCreators(
{
purgeApplication: attachPromise(deleteApplication),
restoreApplication: attachPromise(restoreApplication),
},
dispatch,
),
}),
(stateProps, dispatchProps, ownProps) => ({
...stateProps,
...dispatchProps,
...ownProps,
purgeApplication: id => dispatchProps.purgeApplication(id, { purge: true }),
restoreApplication: id => dispatchProps.restoreApplication(id),
}),
)(ApplicationsTable)

0 comments on commit c0af2fb

Please sign in to comment.