Skip to content

Commit

Permalink
console: Fix locale issues
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelJankoski committed Nov 28, 2023
1 parent 07556e7 commit 21fad62
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 431 deletions.
2 changes: 1 addition & 1 deletion pkg/webui/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Header from '@ttn-lw/components/header'

import WithLocale from '@ttn-lw/lib/components/with-locale'
import { ErrorView } from '@ttn-lw/lib/components/error-view'
import FullViewError from '@ttn-lw/lib/components/full-view-error'
import { FullViewError } from '@ttn-lw/lib/components/full-view-error'
import Init from '@ttn-lw/lib/components/init'

import Logo from '@account/containers/logo'
Expand Down
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)
2 changes: 1 addition & 1 deletion pkg/webui/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BreadcrumbsProvider } from '@ttn-lw/components/breadcrumbs/context'
import Header from '@ttn-lw/components/header'

import { ErrorView } from '@ttn-lw/lib/components/error-view'
import FullViewError from '@ttn-lw/lib/components/full-view-error'
import { FullViewError } from '@ttn-lw/lib/components/full-view-error'
import Init from '@ttn-lw/lib/components/init'
import WithLocale from '@ttn-lw/lib/components/with-locale'

Expand Down
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
22 changes: 22 additions & 0 deletions pkg/webui/lib/components/full-view-error/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright © 2020 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { connect } from 'react-redux'

import { selectOnlineStatus } from '@ttn-lw/lib/store/selectors/status'

export default ErrorView =>
connect(state => ({
onlineStatus: selectOnlineStatus(state),
}))(ErrorView)
Loading

0 comments on commit 21fad62

Please sign in to comment.