Skip to content

Commit

Permalink
Merge branch 'main' into fix/25561-menuItem-date-clip-ios16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BeeMargarida committed Aug 21, 2023
2 parents 028cde3 + d1cf9be commit 92ec3f8
Show file tree
Hide file tree
Showing 49 changed files with 1,400 additions and 367 deletions.
3 changes: 3 additions & 0 deletions docs/_sass/_colors.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
$color-green400: #03D47C;
$color-green-icons: #8B9C8F;
$color-green-borders: #1A3D32;
$color-button-background: #1A3D32;
$color-button-hovered: #2C6755;
$color-green-highlightBG: #07271F;
$color-green-highlightBG-hover: #06231c;
$color-green-appBG: #061B09;
$color-green-hover: #00a862;
$color-light-gray-green: #AFBBB0;
Expand Down
75 changes: 74 additions & 1 deletion docs/_sass/_search-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

$color-appBG: $color-green-appBG;
$color-highlightBG: $color-green-highlightBG;
$color-highlightBG-hover: $color-green-highlightBG-hover;
$color-accent : $color-green400;
$color-borders: $color-green-borders;
$color-icons: $color-green-icons;
Expand All @@ -27,6 +28,7 @@ $color-gray-label: $color-gray-label;
display: block;
top: 0;
right: 0;
z-index: 2;
}

@media only screen and (max-width: $breakpoint-tablet) {
Expand Down Expand Up @@ -69,7 +71,7 @@ $color-gray-label: $color-gray-label;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
z-index: 2;
z-index: 1;
}

/* All gsc id & class are Google Search relate gcse_0 is the search bar parent & gcse_1 is the search result list parent */
Expand Down Expand Up @@ -156,6 +158,13 @@ label.search-label {
font-family: "ExpensifyNeue", "Helvetica Neue", "Helvetica", Arial, sans-serif !important;
max-height: 80vh;
overflow-y: scroll;
-ms-overflow-style: none;
scrollbar-width: none;
}

/* Hide the scrollbar */
.gsc-control-cse::-webkit-scrollbar {
display: none;
}

