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

Disable features on static posters phase #18132

Merged
merged 6 commits into from
Mar 17, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ class JetpackFeatureRemovalPhaseHelper @Inject constructor(
}
}

fun shouldShowJetpackPoweredEditorFeatures(): Boolean {
val currentPhase = getCurrentPhase() ?: return true
return when (currentPhase) {
is PhaseStaticPosters, PhaseFour, PhaseNewUsers, PhaseSelfHostedUsers -> false
else -> true
}
}

fun shouldShowTemplateSelectionInPages(): Boolean {
val currentPhase = getCurrentPhase() ?: return true
return when (currentPhase) {
is PhaseStaticPosters, PhaseFour, PhaseNewUsers, PhaseSelfHostedUsers -> false
else -> true
}
}

@Suppress("Unused")
fun shouldShowStaticPage(): Boolean {
val currentPhase = getCurrentPhase() ?: return false
Expand All @@ -108,6 +124,22 @@ class JetpackFeatureRemovalPhaseHelper @Inject constructor(
is PhaseOne, PhaseTwo, PhaseThree, PhaseStaticPosters -> true
}
}

fun shouldShowQuickStart(): Boolean {
val currentPhase = getCurrentPhase() ?: return true
return when (currentPhase) {
is PhaseStaticPosters, PhaseFour, PhaseNewUsers, PhaseSelfHostedUsers -> false
else -> true
}
}

fun shouldShowHelpAndSupportOnEditor(): Boolean {
val currentPhase = getCurrentPhase() ?: return true
return when (currentPhase) {
is PhaseStaticPosters, PhaseFour, PhaseNewUsers, PhaseSelfHostedUsers -> false
else -> true
}
}
}
// Global overlay frequency is the frequency at which the overlay is shown across the features
// no matter which feature was accessed last time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ private void initViewModel() {
break;
case CREATE_NEW_PAGE:
if (mMLPViewModel.canShowModalLayoutPicker()
&& !mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
&& mJetpackFeatureRemovalPhaseHelper.shouldShowTemplateSelectionInPages()) {
mMLPViewModel.createPageFlowTriggered();
} else {
handleNewPageAction("", "", null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ class MySiteViewModel @Inject constructor(
isSiteTitleTaskCompleted: Boolean,
isNewSite: Boolean
) {
if (!jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()) return
quickStartRepository.checkAndSetQuickStartType(isNewSite = isNewSite)
if (quickStartDynamicCardsFeatureConfig.isEnabled()) {
startQuickStart(siteLocalId, isSiteTitleTaskCompleted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class PagesFragment : Fragment(R.layout.pages_fragment), ScrollableViewInitializ

viewModel.createNewPage.observe(viewLifecycleOwner, {
if (mlpViewModel.canShowModalLayoutPicker()
&& !jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
&& jetpackFeatureRemovalPhaseHelper.shouldShowTemplateSelectionInPages()) {
mlpViewModel.createPageFlowTriggered()
} else {
createNewPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,8 +1335,8 @@ public boolean onPrepareOptionsMenu(Menu menu) {
if (helpMenuItem != null) {
// Support section will be disabled in WordPress app when Jetpack-powered features are removed.
// Therefore, we have to update the Help menu item accordingly.
boolean jetpackFeaturesRemoved = mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures();
int helpMenuTitle = jetpackFeaturesRemoved ? R.string.help : R.string.help_and_support;
boolean showHelpAndSupport = mJetpackFeatureRemovalPhaseHelper.shouldShowHelpAndSupportOnEditor();
int helpMenuTitle = showHelpAndSupport ? R.string.help_and_support : R.string.help;
helpMenuItem.setTitle(helpMenuTitle);

if (mEditorFragment instanceof GutenbergEditorFragment
Expand Down Expand Up @@ -2272,7 +2272,7 @@ public Fragment getItem(int position) {
gutenbergWebViewAuthorizationData,
gutenbergPropsBuilder,
RequestCodes.EDIT_STORY,
!mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()
mJetpackFeatureRemovalPhaseHelper.shouldShowJetpackPoweredEditorFeatures()
);
} else {
// If gutenberg editor is not selected, default to Aztec.
Expand Down Expand Up @@ -2360,7 +2360,7 @@ private GutenbergPropsBuilder getGutenbergPropsBuilder() {
String hostAppNamespace = mBuildConfigWrapper.isJetpackApp() ? "Jetpack" : "WordPress";

// Disable Jetpack-powered editor features in WordPress app based on Jetpack Features Removal Phase helper
boolean jetpackFeaturesRemoved = mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures();
boolean jetpackFeaturesRemoved = !mJetpackFeatureRemovalPhaseHelper.shouldShowJetpackPoweredEditorFeatures();
if (jetpackFeaturesRemoved) {
return new GutenbergPropsBuilder(
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ class MySiteViewModelTest : BaseUnitTest() {
@Test
fun `given dynamic cards enabled + new site, when check & start QS triggered, then new site QS starts`() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(true)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, false, isNewSite = true)

Expand All @@ -1422,6 +1423,7 @@ class MySiteViewModelTest : BaseUnitTest() {
fun `given dynamic cards enabled + existing site, when check & start QS triggered, then existing site QS starts`() {
whenever(quickStartRepository.quickStartType).thenReturn(ExistingSiteQuickStartType)
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(true)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, false, isNewSite = false)

Expand All @@ -1438,6 +1440,7 @@ class MySiteViewModelTest : BaseUnitTest() {
fun `given no selected site, when check and start QS is triggered, then QSP is not shown`() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(false)
whenever(selectedSiteRepository.getSelectedSite()).thenReturn(null)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, isSiteTitleTaskCompleted = false, isNewSite = false)

Expand All @@ -1449,6 +1452,7 @@ class MySiteViewModelTest : BaseUnitTest() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(false)
whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site)
whenever(quickStartUtilsWrapper.isQuickStartAvailableForTheSite(site)).thenReturn(false)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, isSiteTitleTaskCompleted = false, isNewSite = true)

Expand All @@ -1460,6 +1464,7 @@ class MySiteViewModelTest : BaseUnitTest() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(false)
whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site)
whenever(quickStartUtilsWrapper.isQuickStartAvailableForTheSite(site)).thenReturn(false)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, isSiteTitleTaskCompleted = false, isNewSite = false)

Expand All @@ -1471,6 +1476,7 @@ class MySiteViewModelTest : BaseUnitTest() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(false)
whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site)
whenever(quickStartUtilsWrapper.isQuickStartAvailableForTheSite(site)).thenReturn(true)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, false, isNewSite = true)

Expand All @@ -1489,6 +1495,7 @@ class MySiteViewModelTest : BaseUnitTest() {
whenever(quickStartDynamicCardsFeatureConfig.isEnabled()).thenReturn(false)
whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site)
whenever(quickStartUtilsWrapper.isQuickStartAvailableForTheSite(site)).thenReturn(true)
whenever(jetpackFeatureRemovalPhaseHelper.shouldShowQuickStart()).thenReturn(true)

viewModel.checkAndStartQuickStart(siteLocalId, false, isNewSite = false)

Expand Down