[FIX] NewServerView skipping WorkspaceView (#3455)
* Initial commit * Fix interface * Unrequired change on onPress/onSubmit
This commit is contained in:
parent
0a44731229
commit
87a99089ce
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FlatList, StyleSheet, View } from 'react-native';
|
import { FlatList, StyleSheet, TextInputProps, View } from 'react-native';
|
||||||
|
|
||||||
import TextInput from '../../../containers/TextInput';
|
import TextInput from '../../../containers/TextInput';
|
||||||
import * as List from '../../../containers/List';
|
import * as List from '../../../containers/List';
|
||||||
|
@ -28,11 +28,10 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IServerInput {
|
interface IServerInput extends TextInputProps {
|
||||||
text: string;
|
text: string;
|
||||||
theme: string;
|
theme: string;
|
||||||
serversHistory: any[];
|
serversHistory: any[];
|
||||||
onChangeText(text: string): void;
|
|
||||||
onSubmit(): void;
|
onSubmit(): void;
|
||||||
onDelete(item: IServer): void;
|
onDelete(item: IServer): void;
|
||||||
onPressServerHistory(serverHistory: IServer): void;
|
onPressServerHistory(serverHistory: IServer): void;
|
||||||
|
|
|
@ -71,6 +71,7 @@ export interface IServer extends Model {
|
||||||
url: string;
|
url: string;
|
||||||
username: string;
|
username: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface INewServerView {
|
interface INewServerView {
|
||||||
navigation: StackNavigationProp<any, 'NewServerView'>;
|
navigation: StackNavigationProp<any, 'NewServerView'>;
|
||||||
theme: string;
|
theme: string;
|
||||||
|
@ -91,6 +92,11 @@ interface IState {
|
||||||
serversHistory: IServer[];
|
serversHistory: IServer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ISubmitParams {
|
||||||
|
fromServerHistory?: boolean;
|
||||||
|
username?: string;
|
||||||
|
}
|
||||||
|
|
||||||
class NewServerView extends React.Component<INewServerView, IState> {
|
class NewServerView extends React.Component<INewServerView, IState> {
|
||||||
constructor(props: INewServerView) {
|
constructor(props: INewServerView) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -184,10 +190,10 @@ class NewServerView extends React.Component<INewServerView, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
onPressServerHistory = (serverHistory: IServer) => {
|
onPressServerHistory = (serverHistory: IServer) => {
|
||||||
this.setState({ text: serverHistory.url }, () => this.submit(true, serverHistory?.username));
|
this.setState({ text: serverHistory.url }, () => this.submit({ fromServerHistory: true, username: serverHistory?.username }));
|
||||||
};
|
};
|
||||||
|
|
||||||
submit = async (fromServerHistory?: boolean, username?: string) => {
|
submit = async ({ fromServerHistory = false, username }: ISubmitParams = {}) => {
|
||||||
logEvent(events.NS_CONNECT_TO_WORKSPACE);
|
logEvent(events.NS_CONNECT_TO_WORKSPACE);
|
||||||
const { text, certificate } = this.state;
|
const { text, certificate } = this.state;
|
||||||
const { connectServer } = this.props;
|
const { connectServer } = this.props;
|
||||||
|
|
Loading…
Reference in New Issue