Chore: Evaluate AdminPanelView - TypeScript (#4162)
This commit is contained in:
parent
67073a1d75
commit
5970d29ee7
|
@ -198,7 +198,7 @@ const AdminPanelStackNavigator = () => {
|
||||||
return (
|
return (
|
||||||
<AdminPanelStack.Navigator
|
<AdminPanelStack.Navigator
|
||||||
screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation } as StackNavigationOptions}>
|
screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation } as StackNavigationOptions}>
|
||||||
<AdminPanelStack.Screen name='AdminPanelView' component={AdminPanelView} options={AdminPanelView.navigationOptions} />
|
<AdminPanelStack.Screen name='AdminPanelView' component={AdminPanelView} />
|
||||||
</AdminPanelStack.Navigator>
|
</AdminPanelStack.Navigator>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -196,11 +196,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => {
|
||||||
options={props => ProfileView.navigationOptions!({ ...props, isMasterDetail: true })}
|
options={props => ProfileView.navigationOptions!({ ...props, isMasterDetail: true })}
|
||||||
/>
|
/>
|
||||||
<ModalStack.Screen name='DisplayPrefsView' component={DisplayPrefsView} />
|
<ModalStack.Screen name='DisplayPrefsView' component={DisplayPrefsView} />
|
||||||
<ModalStack.Screen
|
<ModalStack.Screen name='AdminPanelView' component={AdminPanelView} />
|
||||||
name='AdminPanelView'
|
|
||||||
component={AdminPanelView}
|
|
||||||
options={props => AdminPanelView.navigationOptions!({ ...props, isMasterDetail: true })}
|
|
||||||
/>
|
|
||||||
<ModalStack.Screen name='NewMessageView' component={NewMessageView} options={NewMessageView.navigationOptions} />
|
<ModalStack.Screen name='NewMessageView' component={NewMessageView} options={NewMessageView.navigationOptions} />
|
||||||
<ModalStack.Screen name='SelectedUsersViewCreateChannel' component={SelectedUsersView} />
|
<ModalStack.Screen name='SelectedUsersViewCreateChannel' component={SelectedUsersView} />
|
||||||
<ModalStack.Screen name='CreateChannelView' component={CreateChannelView} options={CreateChannelView.navigationOptions} />
|
<ModalStack.Screen name='CreateChannelView' component={CreateChannelView} options={CreateChannelView.navigationOptions} />
|
||||||
|
|
|
@ -1,38 +1,34 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
import { useNavigation } from '@react-navigation/native';
|
||||||
import { WebView } from 'react-native-webview';
|
import { WebView } from 'react-native-webview';
|
||||||
import { connect } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { DrawerScreenProps } from '@react-navigation/drawer';
|
import { StackNavigationProp } from '@react-navigation/stack';
|
||||||
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
||||||
|
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import StatusBar from '../../containers/StatusBar';
|
import StatusBar from '../../containers/StatusBar';
|
||||||
import * as HeaderButton from '../../containers/HeaderButton';
|
import * as HeaderButton from '../../containers/HeaderButton';
|
||||||
import { withTheme } from '../../theme';
|
|
||||||
import { getUserSelector } from '../../selectors/login';
|
import { getUserSelector } from '../../selectors/login';
|
||||||
import SafeAreaView from '../../containers/SafeAreaView';
|
import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import { AdminPanelStackParamList } from '../../stacks/types';
|
import { AdminPanelStackParamList } from '../../stacks/types';
|
||||||
|
import { IApplicationState } from '../../definitions';
|
||||||
|
|
||||||
interface IAdminPanelViewProps {
|
const AdminPanelView = () => {
|
||||||
baseUrl: string;
|
const navigation = useNavigation<StackNavigationProp<AdminPanelStackParamList, 'AdminPanelView'>>();
|
||||||
token: string;
|
const baseUrl = useSelector((state: IApplicationState) => state.server.server);
|
||||||
}
|
const token = useSelector((state: IApplicationState) => getUserSelector(state).token);
|
||||||
|
const isMasterDetail = useSelector((state: IApplicationState) => state.app.isMasterDetail);
|
||||||
|
|
||||||
interface INavigationOptions {
|
useEffect(() => {
|
||||||
navigation: DrawerScreenProps<AdminPanelStackParamList, 'AdminPanelView'>;
|
navigation.setOptions({
|
||||||
isMasterDetail: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AdminPanelView extends React.Component<IAdminPanelViewProps, any> {
|
|
||||||
static navigationOptions = ({ navigation, isMasterDetail }: INavigationOptions): StackNavigationOptions => ({
|
|
||||||
headerLeft: isMasterDetail ? undefined : () => <HeaderButton.Drawer navigation={navigation} />,
|
headerLeft: isMasterDetail ? undefined : () => <HeaderButton.Drawer navigation={navigation} />,
|
||||||
title: I18n.t('Admin_Panel')
|
title: I18n.t('Admin_Panel')
|
||||||
});
|
});
|
||||||
|
}, [isMasterDetail, navigation]);
|
||||||
|
|
||||||
render() {
|
|
||||||
const { baseUrl, token } = this.props;
|
|
||||||
if (!baseUrl) {
|
if (!baseUrl) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
<StatusBar />
|
<StatusBar />
|
||||||
|
@ -44,12 +40,6 @@ class AdminPanelView extends React.Component<IAdminPanelViewProps, any> {
|
||||||
/>
|
/>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = (state: any) => ({
|
export default AdminPanelView;
|
||||||
baseUrl: state.server.server,
|
|
||||||
token: getUserSelector(state).token
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(AdminPanelView));
|
|
||||||
|
|
Loading…
Reference in New Issue