-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share Code URL implementation based on Environment URL #20843
Conversation
@alex-mechler @mananjadhav One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
src/libs/Environment/Environment.js
Outdated
getEnvironment().then((environment) => | ||
{ | ||
// Our approach is to use staging url only for staging environment and use production url for all other environments. | ||
const environmentURL = (environment === CONST.ENVIRONMENT.STAGING) ? Url.addTrailingForwardSlash(CONST.STAGING_NEW_EXPENSIFY_URL) : CONST.NEW_EXPENSIFY_URL; | ||
resolve(environmentURL); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you verified every other instance of this function needs this change and you didn't break anything else? Seems like possibly this is the wrong spot to be doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the details section, 'Copy Link' is the only other place where we use getEnvironmentURL(). There, we need this change as the use case is similar to the share code
one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying a link on this branch seems broken, I see a double slash: https://new.expensify.com//r/65129373/1852577140352880000
I don't on main
:
http://localhost:8080/r/65129373/1852577140352880000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Didn't notice the extra slash. Thanks for pointing it out. Will remove the extra slash here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, why not include a slash in the code that uses this function? Ideally we can keep that code the same and make the least amount of code changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, wouldn't it be easier to not modify this file at all? and use Url.addTrailingForwardSlash
in the file where we are actually using the URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, our existing approach is to ensure that the configured URLs have a trailing slash using the helper function Url.addTrailingForwardSlash
. If the configured URL already has a trailing slash, it will ignore. Else, it will add the trailing slash. If we want to follow the approach of ensuring that there is no trailing slash in the configured URLs, we will have to implement additional code to remove the trailing slash from configured URLs. Also, the URLs in the environment configuration files have a trailing slash. So, I strongly think that we should not attempt a change of approach here towards handling of trailing slash in URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also have a look at ACTIVE_EXPENSIFY_URL. So, it would be better to keep the existing approach itself as it would be easier and will have less code changes and associated risks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewGable @mananjadhav Please let me know your comments on my comments above too so that we can decide and take it further
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rojiphil I've commented again. The reason I think we went ahead with environment was it takes care of DEV env too.
A small request. Can one of you please add the following accounts to high-traffic accounts for testing purposes: |
@alex-mechler @mananjadhav @AndrewGable Updated PR with more test case result videos + lint checks compliance. |
src/libs/Environment/Environment.js
Outdated
getEnvironment().then((environment) => | ||
{ | ||
// Our approach is to use staging url only for staging environment and use production url for all other environments. | ||
const environmentURL = (environment === CONST.ENVIRONMENT.STAGING) ? Url.addTrailingForwardSlash(CONST.STAGING_NEW_EXPENSIFY_URL) : CONST.NEW_EXPENSIFY_URL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I am confused was't the staging URL being returned when the environment was STAGING? I mean the ENVIRONMENT_URLS ? I don't see a point of adding this change? @rojiphil
@AndrewGable wdyt?
@@ -206,7 +206,7 @@ export default [ | |||
onPress: (closePopover, {reportAction, reportID}) => { | |||
Environment.getEnvironmentURL().then((environmentURL) => { | |||
const reportActionID = parseInt(lodashGet(reportAction, 'reportActionID'), 10); | |||
Clipboard.setString(`${environmentURL}/r/${reportID}/${reportActionID}`); | |||
Clipboard.setString(`${environmentURL}r/${reportID}/${reportActionID}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is needed if we rollback the commit for environment URL?
@rojiphil I've raised the same comment again. I think we're over complicating the PR. The change of adding the new prop is fine, and I think we shouldn't be touching the Environment URL logic. This way you won't need to change Clipboard file too. @AndrewGable wdyt? |
@mananjadhav Reason why I think we should add trailing slash to staging url is this: |
I got what you meant, but instead of updating the code to add slash, isn't it better to actually make the URLs consistent? One way to do that would be to update the |
But I am going to confirm with @AndrewGable and @alex-mechler if we are okay to use ACTIVE_EXPENSIFY_URL ignoring the DEV URL. |
@mananjadhav Ok. Another thing to note while making the decision is that these URLs can come from the environment configuration files (i.e. .env.staging, .env.production). And so, I don't think it is just enough to make URLs consistent from within the code. We need to ensure that we adjust to a configured URL that may come with or without slash. I think, the person who implemented this would have recognized this fact and decided to always make sure that there is always a trailing slash. The helper function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mananjadhav @AndrewGable I have integrated your review comments with following changes:
a) Rolled back changes in Environment.js file.
b) Rolled back changes in ContextMenuActions.js
c) Added trailing slash code in ShareCodePage.
You were right. We need to keep it simple. Sorry for overdoing the code.
I have updated the review comments also accordingly. KIndly review
Thanks for addressing the changes @rojiphil. I did a quick review of the code, looks fine. I'll take a look at this again in 2 hours or so along with the testing. |
ce0d562
to
e6c2704
Compare
Oh!! Very sorry for this. I was merging the conflict. And, I force-pushed. Have created another PR here. |
@mananjadhav @alex-mechler @kevinksullivan @AndrewGable
Details
The following changes can be done to incorporate the functionality in a common place:
a) Leverage the existing
WithEnvironment
component and add support forenvironmentURL
. This variable will contain the environment-specific URL fromEnvironment
.b) Use the
environmentURL
fromWithEnvironment
to decide on the URL for use withShare code
functionality. Also, ensure that a trailing slash is present in the environment url.Fixed Issues
$ #19464
PROPOSAL: #19464 (comment)
Tests
Prerequisite:
Find out the latest production version at https://api.github.com/repos/expensify/app/releases/latest.
Tag_name will represent the latest deployed production version
"tag_name": "1.3.27-7",
Here, the latest deployed production version is 1.3.27-7
i) Staging:
Build an android app that uses a production environment configuration file with package version of 1.3.27-8
"version": "1.3.27-8", (i.e. in package.json)
Follow the steps as below:
a) Verify version in Settings->About
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://staging.new.expensify.com/
ii) Production:
Build an android app that uses production environment configuration file with package version of 1.3.27-7
"version": "1.3.27-7", (i.e. in package.json)
Follow the steps below:
a) Verify version in Settings->About
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
iii) Development:
Follow the steps as below:
a) Verify 'dev' label next to
Expensify
in header.b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://localhost:8080/
i) Development Version:
a) Launch the expensify app at http://localhost:8080/
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://localhost:8080/
i) Production Version:
a) Launch the electron production App
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
ii) Staging Version:
a) Launch the electron staging App
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://staging.new.expensify.com/
i) Production Environment:
a) Launch the production iOS Native app
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
i) MacOS/iOS-Safari
a) Launch the dev version on Safari in MacOS
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://localhost:8080/
Offline tests
i) Android-Native Production Version:
a) Ensure mobile is offline (Disconnect from WiFi and Mobile Data)
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
QA Steps
Following additional test steps are required:
i) Staging Deployment:
a) Launch the expensify app at https://staging.new.expensify.com/
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://staging.new.expensify.com/
ii) Production Deployment:
a) Launch the expensify app at https://new.expensify.com/
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
i) Staging:
a) Setup TestFlight for iOS and launch app
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://staging.new.expensify.com/
ii) Production:
a) Install production version from iOS App Store and launch app.
b) Copy URL to keyboard in Settings->Share code
c) Paste it in the compose box of one of the existing chat
d) Verify that the URL starts with https://new.expensify.com/
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android-Native-Staging (1->i)
new-android-native-staging.mp4
Android-Native-Production (1->ii)
new-android-native-prod.mp4
Android-Native-Development (1->iii)
new-android-native-dev.mp4
mWeb-Chrome-Development Version (2->i)
new-mweb-chrome-dev.mp4
MacOS / Desktop Production
new_dtop_prod.mp4
MacOS / Desktop Staging
new_dtop_stag.mp4
iOS / Native - Simulator - Production
new_iosnative_prod.mp4
MacOS / Safari -Dev
new_macossafari_dev.mp4
Offline - Android Native Prod
new_offline_android_prod.mp4