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

Refactor old components #6724

Merged
merged 21 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f0d3f0e
console: Removed and refactored withFeatureRequirement HOC
PavelJankoski Nov 27, 2023
35919ef
console: Removed and refactored withConnectionReactor HOC
PavelJankoski Nov 27, 2023
fb8b90e
console: Refactor connect in owners select
PavelJankoski Nov 27, 2023
645b13e
console: Refactor connect in organization events and device title sec…
PavelJankoski Nov 27, 2023
49fb55c
console: Refactor connect in application events
PavelJankoski Nov 27, 2023
f2d6bee
console: Refactor connect in uplink form
PavelJankoski Nov 28, 2023
22a31f7
console: Refactor connect in fw version select
PavelJankoski Nov 28, 2023
baae71b
console: Refactor connect in hw version select
PavelJankoski Nov 28, 2023
1055729
console: Change useParams with props
PavelJankoski Nov 28, 2023
6659f18
console: Refactor connect in device card
PavelJankoski Nov 28, 2023
171219c
console: Refactor connect in downlink form
PavelJankoski Nov 28, 2023
9ddc38a
console: Refactor connect in model select
PavelJankoski Nov 28, 2023
6c1a051
console: Refactor connect in brand select
PavelJankoski Nov 28, 2023
ba481b6
console: Refactor connect in gateway connection form
PavelJankoski Nov 28, 2023
c5632ce
console: Refactor connect in full view error
PavelJankoski Nov 28, 2023
2df18cc
console: Refactor connect in gateway connection reactor
PavelJankoski Nov 28, 2023
0c1acb1
console: Refactor connect in gateway events
PavelJankoski Nov 28, 2023
8badbf2
console: Refactor connect in device events
PavelJankoski Nov 28, 2023
07556e7
console: Refactor connect in collaborators table
PavelJankoski Nov 28, 2023
21fad62
console: Fix locale issues
PavelJankoski Nov 28, 2023
22127c9
console: Removed commented code
PavelJankoski Nov 29, 2023
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
Prev Previous commit
Next Next commit
console: Refactor connect in application events
PavelJankoski committed Nov 27, 2023
commit 49fb55c1d672668e636a5db3be0a1bce4fa99733
78 changes: 35 additions & 43 deletions pkg/webui/console/containers/application-events/index.js
Original file line number Diff line number Diff line change
@@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React, { useMemo } from 'react'
import { connect } from 'react-redux'
import React, { useCallback, useMemo } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useParams } from 'react-router-dom'

import Events from '@console/components/events'

@@ -38,17 +39,37 @@ import {
} from '@console/store/selectors/applications'

const ApplicationEvents = props => {
const {
appId,
events,
widget,
paused,
onClear,
onPauseToggle,
truncated,
onFilterChange,
filter,
} = props
const { appId } = useParams()
const { widget } = props

const events = useSelector(state => selectApplicationEvents(state, appId))
const paused = useSelector(state => selectApplicationEventsPaused(state, appId))
const truncated = useSelector(state => selectApplicationEventsTruncated(state, appId))
const filter = useSelector(state => selectApplicationEventsFilter(state, appId))

const dispatch = useDispatch()

const onClear = useCallback(() => {
dispatch(clearApplicationEventsStream(appId))
}, [appId, dispatch])

const onPauseToggle = useCallback(
paused => {
if (paused) {
dispatch(resumeApplicationEventsStream(appId))
return
}
dispatch(pauseApplicationEventsStream(appId))
},
[appId, dispatch],
)

const onFilterChange = useCallback(
filterId => {
dispatch(setApplicationEventsFilter(appId, filterId))
},
[appId, dispatch],
)

const content = useMemo(() => {
if (widget) {
@@ -75,40 +96,11 @@ const ApplicationEvents = props => {
}

ApplicationEvents.propTypes = {
appId: PropTypes.string.isRequired,
events: PropTypes.events,
filter: PropTypes.eventFilter,
onClear: PropTypes.func.isRequired,
onFilterChange: PropTypes.func.isRequired,
onPauseToggle: PropTypes.func.isRequired,
paused: PropTypes.bool.isRequired,
truncated: PropTypes.bool.isRequired,
widget: PropTypes.bool,
}

ApplicationEvents.defaultProps = {
widget: false,
events: [],
filter: undefined,
}

export default connect(
(state, props) => {
const { appId } = props

return {
events: selectApplicationEvents(state, appId),
paused: selectApplicationEventsPaused(state, appId),
truncated: selectApplicationEventsTruncated(state, appId),
filter: selectApplicationEventsFilter(state, appId),
}
},
(dispatch, ownProps) => ({
onClear: () => dispatch(clearApplicationEventsStream(ownProps.appId)),
onPauseToggle: paused =>
paused
? dispatch(resumeApplicationEventsStream(ownProps.appId))
: dispatch(pauseApplicationEventsStream(ownProps.appId)),
onFilterChange: filterId => dispatch(setApplicationEventsFilter(ownProps.appId, filterId)),
}),
)(ApplicationEvents)
export default ApplicationEvents