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

Add/42 new product page #34115

Merged
merged 18 commits into from Aug 3, 2022
17 changes: 17 additions & 0 deletions plugins/woocommerce-admin/client/layout/controller.js
Expand Up @@ -23,6 +23,7 @@ import { Spinner } from '@woocommerce/components';
import getReports from '../analytics/report/get-reports';
import { getAdminSetting } from '~/utils/admin-settings';
import { NoMatch } from './NoMatch';
import { AddProductPage } from '~/products';

const AnalyticsReport = lazy( () =>
import( /* webpackChunkName: "analytics-report" */ '../analytics/report' )
Expand Down Expand Up @@ -162,6 +163,22 @@ export const getPages = () => {
} );
}

if ( window.wcAdminFeatures[ 'new-product-management-experience' ] ) {
pages.push( {
container: AddProductPage,
path: '/add-product',
breadcrumbs: [
[ '/add-product', __( 'Product', 'woocommerce' ) ],
__( 'Add New', 'woocommerce' ),
],
navArgs: {
id: 'woocommerce-add-product',
},
wpOpenMenu: 'menu-posts-product',
capability: 'manage_woocommerce',
} );
}

if ( window.wcAdminFeatures.onboarding ) {
pages.push( {
container: ProfileWizard,
Expand Down
16 changes: 16 additions & 0 deletions plugins/woocommerce-admin/client/products/add-product-page.tsx
@@ -0,0 +1,16 @@
/**
* External dependencies
*/
import { recordEvent } from '@woocommerce/tracks';
import { useEffect } from '@wordpress/element';

export const AddProductPage: React.FC = () => {
useEffect( () => {
recordEvent( 'view_new_product_management_experience' );
}, [] );
return (
<div className="woocommerce-add-product">
<h1>Add Product</h1>
</div>
);
};
1 change: 1 addition & 0 deletions plugins/woocommerce-admin/client/products/index.ts
@@ -0,0 +1 @@
export * from './add-product-page';
1 change: 1 addition & 0 deletions plugins/woocommerce-admin/client/typings/global.d.ts
Expand Up @@ -15,6 +15,7 @@ declare global {
'minified-js': boolean;
'mobile-app-banner': boolean;
navigation: boolean;
'new-product-management-experience': boolean;
onboarding: boolean;
'onboarding-tasks': boolean;
'payment-gateway-suggestions': boolean;
Expand Down
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/add-new-product-page
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add new product page.
1 change: 1 addition & 0 deletions plugins/woocommerce/client/admin/config/core.json
Expand Up @@ -15,6 +15,7 @@
"minified-js": false,
"mobile-app-banner": true,
"navigation": true,
"new-product-management-experience": false,
"onboarding": true,
"onboarding-tasks": true,
"remote-inbox-notifications": true,
Expand Down
1 change: 1 addition & 0 deletions plugins/woocommerce/client/admin/config/development.json
Expand Up @@ -15,6 +15,7 @@
"minified-js": true,
"mobile-app-banner": true,
"navigation": true,
"new-product-management-experience": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this as true is fine for now I think, given we have the MVP button anyway.
Once the MVP button is gone, we might want to turn this back to false and have everyone enabled it themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We usually leave the feature flags turned on in dev since it's a work in progress and the dev environment is exactly to work on those things. I'm not opposed to turning the flag off, but if we follow that pattern, I do think that we should turn off all of them in dev.

"onboarding": true,
"onboarding-tasks": true,
"payment-gateway-suggestions": true,
Expand Down
10 changes: 10 additions & 0 deletions plugins/woocommerce/includes/admin/class-wc-admin-menus.php
Expand Up @@ -9,6 +9,7 @@
use Automattic\WooCommerce\Internal\Admin\Orders\ListTable as Custom_Orders_List_Table;
use Automattic\WooCommerce\Internal\Admin\Orders\PageController as Custom_Orders_PageController;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Automattic\WooCommerce\Admin\Features\Features;

defined( 'ABSPATH' ) || exit;

Expand All @@ -32,6 +33,7 @@ public function __construct() {
// Add menus.
add_action( 'admin_menu', array( $this, 'menu_highlight' ) );
add_action( 'admin_menu', array( $this, 'menu_order_count' ) );
add_action( 'admin_menu', array( $this, 'maybe_add_new_product_management_experience' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
add_action( 'admin_menu', array( $this, 'orders_menu' ), 9 );
add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
Expand Down Expand Up @@ -416,6 +418,14 @@ public function admin_bar_menus( $wp_admin_bar ) {
);
}

/**
* Maybe add new management product experience.
*/
public function maybe_add_new_product_management_experience() {
if ( Features::is_enabled( 'new-product-management-experience' ) ) {
add_submenu_page( 'edit.php?post_type=product', __( 'Add New', 'woocommerce' ), __( 'Add New (MVP)', 'woocommerce' ), 'manage_woocommerce', 'admin.php?page=wc-admin&path=/add-product', '', 2 );
}
}
}

return new WC_Admin_Menus();
12 changes: 12 additions & 0 deletions plugins/woocommerce/src/Admin/Features/Navigation/CoreMenu.php
Expand Up @@ -213,6 +213,17 @@ public static function get_items() {
);
}

$add_product_mvp = array();
if ( Features::is_enabled( 'new-product-management-experience' ) ) {
$add_product_mvp = array(
'id' => 'woocommerce-add-product-mbp',
'title' => __( 'Add New (MVP)', 'woocommerce' ),
'url' => 'admin.php?page=wc-admin&path=/add-product',
'parent' => 'woocommerce-products',
'order' => 50,
);
}

return array_merge(
array(
$home_item,
Expand Down Expand Up @@ -242,6 +253,7 @@ public static function get_items() {
'menuId' => 'secondary',
'order' => 10,
),
$add_product_mvp,
),
// Tools category.
self::get_tool_items(),
Expand Down