Studio: The "Add site" action doesn't work if there is no site - #570
Conversation
| // App menu is reloaded to ensure the items show the translated strings. | ||
| getIpcApi().setupAppMenu( { needsOnboarding } ); |
There was a problem hiding this comment.
I wouldn't expect that refreshing the app menu requires passing the entire config parameters, like needsOnboarding. That said, I wonder if we could create a React context to manage the app menu from a global perspective instead.
The provider will use the hook useOnboarding to retrieve needsOnboarding, and set a side effect to update that app menu as we do in:
Lines 24 to 26 in c444a1c
Additionally, the provider will expose a function to refresh the app menu that will be consumed here. We could also expose other functions in the future to make updates in the app bar in a reactive way.
With the above approach, we'll unlock updating the app menu from anywhere on the app. WDYT?
There was a problem hiding this comment.
Maybe another alternative would be reading the number of sites directly on IPC?
Something like (I didn't try the code):
export async function setupAppMenu( _event: IpcMainInvokeEvent ) {
const userData = await loadUserData();
const needsOnboarding = userData.sites.length === 0;
setupMenu( { needsOnboarding } );
}
There was a problem hiding this comment.
Since we need to manipulate just one menu item for now, I am going to merge this as this will have an immediate positive effect on the user experience. Let's open a separate issue to create a React context and make this more adaptable for future implementations.
There was a problem hiding this comment.
I created the issue related to this here: https://github.com/Automattic/dotcom-forge/issues/9313
wojtekn
left a comment
There was a problem hiding this comment.
Feature-wise works as expected, thanks!
| // App menu is reloaded to ensure the items show the translated strings. | ||
| getIpcApi().setupAppMenu( { needsOnboarding } ); |
There was a problem hiding this comment.
Maybe another alternative would be reading the number of sites directly on IPC?
Something like (I didn't try the code):
export async function setupAppMenu( _event: IpcMainInvokeEvent ) {
const userData = await loadUserData();
const needsOnboarding = userData.sites.length === 0;
setupMenu( { needsOnboarding } );
}
|
Thanks @sejas - that is what I was planning to do initially (meaning reading the amount of sites) but I found that it works similarly 👍 |

Closes #377
Proposed Changes
This PR does the following:
File > Add sitein the topbar menu, the menu option is disabledFile > Add sitein the topbar menu, that menu option is enabled ,and they can open the modal for adding a siteIt addresses the current issue when the
File > Add sitelooks enabled when the user has no sites and is on onboarding screen but clicking on it does nothing.Testing Instructions
nvm use && npm install && npm startFile > Add siteoption in the topbar menuFile > Add siteoption in the topbar menuAdd sitemenu item is enabledPre-merge Checklist