Outside working
This commit is contained in:
parent
796c82a966
commit
3def144e64
|
@ -24,37 +24,37 @@ const OutsideStack = () => {
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='OnboardingView'
|
name='OnboardingView'
|
||||||
component={OnboardingView}
|
component={OnboardingView}
|
||||||
// options={{ headerShown: false }}
|
options={OnboardingView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='NewServerView'
|
name='NewServerView'
|
||||||
component={NewServerView}
|
component={NewServerView}
|
||||||
// options={{ headerShown: false }}
|
options={NewServerView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='WorkspaceView'
|
name='WorkspaceView'
|
||||||
component={WorkspaceView}
|
component={WorkspaceView}
|
||||||
// options={WorkspaceView.navigationOptions}
|
options={WorkspaceView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='LoginView'
|
name='LoginView'
|
||||||
component={LoginView}
|
component={LoginView}
|
||||||
// options={LoginView.navigationOptions}
|
options={LoginView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='ForgotPasswordView'
|
name='ForgotPasswordView'
|
||||||
component={ForgotPasswordView}
|
component={ForgotPasswordView}
|
||||||
// options={ForgotPasswordView.navigationOptions}
|
options={ForgotPasswordView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='RegisterView'
|
name='RegisterView'
|
||||||
component={RegisterView}
|
component={RegisterView}
|
||||||
// options={RegisterView.navigationOptions}
|
options={RegisterView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<Outside.Screen
|
<Outside.Screen
|
||||||
name='LegalView'
|
name='LegalView'
|
||||||
component={LegalView}
|
component={LegalView}
|
||||||
// options={LegalView.navigationOptions}
|
options={LegalView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
</Outside.Navigator>
|
</Outside.Navigator>
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { analytics, leaveBreadcrumb } from './log';
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
|
|
||||||
export const defaultHeader = {
|
export const defaultHeader = {
|
||||||
headerBackTitle: null
|
headerBackTitleVisible: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cardStyle = {
|
export const cardStyle = {
|
||||||
|
|
|
@ -6,29 +6,20 @@ import parse from 'url-parse';
|
||||||
|
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import { isIOS } from '../utils/deviceInfo';
|
import { isIOS } from '../utils/deviceInfo';
|
||||||
import { CloseModalButton } from '../containers/HeaderButton';
|
|
||||||
import StatusBar from '../containers/StatusBar';
|
import StatusBar from '../containers/StatusBar';
|
||||||
import ActivityIndicator from '../containers/ActivityIndicator';
|
import ActivityIndicator from '../containers/ActivityIndicator';
|
||||||
import { withTheme } from '../theme';
|
import { withTheme } from '../theme';
|
||||||
import { themedHeader } from '../utils/navigation';
|
|
||||||
import debounce from '../utils/debounce';
|
import debounce from '../utils/debounce';
|
||||||
|
import { LegalButton, CloseModalButton } from '../containers/HeaderButton';
|
||||||
|
|
||||||
const userAgent = isIOS
|
const userAgent = isIOS
|
||||||
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1'
|
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1'
|
||||||
: 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G920V Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36';
|
: 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G920V Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36';
|
||||||
|
|
||||||
class AuthenticationWebView extends React.PureComponent {
|
class AuthenticationWebView extends React.PureComponent {
|
||||||
static navigationOptions = ({ navigation, screenProps }) => {
|
|
||||||
const authType = navigation.getParam('authType', 'oauth');
|
|
||||||
return {
|
|
||||||
...themedHeader(screenProps.theme),
|
|
||||||
headerLeft: <CloseModalButton navigation={navigation} />,
|
|
||||||
title: authType === 'saml' || authType === 'cas' ? 'SSO' : 'OAuth'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
|
route: PropTypes.object,
|
||||||
server: PropTypes.string,
|
server: PropTypes.string,
|
||||||
theme: PropTypes.string
|
theme: PropTypes.string
|
||||||
}
|
}
|
||||||
|
@ -39,7 +30,6 @@ class AuthenticationWebView extends React.PureComponent {
|
||||||
logging: false,
|
logging: false,
|
||||||
loading: false
|
loading: false
|
||||||
};
|
};
|
||||||
this.authType = props.navigation.getParam('authType', 'oauth');
|
|
||||||
this.redirectRegex = new RegExp(`(?=.*(${ props.server }))(?=.*(credentialToken))(?=.*(credentialSecret))`, 'g');
|
this.redirectRegex = new RegExp(`(?=.*(${ props.server }))(?=.*(credentialToken))(?=.*(credentialSecret))`, 'g');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,14 +66,15 @@ class AuthenticationWebView extends React.PureComponent {
|
||||||
|
|
||||||
onNavigationStateChange = (webViewState) => {
|
onNavigationStateChange = (webViewState) => {
|
||||||
const url = decodeURIComponent(webViewState.url);
|
const url = decodeURIComponent(webViewState.url);
|
||||||
if (this.authType === 'saml' || this.authType === 'cas') {
|
const { route } = this.props;
|
||||||
const { navigation } = this.props;
|
const { authType } = route.params;
|
||||||
const ssoToken = navigation.getParam('ssoToken');
|
if (authType === 'saml' || authType === 'cas') {
|
||||||
|
const { ssoToken } = route.params;
|
||||||
const parsedUrl = parse(url, true);
|
const parsedUrl = parse(url, true);
|
||||||
// ticket -> cas / validate & saml_idp_credentialToken -> saml
|
// ticket -> cas / validate & saml_idp_credentialToken -> saml
|
||||||
if (parsedUrl.pathname?.includes('validate') || parsedUrl.query?.ticket || parsedUrl.query?.saml_idp_credentialToken) {
|
if (parsedUrl.pathname?.includes('validate') || parsedUrl.query?.ticket || parsedUrl.query?.saml_idp_credentialToken) {
|
||||||
let payload;
|
let payload;
|
||||||
if (this.authType === 'saml') {
|
if (authType === 'saml') {
|
||||||
const token = parsedUrl.query?.saml_idp_credentialToken || ssoToken;
|
const token = parsedUrl.query?.saml_idp_credentialToken || ssoToken;
|
||||||
const credentialToken = { credentialToken: token };
|
const credentialToken = { credentialToken: token };
|
||||||
payload = { ...credentialToken, saml: true };
|
payload = { ...credentialToken, saml: true };
|
||||||
|
@ -94,7 +85,7 @@ class AuthenticationWebView extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.authType === 'oauth') {
|
if (authType === 'oauth') {
|
||||||
if (this.redirectRegex.test(url)) {
|
if (this.redirectRegex.test(url)) {
|
||||||
const parts = url.split('#');
|
const parts = url.split('#');
|
||||||
const credentials = JSON.parse(parts[1]);
|
const credentials = JSON.parse(parts[1]);
|
||||||
|
@ -105,13 +96,13 @@ class AuthenticationWebView extends React.PureComponent {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading } = this.state;
|
const { loading } = this.state;
|
||||||
const { navigation, theme } = this.props;
|
const { route, theme } = this.props;
|
||||||
const uri = navigation.getParam('url');
|
const { url } = route.params;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<StatusBar theme={theme} />
|
<StatusBar theme={theme} />
|
||||||
<WebView
|
<WebView
|
||||||
source={{ uri }}
|
source={{ uri: url }}
|
||||||
userAgent={userAgent}
|
userAgent={userAgent}
|
||||||
onNavigationStateChange={this.onNavigationStateChange}
|
onNavigationStateChange={this.onNavigationStateChange}
|
||||||
onLoadStart={() => {
|
onLoadStart={() => {
|
||||||
|
@ -131,4 +122,12 @@ const mapStateToProps = state => ({
|
||||||
server: state.server.server
|
server: state.server.server
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AuthenticationWebView.navigationOptions = ({ route, navigation }) => {
|
||||||
|
const { authType } = route.params;
|
||||||
|
return {
|
||||||
|
headerLeft: () => <CloseModalButton navigation={navigation} />,
|
||||||
|
title: authType === 'saml' || authType === 'cas' ? 'SSO' : 'OAuth'
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(AuthenticationWebView));
|
export default connect(mapStateToProps)(withTheme(AuthenticationWebView));
|
||||||
|
|
|
@ -13,16 +13,9 @@ import { withTheme } from '../theme';
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
import { themedHeader } from '../utils/navigation';
|
import { themedHeader } from '../utils/navigation';
|
||||||
import FormContainer, { FormContainerInner } from '../containers/FormContainer';
|
import FormContainer, { FormContainerInner } from '../containers/FormContainer';
|
||||||
|
import { LegalButton } from '../containers/HeaderButton';
|
||||||
|
|
||||||
class ForgotPasswordView extends React.Component {
|
class ForgotPasswordView extends React.Component {
|
||||||
static navigationOptions = ({ navigation, screenProps }) => {
|
|
||||||
const title = navigation.getParam('title', 'Rocket.Chat');
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
...themedHeader(screenProps.theme)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
theme: PropTypes.string
|
theme: PropTypes.string
|
||||||
|
@ -114,4 +107,8 @@ class ForgotPasswordView extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForgotPasswordView.navigatonOptions = ({ route }) => ({
|
||||||
|
title: route.params.title
|
||||||
|
});
|
||||||
|
|
||||||
export default withTheme(ForgotPasswordView);
|
export default withTheme(ForgotPasswordView);
|
||||||
|
|
|
@ -52,11 +52,6 @@ Separator.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class LegalView extends React.Component {
|
class LegalView extends React.Component {
|
||||||
static navigationOptions = ({ screenProps }) => ({
|
|
||||||
title: I18n.t('Legal'),
|
|
||||||
...themedHeader(screenProps.theme)
|
|
||||||
})
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
server: PropTypes.string,
|
server: PropTypes.string,
|
||||||
theme: PropTypes.string
|
theme: PropTypes.string
|
||||||
|
@ -120,4 +115,8 @@ const mapStateToProps = state => ({
|
||||||
server: state.server.server
|
server: state.server.server
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LegalView.navigationOptions = {
|
||||||
|
title: I18n.t('Legal')
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(LegalView));
|
export default connect(mapStateToProps)(withTheme(LegalView));
|
||||||
|
|
|
@ -51,15 +51,6 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
class LoginView extends React.Component {
|
class LoginView extends React.Component {
|
||||||
static navigationOptions = ({ navigation, screenProps }) => {
|
|
||||||
const title = navigation.getParam('title', 'Rocket.Chat');
|
|
||||||
return {
|
|
||||||
...themedHeader(screenProps.theme),
|
|
||||||
title,
|
|
||||||
headerRight: <LegalButton testID='login-view-more' navigation={navigation} />
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
Site_Name: PropTypes.string,
|
Site_Name: PropTypes.string,
|
||||||
|
@ -229,4 +220,9 @@ const mapDispatchToProps = dispatch => ({
|
||||||
loginRequest: params => dispatch(loginRequestAction(params))
|
loginRequest: params => dispatch(loginRequestAction(params))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LoginView.navigatonOptions = ({ route, navigation }) => ({
|
||||||
|
title: route.params.title,
|
||||||
|
headerRight: () => <LegalButton testID='login-view-more' navigation={navigation} />
|
||||||
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(LoginView));
|
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(LoginView));
|
||||||
|
|
|
@ -28,7 +28,6 @@ import log from '../utils/log';
|
||||||
import { animateNextTransition } from '../utils/layoutAnimation';
|
import { animateNextTransition } from '../utils/layoutAnimation';
|
||||||
import { withTheme } from '../theme';
|
import { withTheme } from '../theme';
|
||||||
import { setBasicAuth, BASIC_AUTH_KEY } from '../utils/fetch';
|
import { setBasicAuth, BASIC_AUTH_KEY } from '../utils/fetch';
|
||||||
import { themedHeader } from '../utils/navigation';
|
|
||||||
import { CloseModalButton } from '../containers/HeaderButton';
|
import { CloseModalButton } from '../containers/HeaderButton';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -65,16 +64,6 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
class NewServerView extends React.Component {
|
class NewServerView extends React.Component {
|
||||||
static navigationOptions = ({ screenProps, navigation }) => {
|
|
||||||
const previousServer = navigation.getParam('previousServer', null);
|
|
||||||
const close = navigation.getParam('close', () => {});
|
|
||||||
return {
|
|
||||||
headerLeft: previousServer ? <CloseModalButton navigation={navigation} onPress={close} testID='new-server-view-close' /> : undefined,
|
|
||||||
title: I18n.t('Workspaces'),
|
|
||||||
...themedHeader(screenProps.theme)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
theme: PropTypes.string,
|
theme: PropTypes.string,
|
||||||
|
@ -88,8 +77,9 @@ class NewServerView extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.previousServer = props.navigation.getParam('previousServer');
|
// TODO: add server logic
|
||||||
props.navigation.setParams({ close: this.close, previousServer: this.previousServer });
|
// this.previousServer = props.route.params?.previousServer;
|
||||||
|
// props.navigation.setParams({ close: this.close, previousServer: this.previousServer });
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
this.options = [I18n.t('Cancel')];
|
this.options = [I18n.t('Cancel')];
|
||||||
|
@ -355,4 +345,18 @@ const mapDispatchToProps = dispatch => ({
|
||||||
appStart: root => dispatch(appStartAction(root))
|
appStart: root => dispatch(appStartAction(root))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// static navigationOptions = ({ screenProps, navigation }) => {
|
||||||
|
// const previousServer = navigation.getParam('previousServer', null);
|
||||||
|
// const close = navigation.getParam('close', () => {});
|
||||||
|
// return {
|
||||||
|
// headerLeft: previousServer ? <CloseModalButton navigation={navigation} onPress={close} testID='new-server-view-close' /> : undefined,
|
||||||
|
// title: I18n.t('Workspaces'),
|
||||||
|
// ...themedHeader(screenProps.theme)
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
NewServerView.navigationOptions = {
|
||||||
|
title: I18n.t('Workspaces')
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView));
|
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView));
|
||||||
|
|
|
@ -16,10 +16,6 @@ import { withTheme } from '../../theme';
|
||||||
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
|
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
|
||||||
|
|
||||||
class OnboardingView extends React.Component {
|
class OnboardingView extends React.Component {
|
||||||
static navigationOptions = () => ({
|
|
||||||
header: null
|
|
||||||
})
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
appStart: PropTypes.func,
|
appStart: PropTypes.func,
|
||||||
|
@ -101,4 +97,8 @@ const mapDispatchToProps = dispatch => ({
|
||||||
appStart: root => dispatch(appStartAction(root))
|
appStart: root => dispatch(appStartAction(root))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
OnboardingView.navigationOptions = {
|
||||||
|
headerShown: false
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(withTheme(OnboardingView));
|
export default connect(null, mapDispatchToProps)(withTheme(OnboardingView));
|
||||||
|
|
|
@ -342,4 +342,9 @@ const mapDispatchToProps = dispatch => ({
|
||||||
loginRequest: params => dispatch(loginRequestAction(params))
|
loginRequest: params => dispatch(loginRequestAction(params))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RegisterView.navigatonOptions = ({ route, navigation }) => ({
|
||||||
|
title: route.params.title,
|
||||||
|
headerRight: () => <LegalButton testID='register-view-more' navigation={navigation} />
|
||||||
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(RegisterView));
|
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(RegisterView));
|
||||||
|
|
|
@ -9,16 +9,10 @@ import styles from './styles';
|
||||||
import { themes } from '../../constants/colors';
|
import { themes } from '../../constants/colors';
|
||||||
import { withTheme } from '../../theme';
|
import { withTheme } from '../../theme';
|
||||||
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
|
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
|
||||||
import { themedHeader } from '../../utils/navigation';
|
|
||||||
import ServerAvatar from './ServerAvatar';
|
import ServerAvatar from './ServerAvatar';
|
||||||
import { getShowLoginButton } from '../../selectors/login';
|
import { getShowLoginButton } from '../../selectors/login';
|
||||||
|
|
||||||
class WorkspaceView extends React.Component {
|
class WorkspaceView extends React.Component {
|
||||||
static navigationOptions = ({ screenProps }) => ({
|
|
||||||
title: I18n.t('Your_workspace'),
|
|
||||||
...themedHeader(screenProps.theme)
|
|
||||||
})
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
theme: PropTypes.string,
|
theme: PropTypes.string,
|
||||||
|
@ -94,4 +88,8 @@ const mapStateToProps = state => ({
|
||||||
showLoginButton: getShowLoginButton(state)
|
showLoginButton: getShowLoginButton(state)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WorkspaceView.navigationOptions = {
|
||||||
|
title: I18n.t('Your_workspace')
|
||||||
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(WorkspaceView));
|
export default connect(mapStateToProps)(withTheme(WorkspaceView));
|
||||||
|
|
Loading…
Reference in New Issue