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

Remove linking references #3614

Merged
merged 2 commits into from
Dec 29, 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
9 changes: 0 additions & 9 deletions cypress/integration/console/applications/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ describe('Application create', () => {
'Optional application description; can also be used to save notes about the application',
)
.and('be.visible')
cy.findByLabelText('Linking')
.should('be.visible')
.should('have.attr', 'value', 'true')
cy.findByLabelText('Network Server address').should('be.visible')
cy.findDescriptionByLabelText('Network Server address')
.should('contain', 'Leave empty to link to the Network Server in the same cluster')
.and('be.visible')
cy.findByRole('button', { name: 'Create application' }).should('be.visible')
})

Expand Down Expand Up @@ -116,8 +109,6 @@ describe('Application create', () => {
'Optional application description; can also be used to save notes about the application',
)
.and('be.visible')
cy.findByLabelText('Linking').should('not.exist')
cy.findByLabelText('Network Server address').should('not.exist')
cy.findByRole('button', { name: 'Create application' }).should('be.visible')
})
})
Expand Down
2 changes: 0 additions & 2 deletions pkg/webui/console/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ export default {
link: {
get: tts.Applications.Link.get.bind(tts.Applications.Link),
set: tts.Applications.Link.set.bind(tts.Applications.Link),
delete: tts.Applications.Link.delete.bind(tts.Applications.Link),
stats: tts.Applications.Link.getStats.bind(tts.Applications.Link),
},
collaborators: {
getOrganization: tts.Applications.Collaborators.getByOrganizationId.bind(
Expand Down
10 changes: 1 addition & 9 deletions pkg/webui/console/components/payload-formatters-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ class PayloadFormattersForm extends React.Component {
}

get formatter() {
const { linked } = this.props

if (!linked) {
return null
}

const { type } = this.state

switch (type) {
Expand Down Expand Up @@ -168,7 +162,7 @@ class PayloadFormattersForm extends React.Component {
}

render() {
const { initialType, initialParameter, linked, uplink, allowReset } = this.props
const { initialType, initialParameter, uplink, allowReset } = this.props
const { error, type } = this.state

const initialValues = {
Expand All @@ -182,7 +176,6 @@ class PayloadFormattersForm extends React.Component {
return (
<div>
<Form
disabled={!linked}
submitEnabledWhenInvalid
onSubmit={this.handleSubmit}
initialValues={initialValues}
Expand Down Expand Up @@ -218,7 +211,6 @@ PayloadFormattersForm.propTypes = {
allowReset: PropTypes.bool,
initialParameter: PropTypes.string,
initialType: PropTypes.oneOf(Object.values(TYPES)).isRequired,
linked: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onSubmitFailure: PropTypes.func,
onSubmitSuccess: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import PropTypes from '@ttn-lw/lib/prop-types'
import { updateApplicationLinkSuccess } from '@console/store/actions/link'

import {
selectApplicationIsLinked,
selectApplicationLinkFormatters,
selectSelectedApplicationId,
} from '@console/store/selectors/applications'
Expand All @@ -47,18 +46,17 @@ const m = defineMessages({
'These payload formatters are executed on downlink messages to all end devices in this application. Note: end device level payload formatters have precedence.',
})
@connect(
function(state) {
state => {
const formatters = selectApplicationLinkFormatters(state) || {}

return {
appId: selectSelectedApplicationId(state),
linked: selectApplicationIsLinked(state) || false,
formatters,
}
},
{ updateLinkSuccess: updateApplicationLinkSuccess },
)
@withBreadcrumb('apps.single.payload-formatters.downlink', function(props) {
@withBreadcrumb('apps.single.payload-formatters.downlink', props => {
const { appId } = props

return (
Expand All @@ -72,7 +70,6 @@ class ApplicationPayloadFormatters extends React.PureComponent {
static propTypes = {
appId: PropTypes.string.isRequired,
formatters: PropTypes.formatters.isRequired,
linked: PropTypes.bool.isRequired,
updateLinkSuccess: PropTypes.func.isRequired,
}

Expand Down Expand Up @@ -102,19 +99,14 @@ class ApplicationPayloadFormatters extends React.PureComponent {
}

render() {
const { formatters, linked } = this.props

const applicationFormatterInfo = (
<Notification className={style.notification} small info content={m.infoText} />
)
const { formatters } = this.props

return (
<React.Fragment>
<PageTitle title={sharedMessages.payloadFormattersDownlink} />
{linked && applicationFormatterInfo}
<Notification className={style.notification} small info content={m.infoText} />
<PayloadFormattersForm
uplink={false}
linked={linked}
onSubmit={this.onSubmit}
onSubmitSuccess={this.onSubmitSuccess}
title={sharedMessages.payloadFormattersDownlink}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import PropTypes from '@ttn-lw/lib/prop-types'
import { updateApplicationLinkSuccess } from '@console/store/actions/link'

import {
selectApplicationIsLinked,
selectApplicationLinkFormatters,
selectSelectedApplicationId,
} from '@console/store/selectors/applications'
Expand All @@ -47,18 +46,17 @@ const m = defineMessages({
'These payload formatters are executed on uplink messages from all end devices in this application. Note: end device level payload formatters have precedence.',
})
@connect(
function(state) {
state => {
const formatters = selectApplicationLinkFormatters(state) || {}

return {
appId: selectSelectedApplicationId(state),
linked: selectApplicationIsLinked(state) || false,
formatters,
}
},
{ updateLinkSuccess: updateApplicationLinkSuccess },
)
@withBreadcrumb('apps.single.payload-formatters.uplink', function(props) {
@withBreadcrumb('apps.single.payload-formatters.uplink', props => {
const { appId } = props

return (
Expand All @@ -72,7 +70,6 @@ class ApplicationPayloadFormatters extends React.PureComponent {
static propTypes = {
appId: PropTypes.string.isRequired,
formatters: PropTypes.formatters.isRequired,
linked: PropTypes.bool.isRequired,
updateLinkSuccess: PropTypes.func.isRequired,
}

Expand Down Expand Up @@ -102,19 +99,17 @@ class ApplicationPayloadFormatters extends React.PureComponent {
}

render() {
const { formatters, linked } = this.props

const { formatters } = this.props
const applicationFormatterInfo = (
<Notification className={style.notification} small info content={m.infoText} />
)

return (
<React.Fragment>
<PageTitle title={sharedMessages.payloadFormattersUplink} />
{linked && applicationFormatterInfo}
{applicationFormatterInfo}
<PayloadFormattersForm
uplink
linked={linked}
onSubmit={this.onSubmit}
onSubmitSuccess={this.onSubmitSuccess}
initialType={formatters.up_formatter || PAYLOAD_FORMATTER_TYPES.NONE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import EntityTitleSection from '@console/components/entity-title-section'
import sharedMessages from '@ttn-lw/lib/shared-messages'
import PropTypes from '@ttn-lw/lib/prop-types'

import ApplicationStatus from './status'
Copy link
Contributor

Choose a reason for hiding this comment

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

You can then also remove the status folder. Or can we still fetch up/down counts and last received timestamp from ApplicationLinkStats ? cc @adriansmares

Copy link
Contributor

Choose a reason for hiding this comment

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

ApplicationLinkStats is deprecated. There are no plans in bringing it back at the moment.


const { Content } = EntityTitleSection

const ApplicationTitleSection = props => {
Expand All @@ -43,10 +41,6 @@ const ApplicationTitleSection = props => {
mayViewCollaborators,
mayViewApiKeys,
mayViewDevices,
mayViewLink,
linked,
linkStats,
lastSeen,
} = props

return (
Expand All @@ -63,9 +57,6 @@ const ApplicationTitleSection = props => {
</Spinner>
) : (
<>
{mayViewLink && (
<ApplicationStatus linkStats={linkStats} linked={linked} lastSeen={lastSeen} />
)}
{mayViewDevices && (
<Content.EntityCount
icon="devices"
Expand Down Expand Up @@ -110,22 +101,15 @@ ApplicationTitleSection.propTypes = {
devicesErrored: PropTypes.bool.isRequired,
devicesTotalCount: PropTypes.number,
fetching: PropTypes.bool.isRequired,
lastSeen: PropTypes.string,
linkStats: PropTypes.applicationLinkStats,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also edit the applicationLink and applicationLinkStats prop-type definitions to match the current types.

Copy link
Contributor

Choose a reason for hiding this comment

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

ApplicationLink does not require network_server_address and api_key as those will be deprecated in v3.11

linked: PropTypes.bool,
mayViewApiKeys: PropTypes.bool.isRequired,
mayViewCollaborators: PropTypes.bool.isRequired,
mayViewDevices: PropTypes.bool.isRequired,
mayViewLink: PropTypes.bool.isRequired,
}

ApplicationTitleSection.defaultProps = {
linked: undefined,
linkStats: undefined,
apiKeysTotalCount: undefined,
collaboratorsTotalCount: undefined,
devicesTotalCount: undefined,
lastSeen: undefined,
}

export default ApplicationTitleSection
24 changes: 2 additions & 22 deletions pkg/webui/console/containers/application-title-section/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,17 @@ import {
mayViewOrEditApplicationApiKeys,
mayViewOrEditApplicationCollaborators,
mayViewApplicationDevices,
mayLinkApplication,
} from '@console/lib/feature-checks'

import { getCollaboratorsList } from '@console/store/actions/collaborators'
import { getApiKeysList } from '@console/store/actions/api-keys'
import { getApplicationLink } from '@console/store/actions/link'
import { getApplicationDeviceCount } from '@console/store/actions/applications'

import {
selectApplicationById,
selectApplicationDeviceCount,
selectApplicationDevicesFetching,
selectApplicationDevicesError,
selectApplicationLinkIndicator,
selectApplicationLinkStats,
selectApplicationLinkFetching,
selectApplicationLastSeen,
} from '@console/store/selectors/applications'
import {
selectCollaboratorsTotalCount,
Expand All @@ -60,35 +54,26 @@ const mapStateToProps = (state, props) => {
const devicesTotalCount = selectApplicationDeviceCount(state)
const devicesFetching = selectApplicationDevicesFetching(state)
const devicesError = selectApplicationDevicesError(state)
const linked = selectApplicationLinkIndicator(state)
const linkStats = selectApplicationLinkStats(state)
const lastSeen = selectApplicationLastSeen(state)
const linkFetching = selectApplicationLinkFetching(state)

const fetching = apiKeysFetching || collaboratorsFetching || devicesFetching || linkFetching
const fetching = apiKeysFetching || collaboratorsFetching || devicesFetching

return {
mayViewLink: checkFromState(mayLinkApplication, state),
mayViewCollaborators: checkFromState(mayViewOrEditApplicationCollaborators, state),
mayViewApiKeys: checkFromState(mayViewOrEditApplicationApiKeys, state),
mayViewDevices: checkFromState(mayViewApplicationDevices, state),
mayViewApplicationLink: checkFromState(mayLinkApplication, state),
application: selectApplicationById(state, props.appId),
apiKeysTotalCount,
apiKeysErrored: Boolean(apiKeysError),
collaboratorsTotalCount,
collaboratorsErrored: Boolean(collaboratorsError),
devicesTotalCount,
devicesErrored: Boolean(devicesError),
linked,
linkStats,
lastSeen,
fetching,
}
}

const mapDispatchToProps = dispatch => ({
loadData(mayViewCollaborators, mayViewApiKeys, mayViewLink, mayViewDevices, appId) {
loadData: (mayViewCollaborators, mayViewApiKeys, mayViewDevices, appId) => {
if (mayViewCollaborators) {
dispatch(getCollaboratorsList('application', appId))
}
Expand All @@ -97,10 +82,6 @@ const mapDispatchToProps = dispatch => ({
dispatch(getApiKeysList('application', appId))
}

if (mayViewLink) {
dispatch(getApplicationLink(appId))
}

if (mayViewDevices) {
dispatch(getApplicationDeviceCount(appId))
}
Expand All @@ -115,7 +96,6 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => ({
dispatchProps.loadData(
stateProps.mayViewCollaborators,
stateProps.mayViewApiKeys,
stateProps.mayViewLink,
stateProps.mayViewDevices,
ownProps.appId,
),
Expand Down

This file was deleted.

This file was deleted.

Loading