Skip to content

Commit

Permalink
Merge pull request #14334 from wordpress-mobile/gutenberg/remove-swit…
Browse files Browse the repository at this point in the history
…ch-to-classic

Remove switch to classic from gutenberg
  • Loading branch information
cameronvoell authored Mar 25, 2021
2 parents d8923f8 + a4d1c1e commit 7547ffd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.wordpress.android.e2e.pages.BlockEditorPage;
import org.wordpress.android.e2e.pages.EditorPage;
import org.wordpress.android.e2e.pages.MySitesPage;
import org.wordpress.android.e2e.pages.PostPreviewPage;
import org.wordpress.android.e2e.pages.SiteSettingsPage;
Expand Down Expand Up @@ -58,12 +57,7 @@ public void testSwitchToClassicAndPreview() {

blockEditorPage.enterTitle(title);

blockEditorPage.switchToClassic();

EditorPage editorPage = new EditorPage();
editorPage.hasTitle(title);

editorPage.previewPost();
blockEditorPage.previewPost();
sleep();

new PostPreviewPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withHint;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.wordpress.android.support.WPSupportUtils.clickOn;
import static org.wordpress.android.support.WPSupportUtils.waitForElementToBeDisplayed;

Expand All @@ -34,8 +35,8 @@ public void enterTitle(String postTitle) {
titleField.perform(typeText(postTitle), ViewActions.closeSoftKeyboard());
}

public void switchToClassic() {
public void previewPost() {
openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext());
clickOn("Switch to classic editor");
clickOn(onView(withText(R.string.menu_preview)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1213,25 +1213,15 @@ public boolean onPrepareOptionsMenu(Menu menu) {
}
}

MenuItem switchToAztecMenuItem = menu.findItem(R.id.menu_switch_to_aztec);
MenuItem switchToGutenbergMenuItem = menu.findItem(R.id.menu_switch_to_gutenberg);

// The following null checks should basically be redundant but were added to manage
// an odd behaviour recorded with Android 8.0.0
// (see https://github.com/wordpress-mobile/WordPress-Android/issues/9748 for more information)
if (switchToAztecMenuItem != null && switchToGutenbergMenuItem != null) {
if (mShowGutenbergEditor) {
// we're showing Gutenberg so, just offer the Aztec switch
switchToAztecMenuItem.setVisible(true);
switchToGutenbergMenuItem.setVisible(false);
} else {
// we're showing Aztec so, hide the "Switch to Aztec" menu
switchToAztecMenuItem.setVisible(false);

switchToGutenbergMenuItem.setVisible(
shouldSwitchToGutenbergBeVisible(mEditorFragment, mSite)
);
}
if (switchToGutenbergMenuItem != null) {
boolean switchToGutenbergVisibility = mShowGutenbergEditor ? false
: shouldSwitchToGutenbergBeVisible(mEditorFragment, mSite);
switchToGutenbergMenuItem.setVisible(switchToGutenbergVisibility);
}

MenuItem contentInfo = menu.findItem(R.id.menu_content_info);
Expand Down Expand Up @@ -1418,19 +1408,6 @@ public boolean onOptionsItemSelected(final MenuItem item) {
} else if (mEditorFragment instanceof GutenbergEditorFragment) {
((GutenbergEditorFragment) mEditorFragment).onToggleHtmlMode();
}
} else if (itemId == R.id.menu_switch_to_aztec) {
// The following boolean check should be always redundant but was added to manage
// an odd behaviour recorded with Android 8.0.0
// (see https://github.com/wordpress-mobile/WordPress-Android/issues/9748 for more information)
if (mShowGutenbergEditor) {
// let's finish this editing instance and start again, but not letting Gutenberg be used
mRestartEditorOption = RestartEditorOptions.RESTART_SUPPRESS_GUTENBERG;
mPostEditorAnalyticsSession.switchEditor(Editor.CLASSIC);
mPostEditorAnalyticsSession.setOutcome(Outcome.SAVE);
mViewModel.finish(ActivityFinishState.SAVED_LOCALLY);
} else {
logWrongMenuState("Wrong state in menu_switch_to_aztec: menu should not be visible.");
}
} else if (itemId == R.id.menu_switch_to_gutenberg) {
// The following boolean check should be always redundant but was added to manage
// an odd behaviour recorded with Android 8.0.0
Expand Down
5 changes: 0 additions & 5 deletions WordPress/src/main/res/menu/edit_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
<group
android:orderInCategory="1" >

<item
android:id="@+id/menu_switch_to_aztec"
android:title="@string/menu_switch_to_aztec_editor">
</item>

<item
android:id="@+id/menu_switch_to_gutenberg"
android:title="@string/menu_switch_to_gutenberg_editor">
Expand Down
1 change: 0 additions & 1 deletion WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,6 @@
<string name="menu_undo">Undo</string>
<string name="menu_redo">Redo</string>
<string name="menu_debug">Debug Menu</string>
<string name="menu_switch_to_aztec_editor">Switch to classic editor</string>
<string name="menu_switch_to_gutenberg_editor">Switch to block editor</string>
<string name="menu_content_info">Content structure</string>

Expand Down

0 comments on commit 7547ffd

Please sign in to comment.