From 260c31105a0669c3ec277a6f867fed131e4a18a0 Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Wed, 16 Mar 2022 20:50:59 +0100 Subject: [PATCH] feat(ui): add user menu to DashboardsPage when reader --- .../dashboards/containers/DashboardsPage.tsx | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardsPage.tsx b/ui/src/dashboards/containers/DashboardsPage.tsx index f85824398..fd382ef0b 100644 --- a/ui/src/dashboards/containers/DashboardsPage.tsx +++ b/ui/src/dashboards/containers/DashboardsPage.tsx @@ -31,9 +31,11 @@ import { notifyDashboardExportFailed, } from 'src/shared/copy/notifications' -import {Source, Dashboard, RemoteDataState} from 'src/types' +import {Source, Dashboard, RemoteDataState, Links, Me} from 'src/types' import {Notification} from 'src/types/notifications' import {DashboardFile, Cell} from 'src/types/dashboards' +import UserNavBlock from 'src/side_nav/components/UserNavBlock' +import {READER_ROLE} from 'src/auth/Authorized' export interface Props extends WithRouterProps { source: Source @@ -48,6 +50,10 @@ export interface Props extends WithRouterProps { retainRangesDashTimeV1: (dashboardIDs: number[]) => void retainDashRefresh: (dashboardIDs: number[]) => void dashboards: Dashboard[] + isUsingAuth: boolean + logoutLink?: string + links?: Links + me: Me } interface State { @@ -81,7 +87,16 @@ export class DashboardsPage extends PureComponent { } public render() { - const {dashboards, notify, sources, source} = this.props + const { + dashboards, + notify, + sources, + source, + isUsingAuth, + me, + logoutLink, + links, + } = this.props const {dashboardsStatus} = this.state const dashboardLink = `/sources/${this.props.source.id}` @@ -91,7 +106,17 @@ export class DashboardsPage extends PureComponent { - + + {isUsingAuth && me.role === READER_ROLE ? ( + + ) : undefined} + { const mapStateToProps = ({ dashboardUI: {dashboards, dashboard}, sources, + auth: {isUsingAuth, logoutLink, me}, + links, }): Partial => ({ dashboards, dashboard, sources, + isUsingAuth, + logoutLink, + me, + links, }) const mapDispatchToProps = {