Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/icon-paper-clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 0 additions & 55 deletions src/components/Anchor/index.js

This file was deleted.

55 changes: 0 additions & 55 deletions src/components/Anchor/index.native.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/lib/openURLInNewTab/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* On web, the Linking.openURL implementation does not open a URL in a new tab by default. This lib allows for that
* functionality.
*/

/**
* @param {String} href
*/
const openURLInNewTab = (href) => {
window.open(href, '_blank');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refactor the <Anchor> component to use openURLInNewTab? It has the same idea where we have to use window.open on web and Linking for native.

cc @marcaaron or @tgolen for thoughts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Do they differ in any other way besides this method? I think that's a good case for eliminating two separate implementations by creating a shared behavior instead of components that specialize in a behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it out and it works! I'll remove the Anchor component and add some tests to this PR confirm the behavior

};

export default openURLInNewTab;
12 changes: 12 additions & 0 deletions src/lib/openURLInNewTab/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Mobile implementation to match the web lib, this will open the URL in the browser

import {Linking} from 'react-native';

/**
* @param {String} href
*/
const openURLInNewTab = (href) => {
Linking.openURL(href);
};

export default openURLInNewTab;
18 changes: 18 additions & 0 deletions src/page/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import {View, Image, TouchableOpacity} from 'react-native';
import styles, {colors} from '../../../style/StyleSheet';
import TextInputFocusable from '../../../components/TextInputFocusable';
import sendIcon from '../../../../assets/images/icon-send.png';
import paperClipIcon from '../../../../assets/images/icon-paper-clip.png';
import CONFIG from '../../../CONFIG';
import openURLInNewTab from '../../../lib/openURLInNewTab';

const propTypes = {
// A method to call when the form is submitted
onSubmit: PropTypes.func.isRequired,

// The ID of the report actions will be created for
reportID: PropTypes.number.isRequired,
};

class ReportActionCompose extends React.Component {
Expand Down Expand Up @@ -73,9 +79,21 @@ class ReportActionCompose extends React.Component {
}

render() {
const href = `${CONFIG.PUSHER.AUTH_URL}/report?reportID=${this.props.reportID}&shouldScrollToLastUnread=true`;
return (
<View style={[styles.chatItemCompose]}>
<View style={[styles.chatItemComposeBox, styles.flexRow]}>
<TouchableOpacity
onPress={() => openURLInNewTab(href)}
style={[styles.chatItemAttachButton]}
underlayColor={colors.componentBG}
>
<Image
style={[styles.chatItemSubmitButtonIcon]}
resizeMode="contain"
source={paperClipIcon}
/>
</TouchableOpacity>
<TextInputFocusable
multiline
textAlignVertical="top"
Expand Down
1 change: 1 addition & 0 deletions src/page/home/report/ReportView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ReportView extends React.PureComponent {
{shouldShowComposeForm && (
<ReportActionCompose
onSubmit={text => addAction(this.props.reportID, text)}
reportID={this.props.reportID}
/>
)}

Expand Down
21 changes: 11 additions & 10 deletions src/page/home/sidebar/AppLinks.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import React from 'react';
import styles from '../../../style/StyleSheet';
import Anchor from '../../../components/Anchor';
import openURLInNewTab from '../../../lib/openURLInNewTab';
import Text from '../../../components/Text';

const AppLinks = () => (
<>
<Anchor
<Text
style={[styles.sidebarFooterLink, styles.mr2]}
href="https://chat.expensify.com/Chat.dmg"
onPress={() => openURLInNewTab('https://chat.expensify.com/Chat.dmg')}
>
Desktop
</Anchor>
<Anchor
</Text>
<Text
style={[styles.sidebarFooterLink, styles.mr2]}
href="https://testflight.apple.com/join/ucuXr4g5"
onPress={() => openURLInNewTab('https://testflight.apple.com/join/ucuXr4g5')}
>
iOS
</Anchor>
<Anchor
</Text>
<Text
style={[styles.sidebarFooterLink, styles.mr2]}
href="https://play.google.com/apps/internaltest/4700657970395613233"
onPress={() => openURLInNewTab('https://play.google.com/apps/internaltest/4700657970395613233')}
>
Android
</Anchor>
</Text>
</>
);

Expand Down
22 changes: 19 additions & 3 deletions src/style/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const styles = {
borderWidth: 1,
color: colors.textReversed,
padding: 12,
outline: 'none',
outlineWidth: 0,
},

textInputReversedFocus: {
Expand Down Expand Up @@ -544,10 +544,14 @@ const styles = {

textInputCompose: {
borderWidth: 0,
outline: 0,
borderRadius: 0,
outlineWidth: 0,
height: 'auto',
minHeight: 38,
padding: 10,
paddingTop: 10,
paddingRight: 8,
paddingBottom: 10,
paddingLeft: 8,
},

chatItemSubmitButton: {
Expand All @@ -567,6 +571,18 @@ const styles = {
width: 20,
},

chatItemAttachButton: {
alignItems: 'center',
alignSelf: 'flex-end',
borderRightColor: colors.border,
borderRightWidth: 1,
height: 26,
marginBottom: 6,
marginTop: 6,
justifyContent: 'center',
width: 39,
},

chatSwitcherInputClear: {
alignSelf: 'center',
},
Expand Down