From 52bc264ca8695ed486f862480bd834fc96dbe45b Mon Sep 17 00:00:00 2001 From: Kevin Schiffer Date: Mon, 3 Jul 2023 18:04:01 +0200 Subject: [PATCH] fixup! console: Refactor gateway views --- pkg/webui/console/views/gateway-data/index.js | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/pkg/webui/console/views/gateway-data/index.js b/pkg/webui/console/views/gateway-data/index.js index d6c3d267cdf..bf49eda84f5 100644 --- a/pkg/webui/console/views/gateway-data/index.js +++ b/pkg/webui/console/views/gateway-data/index.js @@ -1,4 +1,4 @@ -// Copyright © 2019 The Things Network Foundation, The Things Industries B.V. +// Copyright © 2023 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. @@ -13,52 +13,45 @@ // limitations under the License. import React from 'react' -import { connect } from 'react-redux' import { defineMessages } from 'react-intl' +import { useParams } from 'react-router-dom' import PageTitle from '@ttn-lw/components/page-title' import Breadcrumb from '@ttn-lw/components/breadcrumbs/breadcrumb' -import { withBreadcrumb } from '@ttn-lw/components/breadcrumbs/context' +import { useBreadcrumbs } from '@ttn-lw/components/breadcrumbs/context' import WithRootClass from '@ttn-lw/lib/components/with-root-class' import GatewayEvents from '@console/containers/gateway-events' -import withFeatureRequirement from '@console/lib/components/with-feature-requirement' +import Require from '@console/lib/components/require' import style from '@console/views/app/app.styl' import sharedMessages from '@ttn-lw/lib/shared-messages' -import PropTypes from '@ttn-lw/lib/prop-types' import { mayViewGatewayEvents } from '@console/lib/feature-checks' -import { selectSelectedGatewayId } from '@console/store/selectors/gateways' - const m = defineMessages({ gtwData: 'Gateway data', }) -@connect(state => ({ gtwId: selectSelectedGatewayId(state) })) -@withFeatureRequirement(mayViewGatewayEvents, { - redirect: ({ gtwId }) => `/gateways/${gtwId}`, -}) -@withBreadcrumb('gateways.single.data', ({ gtwId }) => ( - -)) -export default class Data extends React.Component { - static propTypes = { - gtwId: PropTypes.string.isRequired, - } +const GatewayData = () => { + const { gtwId } = useParams() - render() { - const { gtwId } = this.props + useBreadcrumbs( + 'gateways.single.data', + , + ) - return ( + return ( + - ) - } + + ) } + +export default GatewayData