2019-05-18 19:31:33 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { WebView } from 'react-native-webview';
|
|
|
|
import { connect } from 'react-redux';
|
2021-09-15 13:18:53 +00:00
|
|
|
import { DrawerScreenProps } from '@react-navigation/drawer';
|
2022-01-17 16:10:39 +00:00
|
|
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
2019-05-18 19:31:33 +00:00
|
|
|
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import StatusBar from '../../containers/StatusBar';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { withTheme } from '../../theme';
|
2020-02-11 14:09:14 +00:00
|
|
|
import { getUserSelector } from '../../selectors/login';
|
2020-06-15 14:00:46 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { AdminPanelStackParamList } from '../../stacks/types';
|
2019-05-18 19:31:33 +00:00
|
|
|
|
2021-09-15 13:18:53 +00:00
|
|
|
interface IAdminPanelViewProps {
|
|
|
|
baseUrl: string;
|
|
|
|
token: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface INavigationOptions {
|
2021-12-03 19:27:57 +00:00
|
|
|
navigation: DrawerScreenProps<AdminPanelStackParamList, 'AdminPanelView'>;
|
2021-09-15 13:18:53 +00:00
|
|
|
isMasterDetail: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
class AdminPanelView extends React.Component<IAdminPanelViewProps, any> {
|
2022-01-17 16:10:39 +00:00
|
|
|
static navigationOptions = ({ navigation, isMasterDetail }: INavigationOptions): StackNavigationOptions => ({
|
2020-10-30 16:15:58 +00:00
|
|
|
headerLeft: isMasterDetail ? undefined : () => <HeaderButton.Drawer navigation={navigation} />,
|
2019-05-18 19:31:33 +00:00
|
|
|
title: I18n.t('Admin_Panel')
|
2021-09-13 20:41:05 +00:00
|
|
|
});
|
2019-05-18 19:31:33 +00:00
|
|
|
|
|
|
|
render() {
|
2020-10-30 13:59:44 +00:00
|
|
|
const { baseUrl, token } = this.props;
|
2019-05-18 19:31:33 +00:00
|
|
|
if (!baseUrl) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
2020-10-30 13:59:44 +00:00
|
|
|
<SafeAreaView>
|
|
|
|
<StatusBar />
|
2019-05-18 19:31:33 +00:00
|
|
|
<WebView
|
2020-07-22 19:41:36 +00:00
|
|
|
// https://github.com/react-native-community/react-native-webview/issues/1311
|
|
|
|
onMessage={() => {}}
|
2021-09-13 20:41:05 +00:00
|
|
|
source={{ uri: `${baseUrl}/admin/info?layout=embedded` }}
|
|
|
|
injectedJavaScript={`Meteor.loginWithToken('${token}', function() { })`}
|
2019-05-18 19:31:33 +00:00
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2021-09-15 13:18:53 +00:00
|
|
|
const mapStateToProps = (state: any) => ({
|
2020-02-11 14:09:14 +00:00
|
|
|
baseUrl: state.server.server,
|
|
|
|
token: getUserSelector(state).token
|
2019-08-07 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
export default connect(mapStateToProps)(withTheme(AdminPanelView));
|