.gs-title {
Expand Down Expand Up @@ -195,3 +204,67 @@ label.search-label {
.gsc-resultsbox-visible .gsc-webResult .gsc-result {
border-bottom: none;
}


/* Change Font the Google Search result */
.gsc-control-cse .gsc-table-result {
font-family: "ExpensifyNeue", "Helvetica Neue", "Helvetica", Arial, sans-serif !important;
}

/* Change Font result Paragraph color */
.gsc-results .gs-webResult:not(.gs-no-results-result):not(.gs-error-result) .gs-snippet, .gs-fileFormatType {
color: $color-text;
}


/* Change the color of the Google Search Suggestion font */
.gs-spelling.gs-result {
color: $color-text;
}

/* Pagination related style */
.gsc-resultsbox-visible .gsc-results .gsc-cursor-box {
text-align: center;
}

.gsc-resultsbox-visible .gsc-results .gsc-cursor-box .gsc-cursor-page {
margin: 4px;
width: 28px;
height: 28px;
border-radius: 25px;
display: inline-block;
line-height: 2.5;
background-color: $color-accent;
font-weight: bold;
font-size: 11px;
}


/* Change the color & background of Google Search Pagination */
.gsc-cursor-next-page,
.gsc-cursor-final-page {
color: $color-text;
background-color: $color-appBG;
}

/* Change the color & background of Google Search Current Page */
.gsc-resultsbox-visible .gsc-results .gsc-cursor-box .gsc-cursor-page.gsc-cursor-current-page {
background-color: $color-accent;
color: $color-text;

&:hover {
text-decoration: none;
background-color: $color-accent;
}
}

/* Change the color & background of Google Search of Other Page */
.gsc-resultsbox-visible .gsc-results .gsc-cursor-box .gsc-cursor-page {
background-color: $color-button-background;
color: $color-text;

&:hover {
background-color: $color-button-hovered;
text-decoration: none;
}
}
35 changes: 25 additions & 10 deletions docs/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ function injectFooterCopywrite() {
footer.innerHTML = `©2008-${new Date().getFullYear()} Expensify, Inc.`;
}

function openSidebar() {
document.getElementById('sidebar-layer').style.display = 'block';

// Make body unscrollable
const yAxis = document.documentElement.style.getPropertyValue('y-axis');
const body = document.body;
body.style.position = 'fixed';
body.style.top = `-${yAxis}`;
}

function closeSidebar() {
document.getElementById('sidebar-layer').style.display = 'none';

Expand All @@ -100,6 +90,31 @@ function closeSidebar() {
window.scrollTo(0, parseInt(scrollY || '0', 10) * -1);
}

function closeSidebarOnClickOutside(event) {
const sidebarLayer = document.getElementById('sidebar-layer');

if (event.target !== sidebarLayer) {
return;
}
closeSidebar();
}

function openSidebar() {
document.getElementById('sidebar-layer').style.display = 'block';

// Make body unscrollable
const yAxis = document.documentElement.style.getPropertyValue('y-axis');
const body = document.body;
body.style.position = 'fixed';
body.style.top = `-${yAxis}`;

// Close the sidebar when clicking sidebar layer (outside the sidebar search)
const sidebarLayer = document.getElementById('sidebar-layer');
if (sidebarLayer) {
sidebarLayer.addEventListener('click', closeSidebarOnClickOutside);
}
}

// Function to adapt & fix cropped SVG viewBox from Google based on viewport (Mobile or Tablet-Desktop)
function changeSVGViewBoxGoogle() {
// Get all inline Google SVG elements on the page
Expand Down
2 changes: 1 addition & 1 deletion docs/context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<search_restrict_args lr="" cr="" gl="" filter="0" sort="" as_siteseach="" as_oq=""></search_restrict_args>
</image_advanced_options>
<search_options link_target=""></search_options>
<custom_search_control_options no_results_string="Oops no results found, Please try again..."></custom_search_control_options>
<custom_search_control_options no_results_string="Oops, I couldn't find that. Please try again!"></custom_search_control_options>
</cse_advance_settings>
<sort_by_keys label="Relevance" key=""></sort_by_keys>
<sort_by_keys label="Date" key="date"></sort_by_keys>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"react-web-config": "^1.0.0",
"react-window": "^1.8.9",
"save": "^2.4.0",
"semver": "^7.3.8",
"semver": "^7.5.2",
"shim-keyboard-event-key": "^1.0.3",
"underscore": "^1.13.1"
},
Expand Down
3 changes: 3 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,9 @@ const CONST = {
AMOUNT_MAX_LENGTH: 10,
RECEIPT_STATE: {
SCANREADY: 'SCANREADY',
SCANNING: 'SCANNING',
SCANCOMPLETE: 'SCANCOMPLETE',
SCANFAILED: 'SCANFAILED',
},
FILE_TYPES: {
HTML: 'html',
Expand Down
5 changes: 3 additions & 2 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
// Credentials to authenticate the user
CREDENTIALS: 'credentials',

// Contains loading data for the IOU feature (MoneyRequestModal, IOUDetail, & IOUPreview Components)
// Contains loading data for the IOU feature (MoneyRequestModal, IOUDetail, & MoneyRequestPreview Components)
IOU: 'iou',

// Keeps track if there is modal currently visible or not
Expand Down Expand Up @@ -221,8 +221,9 @@ export default {
NEW_TASK_FORM: 'newTaskForm',
EDIT_TASK_FORM: 'editTaskForm',
MONEY_REQUEST_DESCRIPTION_FORM: 'moneyRequestDescriptionForm',
MONEY_REQUEST_MERCHANT_FORM: 'moneyRequestMerchantForm',
MONEY_REQUEST_AMOUNT_FORM: 'moneyRequestAmountForm',
MONEY_REQUEST_CREATED_FORM: 'moneyRequestCreatedForm',
MONEY_REQUEST_DATE_FORM: 'moneyRequestCreatedForm',
NEW_CONTACT_METHOD_FORM: 'newContactMethodForm',
PAYPAL_FORM: 'payPalForm',
WAYPOINT_FORM: 'waypointForm',
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ export default {
MONEY_REQUEST_AMOUNT: ':iouType/new/amount/:reportID?',
MONEY_REQUEST_PARTICIPANTS: ':iouType/new/participants/:reportID?',
MONEY_REQUEST_CONFIRMATION: ':iouType/new/confirmation/:reportID?',
MONEY_REQUEST_DATE: ':iouType/new/date/:reportID?',
MONEY_REQUEST_CURRENCY: ':iouType/new/currency/:reportID?',
MONEY_REQUEST_DESCRIPTION: ':iouType/new/description/:reportID?',
MONEY_REQUEST_MERCHANT: ':iouType/new/merchant/:reportID?',
MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual',
MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan',
MONEY_REQUEST_DISTANCE_TAB: ':iouType/new/:reportID?/distance',
Expand All @@ -102,8 +104,10 @@ export default {
getMoneyRequestAmountRoute: (iouType, reportID = '') => `${iouType}/new/amount/${reportID}`,
getMoneyRequestParticipantsRoute: (iouType, reportID = '') => `${iouType}/new/participants/${reportID}`,
getMoneyRequestConfirmationRoute: (iouType, reportID = '') => `${iouType}/new/confirmation/${reportID}`,
getMoneyRequestCreatedRoute: (iouType, reportID = '') => `${iouType}/new/date/${reportID}`,
getMoneyRequestCurrencyRoute: (iouType, reportID = '', currency, backTo) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}`,
getMoneyRequestDescriptionRoute: (iouType, reportID = '') => `${iouType}/new/description/${reportID}`,
getMoneyRequestMerchantRoute: (iouType, reportID = '') => `${iouType}/new/merchant/${reportID}`,
getMoneyRequestDistanceTabRoute: (iouType, reportID = '') => `${iouType}/new/${reportID}/distance`,
getMoneyRequestWaypointRoute: (iouType, waypointIndex) => `${iouType}/new/waypoint/${waypointIndex}`,
SPLIT_BILL_DETAILS: `r/:reportID/split/:reportActionID`,
Expand Down
7 changes: 5 additions & 2 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function AttachmentModal(props) {
const [shouldLoadAttachment, setShouldLoadAttachment] = useState(false);
const [isAttachmentInvalid, setIsAttachmentInvalid] = useState(false);
const [isAuthTokenRequired, setIsAuthTokenRequired] = useState(props.isAuthTokenRequired);
const [isAttachmentReceipt, setIsAttachmentReceipt] = useState(false);
const [attachmentInvalidReasonTitle, setAttachmentInvalidReasonTitle] = useState('');
const [attachmentInvalidReason, setAttachmentInvalidReason] = useState(null);
const [source, setSource] = useState(props.source);
Expand All @@ -118,12 +119,13 @@ function AttachmentModal(props) {

/**
* Keeps the attachment source in sync with the attachment displayed currently in the carousel.
* @param {{ source: String, isAuthTokenRequired: Boolean, file: { name: string } }} attachment
* @param {{ source: String, isAuthTokenRequired: Boolean, file: { name: string }, isReceipt: Boolean }} attachment
*/
const onNavigate = useCallback(
(attachment) => {
setSource(attachment.source);
setFile(attachment.file);
setIsAttachmentReceipt(attachment.isReceipt);
setIsAuthTokenRequired(attachment.isAuthTokenRequired);
onCarouselAttachmentChange(attachment);
},
Expand Down Expand Up @@ -314,6 +316,7 @@ function AttachmentModal(props) {
}, []);

const sourceForAttachmentView = props.source || source;

return (
<>
<Modal
Expand All @@ -334,7 +337,7 @@ function AttachmentModal(props) {
>
{props.isSmallScreenWidth && <HeaderGap />}
<HeaderWithBackButton
title={props.headerTitle || translate('common.attachment')}
title={props.headerTitle || translate(isAttachmentReceipt ? 'common.receipt' : 'common.attachment')}
shouldShowBorderBottom
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton}
onDownloadButtonPress={() => downloadAttachment(source)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {Parser as HtmlParser} from 'htmlparser2';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
import * as TransactionUtils from '../../../libs/TransactionUtils';
import * as ReceiptUtils from '../../../libs/ReceiptUtils';
import CONST from '../../../CONST';
import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot';

Expand Down Expand Up @@ -28,6 +31,7 @@ function extractAttachmentsFromReport(report, reportActions) {
source: tryResolveUrlFromApiRoot(expensifySource || attribs.src),
isAuthTokenRequired: Boolean(expensifySource),
file: {name: attribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE]},
isReceipt: false,
});
},
});
Expand All @@ -36,6 +40,28 @@ function extractAttachmentsFromReport(report, reportActions) {
if (!ReportActionsUtils.shouldReportActionBeVisible(action, key)) {
return;
}

// We're handling receipts differently here because receipt images are not
// part of the report action message, the images are constructed client-side
if (ReportActionsUtils.isMoneyRequestAction(action)) {
const transactionID = lodashGet(action, ['originalMessage', 'IOUTransactionID']);
if (!transactionID) {
return;
}

const transaction = TransactionUtils.getTransaction(transactionID);
if (TransactionUtils.hasReceipt(transaction)) {
const {image} = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename);
attachments.unshift({
source: tryResolveUrlFromApiRoot(image),
isAuthTokenRequired: true,
file: {name: transaction.filename},
isReceipt: true,
});
return;
}
}

htmlParser.write(_.get(action, ['message', 0, 'html']));
});
htmlParser.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const customHTMLElementModels = {
'mention-here': defaultHTMLElementModels.span.extend({tagName: 'mention-here'}),
};

const defaultViewProps = {style: [styles.alignItemsStart, styles.userSelectText]};
const defaultViewProps = {style: [styles.alignItemsStart, styles.userSelectText, styles.w100, styles.h100]};

// We are using the explicit composite architecture for performance gains.
// Configuration for RenderHTML is handled in a top-level component providing
Expand Down
19 changes: 12 additions & 7 deletions src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,33 @@ function ImageRenderer(props) {
// Concierge responder attachments are uploaded to S3 without any access
// control and thus require no authToken to verify access.
//
const isAttachment = Boolean(htmlAttribs[CONST.ATTACHMENT_SOURCE_ATTRIBUTE]);
const isAttachmentOrReceipt = Boolean(htmlAttribs[CONST.ATTACHMENT_SOURCE_ATTRIBUTE]);

// Files created/uploaded/hosted by App should resolve from API ROOT. Other URLs aren't modified
const previewSource = tryResolveUrlFromApiRoot(htmlAttribs.src);
const source = tryResolveUrlFromApiRoot(isAttachment ? htmlAttribs[CONST.ATTACHMENT_SOURCE_ATTRIBUTE] : htmlAttribs.src);
const source = tryResolveUrlFromApiRoot(isAttachmentOrReceipt ? htmlAttribs[CONST.ATTACHMENT_SOURCE_ATTRIBUTE] : htmlAttribs.src);

const imageWidth = htmlAttribs['data-expensify-width'] ? parseInt(htmlAttribs['data-expensify-width'], 10) : undefined;
const imageHeight = htmlAttribs['data-expensify-height'] ? parseInt(htmlAttribs['data-expensify-height'], 10) : undefined;
const imagePreviewModalDisabled = htmlAttribs['data-expensify-preview-modal-disabled'] === 'true';

const shouldFitContainer = htmlAttribs['data-expensify-fit-container'] === 'true';
const sizingStyle = shouldFitContainer ? [styles.w100, styles.h100] : [];

return imagePreviewModalDisabled ? (
<ThumbnailImage
previewSourceURL={previewSource}
style={styles.webViewStyles.tagStyles.img}
isAuthTokenRequired={isAttachment}
style={shouldFitContainer ? [styles.w100, styles.h100] : styles.webViewStyles.tagStyles.img}
isAuthTokenRequired={isAttachmentOrReceipt}
imageWidth={imageWidth}
imageHeight={imageHeight}
shouldDynamicallyResize={!shouldFitContainer}
/>
) : (
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
<PressableWithoutFocus
style={[styles.noOutline]}
style={[styles.noOutline, ...sizingStyle]}
onPress={() => {
const route = ROUTES.getReportAttachmentRoute(report.reportID, source);
Navigation.navigate(route);
Expand All @@ -66,10 +70,11 @@ function ImageRenderer(props) {
>
<ThumbnailImage
previewSourceURL={previewSource}
style={styles.webViewStyles.tagStyles.img}
isAuthTokenRequired={isAttachment}
style={shouldFitContainer ? [styles.w100, styles.h100] : styles.webViewStyles.tagStyles.img}
isAuthTokenRequired={isAttachmentOrReceipt}
imageWidth={imageWidth}
imageHeight={imageHeight}
shouldDynamicallyResize={!shouldFitContainer}
/>
</PressableWithoutFocus>
)}
Expand Down
Loading

0 comments on commit 92ec3f8

Please sign in to comment.