Skip to content
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

Added Workspace Menu #5921

Merged
merged 33 commits into from
Nov 30, 2021
Merged

Conversation

mananjadhav
Copy link
Collaborator

@mananjadhav mananjadhav commented Oct 17, 2021

cc - @chiragsalian

Details

  • Adds a generic popup menu to Header with options
  • Uses this popup menu to add "New workspace" and "Delete Workspace" options

Fixed Issues

$ #5185

Tests

  1. Tested the popup for all platforms - including hiding close button on desktop
  2. Checked the options for New Workspace
  3. Changed by updating language and translations
  4. Pending: Delete Workspace Testing

QA Steps

  1. Go to the right sidebar
  2. Click on any Workspace item
  3. You should see three dots (more options) menu, hover over it
  4. You should see two options - New Workspace and Delete Workspace
  5. Test both the actions are working fine
  6. Try the same steps for mobile, except that the popup should be docked at the bottom

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

web-workspace-menu

Mobile Web

mweb-workspace-menu

Desktop

desktop-workspace-menu

iOS

ios-workspace-menu

Android

android-workspace-menu

@mananjadhav
Copy link
Collaborator Author

Hi @chiragsalian,
I've got the whole PR ready except for the delete API call.

One major question is, I was trying to get the latest pull and it turns out I am not able to access this component. Did we change the flow?

image

This is the sidebar I see on click. Does the component have to be moved to this one?

@mananjadhav
Copy link
Collaborator Author

@chiragsalian Were you able to check the questions in the previous comment ?

@chiragsalian
Copy link
Contributor

Hi Manan, sorry for the delay. I must have missed your messages and then i was OOO for a little bit. Anyway feel free to message me on newDot whenever needed since i usually see the messages there faster.

So firstly, while asking a question maybe be more specific on what component you are discussing about. Makes it a little easier to figure out the flow. Okay so let me try to answer now,

I've got the whole PR ready except for the delete API call.

I believe the delete API methods are unchanged so it should work the same as before. Let me know if there is any trouble here.

I was trying to get the latest pull and it turns out I am not able to access this component. Did we change the flow?

So for N6, yeah we changed quite a bit with the front end. Especially during the last week of N6. Number of components did get modified. As for your component, i believe you are talking about this,
image

If so yes that was unfortunately removed pretty quickly during the last week of N6. Hmm i guess we gotta ask design team if we still want to stick with 3 dots or just show it as another option. I'll ask them now in the issue.

@chiragsalian
Copy link
Contributor

I just did a quick post in the issue. I imagine that most likely you've to add the 3 dots next to the close button on the new workspace (which is a slider).
image

But i've asked design to confirm.

@mananjadhav
Copy link
Collaborator Author

Thanks @chiragsalian for the response. I'll do an update on the code and hopefully nothing major in terms of changes.

I believe the delete API methods are unchanged so it should work the same as before. Let me know if there is any trouble here.

I couldn't find this in the current code. If it was added with the new n6-update, I'll have to check. Afaik, it isn't added. Hence, can you help me point to the code where delete is implemented or the API so that I can add the actions on the frontend.

@chiragsalian
Copy link
Contributor

Ah yes good question. The endpoint for deleting the workspace is not implemented in App.

But creating it should be easy since we have the endpoint. The API endpoint is called "Policy_Delete" and the argument it needs are authToken and policyID (the policyID to delete). The policyID is seen in the URL whenever you click the workspace.

Adding the delete method should be very similar to how we call Policy_Create like here. Let me know if that helps or if you have any questions around it 👍

@mananjadhav
Copy link
Collaborator Author

@chiragsalian I've made updates to the PR and currently testing. Can you help with one last thing?

return Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${response.policyID}`, null);

I am using the above code to unset the value for the policy. How do I delete a key from Onyx?

@chiragsalian
Copy link
Contributor

So there is no way to delete a key from Onyx atm. We usually just set it to empty string or null just as you have.
So your code looks good. The only thing i would say is that i don't think request returns a policyID so that code of yours should most likely be,

return Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, null);

Once you update that just make sure to test that setting it to null doesn't break anything else 🙂

@chiragsalian
Copy link
Contributor

chiragsalian commented Nov 16, 2021

Sorry for the delay. Last week i was really busy with other tasks and then i was on vacation for a few days. Now I'm back 100%. Looking into this. Hmm, the E2E test failure looks odd. As a first step, whenever there is an unusual GH Action test failure first re-run the test, and then update branch with main branch (you can do just the latter if you want since it will trigger travis test). Anyway i've re-run the job. Let's see if it fails at the same spot. I'll review the code in the meantime.

Edit: Looks like rerunning GH actions for E2E tests didn't help. Can you try merging with main and see if that helps.

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

Tested the PR. I'm facing a few issues,

  1. The moment a new workspace is created the URL show the reportID i.e., http://localhost:8080/r/255 for me instead of the workspace policyID url i.e., http://localhost:8080/workspace/52E30B06BC2CE462 (the only way to get the correct URL is by closing the workspace menu and opening it again which is weird)
  2. Creating a new workspace ends up in a loop of tons of same network requests. Let me know if you notice the same as well.

@@ -0,0 +1,11 @@
import PropTypes from 'prop-types';


Copy link
Contributor

Choose a reason for hiding this comment

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

delete extra line break

onPress: PropTypes.func,
}));


Copy link
Contributor

Choose a reason for hiding this comment

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

delete extra line break

onIconPress: () => {},
};


Copy link
Contributor

Choose a reason for hiding this comment

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

a line break should just be 1 line break and not 2. Remove the extra line break.

</Pressable>

{policy.name && (

Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra line break.

* @param {Boolean} shouldAutomaticallyReroute
* @returns {Promise}
*/
function deletePolicy(policyID = '', shouldGrowl = true, shouldAutomaticallyReroute = true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is policyID optional? It shouldn't be since the backend needs a policyID to know what to delete.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see shouldGrowl and shouldAutomaticallyReroute passed when we call this method. If that's the case let's not preoptimize here and remove these two params from the method call and just do the growl and reroute in the method. In future if there is a scenario to not show growl or reroute then we'll update as needed.

@mananjadhav
Copy link
Collaborator Author

@chiragsalian: PR Updated with the changes. About the two issues:

  1. It seems to be happening due to Navigation.dismissModal() in Policy.js:navigateToPolicy method. If I remove the dismissModal call, it works fine. I am not sure why it was added. Can you confirm?

  2. I had this issue when I raised the first draft, but not later when I submitted with screenshots. Tried creating multiple workspaces and it didn't end into a loop. Can you take the latest pull and check?

@mananjadhav
Copy link
Collaborator Author

@chiragsalian Any updates for me on this one? As I've mentioned earlier I'll resolve conflicts once all review is complete or when there are changes. I keep getting conflicts because I've updated the function component to class component.

@chiragsalian
Copy link
Contributor

Sorry yes, I was out for Thanksgiving week. Checking this now.

@chiragsalian
Copy link
Contributor

It seems to be happening due to Navigation.dismissModal() in Policy.js:navigateToPolicy method. If I remove the dismissModal call, it works fine. I am not sure why it was added. Can you confirm?

My guess is because earlier we use to show a large full screen modal and when we clicked new workspace there we wanted the modal to close. But we don't show that full-screen modal anymore so i'm pretty sure you are safe to remove it. Its usages are also only in two spots so it should be easy enough to confirm if everything runs fine.

I had this issue when I raised the first draft, but not later when I submitted with screenshots. Tried creating multiple workspaces and it didn't end into a loop. Can you take the latest pull and check?

Cool on investigation it looks like its not because of your PR and the issue lies elsewhere.

chiragsalian
chiragsalian previously approved these changes Nov 30, 2021
Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Feel free to address the conflicts and remove Navigation.dismissModal (test it a bit too)
and then i can merge your PR 👍

…rkspace-popup-menu

# Conflicts:
#	src/pages/workspace/WorkspaceInitialPage.js
#	src/styles/styles.js
@mananjadhav
Copy link
Collaborator Author

Sorry yes, I was out for Thanksgiving week. Checking this now.

@chiragsalian No problem. Thanks for the reviewing, PR updated.

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

LGTM and works well. Thank you for the changes.

@chiragsalian chiragsalian merged commit ff3625f into Expensify:main Nov 30, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Dec 7, 2021

🚀 Deployed to staging by @chiragsalian in version: 1.1.17-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Dec 8, 2021

🚀 Deployed to production by @roryabraham in version: 1.1.18-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@marcaaron
Copy link
Contributor

My guess is because earlier we use to show a large full screen modal and when we clicked new workspace there we wanted the modal to close. But we don't show that full-screen modal anymore so i'm pretty sure you are safe to remove it. Its usages are also only in two spots so it should be easy enough to confirm if everything runs fine.

It was actually because when creating a new workspace via the LogInWithShortLivedTokenPage we must dismiss the modal that shows a loading spinner here:

return <FullScreenLoadingIndicator />;

And the removal of the call to dismissModal() broke this is not obvious ways e.g.

https://github.com/Expensify/Expensify/issues/188048

This was probably hard (maybe impossible) to see because the line from LoginWithShortLivedTokenPage to policy creation (and which modal needs to be dismissed) isn't super clear.

cc @roryabraham @ctkochan22

@mananjadhav
Copy link
Collaborator Author

@marcaaron Then should I add a param to the function and add the Navigation.dismissModal back.

@marcaaron
Copy link
Contributor

No worries @mananjadhav we'll take care of it.

@mananjadhav
Copy link
Collaborator Author

Thanks, @marcaaron. Do let me know if any help is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants