Rocket.Chat.ReactNative/app/views/AdminPanelView/index.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { WebView } from 'react-native-webview';
import { SafeAreaView } from 'react-navigation';
import { connect } from 'react-redux';
import I18n from '../../i18n';
import StatusBar from '../../containers/StatusBar';
import { DrawerButton } from '../../containers/HeaderButton';
import styles from '../Styles';
2019-12-04 16:39:53 +00:00
import { themedHeader } from '../../utils/navigation';
import { withTheme } from '../../theme';
import { themes } from '../../constants/colors';
2020-02-11 14:09:14 +00:00
import { getUserSelector } from '../../selectors/login';
class AdminPanelView extends React.Component {
2019-12-04 16:39:53 +00:00
static navigationOptions = ({ navigation, screenProps }) => ({
...themedHeader(screenProps.theme),
headerLeft: <DrawerButton navigation={navigation} />,
title: I18n.t('Admin_Panel')
})
static propTypes = {
baseUrl: PropTypes.string,
2020-02-11 14:09:14 +00:00
token: PropTypes.string,
2019-12-04 16:39:53 +00:00
theme: PropTypes.string
}
render() {
2020-02-11 14:09:14 +00:00
const { baseUrl, token, theme } = this.props;
if (!baseUrl) {
return null;
}
return (
2019-12-04 16:39:53 +00:00
<SafeAreaView style={[styles.container, { backgroundColor: themes[theme].backgroundColor }]} testID='terms-view'>
<StatusBar theme={theme} />
<WebView
source={{ uri: `${ baseUrl }/admin/info?layout=embedded` }}
2020-02-11 14:09:14 +00:00
injectedJavaScript={`Meteor.loginWithToken('${ token }', function() { })`}
/>
</SafeAreaView>
);
}
}
const mapStateToProps = state => ({
2020-02-11 14:09:14 +00:00
baseUrl: state.server.server,
token: getUserSelector(state).token
});
2019-12-04 16:39:53 +00:00
export default connect(mapStateToProps)(withTheme(AdminPanelView));