Load legal pages from web (#849)

This commit is contained in:
Diego Mello 2019-04-26 17:51:09 -03:00 committed by GitHub
parent 2f25b10681
commit c15fab7c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 103 deletions

View File

@ -14,12 +14,6 @@ export default {
CROWD_Enable: { CROWD_Enable: {
type: 'valueAsBoolean' type: 'valueAsBoolean'
}, },
Layout_Privacy_Policy: {
type: 'valueAsString'
},
Layout_Terms_of_Service: {
type: 'valueAsString'
},
LDAP_Enable: { LDAP_Enable: {
type: 'valueAsBoolean' type: 'valueAsBoolean'
}, },

View File

@ -33,8 +33,6 @@ import ThreadMessagesView from './views/ThreadMessagesView';
import SelectedUsersView from './views/SelectedUsersView'; import SelectedUsersView from './views/SelectedUsersView';
import CreateChannelView from './views/CreateChannelView'; import CreateChannelView from './views/CreateChannelView';
import LegalView from './views/LegalView'; import LegalView from './views/LegalView';
import TermsServiceView from './views/TermsServiceView';
import PrivacyPolicyView from './views/PrivacyPolicyView';
import ForgotPasswordView from './views/ForgotPasswordView'; import ForgotPasswordView from './views/ForgotPasswordView';
import RegisterView from './views/RegisterView'; import RegisterView from './views/RegisterView';
import OAuthView from './views/OAuthView'; import OAuthView from './views/OAuthView';
@ -81,15 +79,8 @@ const OutsideStack = createStackNavigator({
LoginSignupView, LoginSignupView,
LoginView, LoginView,
ForgotPasswordView, ForgotPasswordView,
RegisterView RegisterView,
}, { LegalView
defaultNavigationOptions: defaultHeader
});
const LegalStack = createStackNavigator({
LegalView,
TermsServiceView,
PrivacyPolicyView
}, { }, {
defaultNavigationOptions: defaultHeader defaultNavigationOptions: defaultHeader
}); });
@ -102,7 +93,6 @@ const OAuthStack = createStackNavigator({
const OutsideStackModal = createStackNavigator({ const OutsideStackModal = createStackNavigator({
OutsideStack, OutsideStack,
LegalStack,
OAuthStack OAuthStack
}, },
{ {

View File

@ -5,15 +5,16 @@ import {
} from 'react-native'; } from 'react-native';
import { SafeAreaView } from 'react-navigation'; import { SafeAreaView } from 'react-navigation';
import { RectButton } from 'react-native-gesture-handler'; import { RectButton } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import sharedStyles from './Styles'; import sharedStyles from './Styles';
import scrollPersistTaps from '../utils/scrollPersistTaps'; import scrollPersistTaps from '../utils/scrollPersistTaps';
import LoggedView from './View'; import LoggedView from './View';
import I18n from '../i18n'; import I18n from '../i18n';
import DisclosureIndicator from '../containers/DisclosureIndicator'; import DisclosureIndicator from '../containers/DisclosureIndicator';
import { CloseModalButton } from '../containers/HeaderButton';
import StatusBar from '../containers/StatusBar'; import StatusBar from '../containers/StatusBar';
import { COLOR_SEPARATOR, COLOR_WHITE } from '../constants/colors'; import { COLOR_SEPARATOR, COLOR_WHITE } from '../constants/colors';
import openLink from '../utils/openLink';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
@ -52,15 +53,17 @@ const styles = StyleSheet.create({
const Separator = () => <View style={styles.separator} />; const Separator = () => <View style={styles.separator} />;
@connect(state => ({
server: state.server.server
}))
/** @extends React.Component */ /** @extends React.Component */
export default class LegalView extends LoggedView { export default class LegalView extends LoggedView {
static navigationOptions = ({ navigation }) => ({ static navigationOptions = () => ({
headerLeft: <CloseModalButton testID='legal-view-close' navigation={navigation} />,
title: I18n.t('Legal') title: I18n.t('Legal')
}) })
static propTypes = { static propTypes = {
navigation: PropTypes.object server: PropTypes.string
} }
constructor(props) { constructor(props) {
@ -68,8 +71,11 @@ export default class LegalView extends LoggedView {
} }
onPressItem = ({ route }) => { onPressItem = ({ route }) => {
const { navigation } = this.props; const { server } = this.props;
navigation.navigate(route); if (!server) {
return;
}
openLink(`${ server }/${ route }`);
} }
renderItem = ({ text, route, testID }) => ( renderItem = ({ text, route, testID }) => (
@ -84,9 +90,9 @@ export default class LegalView extends LoggedView {
<SafeAreaView style={styles.container} testID='legal-view' forceInset={{ bottom: 'never' }}> <SafeAreaView style={styles.container} testID='legal-view' forceInset={{ bottom: 'never' }}>
<StatusBar /> <StatusBar />
<ScrollView {...scrollPersistTaps} contentContainerStyle={styles.scroll}> <ScrollView {...scrollPersistTaps} contentContainerStyle={styles.scroll}>
{this.renderItem({ text: 'Terms_of_Service', route: 'TermsServiceView', testID: 'legal-terms-button' })} {this.renderItem({ text: 'Terms_of_Service', route: 'terms-of-service', testID: 'legal-terms-button' })}
<Separator /> <Separator />
{this.renderItem({ text: 'Privacy_Policy', route: 'PrivacyPolicyView', testID: 'legal-privacy-button' })} {this.renderItem({ text: 'Privacy_Policy', route: 'privacy-policy', testID: 'legal-privacy-button' })}
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
); );

View File

@ -1,39 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import { WebView } from 'react-native';
import { connect } from 'react-redux';
import { SafeAreaView } from 'react-navigation';
import styles from './Styles';
import LoggedView from './View';
import I18n from '../i18n';
import StatusBar from '../containers/StatusBar';
@connect(state => ({
privacyPolicy: state.settings.Layout_Privacy_Policy
}))
/** @extends React.Component */
export default class PrivacyPolicyView extends LoggedView {
static navigationOptions = {
title: I18n.t('Privacy_Policy')
}
static propTypes = {
privacyPolicy: PropTypes.string
}
constructor(props) {
super('PrivacyPolicyView', props);
}
render() {
const { privacyPolicy } = this.props;
return (
<SafeAreaView style={styles.container} testID='privacy-view'>
<StatusBar />
<WebView originWhitelist={['*']} source={{ html: privacyPolicy, baseUrl: '' }} />
</SafeAreaView>
);
}
}

View File

@ -1,38 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import { WebView } from 'react-native';
import { connect } from 'react-redux';
import { SafeAreaView } from 'react-navigation';
import styles from './Styles';
import LoggedView from './View';
import I18n from '../i18n';
import StatusBar from '../containers/StatusBar';
@connect(state => ({
termsService: state.settings.Layout_Terms_of_Service
}))
/** @extends React.Component */
export default class TermsServiceView extends LoggedView {
static navigationOptions = {
title: I18n.t('Terms_of_Service')
}
static propTypes = {
termsService: PropTypes.string
}
constructor(props) {
super('TermsServiceView', props);
}
render() {
const { termsService } = this.props;
return (
<SafeAreaView style={styles.container} testID='terms-view'>
<StatusBar />
<WebView originWhitelist={['*']} source={{ html: termsService, baseUrl: '' }} />
</SafeAreaView>
);
}
}