// @flow import * as React from 'react'; import compose from 'recompose/compose'; import { withRouter } from 'react-router'; import { connect } from 'react-redux'; import { getChannelByMatch } from 'shared/graphql/queries/channel/getChannel'; import type { GetChannelType } from 'shared/graphql/queries/channel/getChannel'; import Head from 'src/components/head'; import { Upsell404Channel } from 'src/components/upsell'; import viewNetworkHandler from 'src/components/viewNetworkHandler'; import ViewError from 'src/components/viewError'; import { View } from 'src/components/settingsViews/style'; import Header from 'src/components/settingsViews/header'; import Overview from './components/overview'; import type { Dispatch } from 'redux'; import { ErrorView, LoadingView } from 'src/views/viewHelpers'; import { ViewGrid } from 'src/components/layout'; import { setTitlebarProps } from 'src/actions/titlebar'; type Props = { data: { channel: GetChannelType, }, location: Object, match: Object, isLoading: boolean, hasError: boolean, dispatch: Dispatch, history: Object, }; class ChannelSettings extends React.Component { componentDidMount() { const { dispatch } = this.props; dispatch( setTitlebarProps({ title: 'Settings', }) ); } render() { const { data: { channel }, match, location, isLoading, } = this.props; const { communitySlug } = match.params; // this is hacky, but will tell us if we're viewing analytics or the root settings view const pathname = location.pathname; const lastIndex = pathname.lastIndexOf('/'); const activeTab = pathname.substr(lastIndex + 1); if (channel && channel.id) { const { isModerator, isOwner } = channel.channelPermissions; const userHasPermissions = isOwner || isModerator || channel.community.communityPermissions.isOwner || channel.community.communityPermissions.isModerator; if (!userHasPermissions) { return ( ); } const ActiveView = () => { switch (activeTab) { case 'settings': return ( ); default: return null; } }; const subheading = { to: `/${channel.community.slug}/settings`, label: `Return to ${channel.community.name} settings`, }; return (
); } if (isLoading) { return ; } return ; } } export default compose( // $FlowIssue connect(), withRouter, getChannelByMatch, viewNetworkHandler )(ChannelSettings);