woocommerce/plugins/woocommerce-admin/client/marketplace/utils/functions.tsx

472 lines
11 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import apiFetch from '@wordpress/api-fetch';
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
import { __, sprintf } from '@wordpress/i18n';
My subscriptions error notices (#41124) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Add error notices * Move update to functions * Add notice store * Fix linter errors * Remove temp file * Add changefile(s) from automation for the following project(s): woocommerce * Don't autoremove notices * Add status to notices * Send just required path field * Subvscribe hover color * Css linter fix * Fix error notice style * Update manage button text * Linter fixes --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-07 08:21:12 +00:00
import { dispatch } from '@wordpress/data';
import { Options } from '@wordpress/notices';
import { Icon } from '@wordpress/components';
/**
* Internal dependencies
*/
import { LOCALE, getAdminSetting } from '../../utils/admin-settings';
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
import { CategoryAPIItem } from '../components/category-selector/types';
2023-09-28 15:09:37 +00:00
import {
MARKETPLACE_CART_PATH,
MARKETPLACE_CATEGORY_API_PATH,
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
MARKETPLACE_HOST,
MARKETPLACE_SEARCH_API_PATH,
} from '../components/constants';
2023-09-26 12:12:14 +00:00
import { Subscription } from '../components/my-subscriptions/types';
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
import {
Product,
ProductType,
SearchAPIJSONType,
SearchAPIProductType,
} from '../components/product-list/types';
My subscriptions error notices (#41124) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Add error notices * Move update to functions * Add notice store * Fix linter errors * Remove temp file * Add changefile(s) from automation for the following project(s): woocommerce * Don't autoremove notices * Add status to notices * Send just required path field * Subvscribe hover color * Css linter fix * Fix error notice style * Update manage button text * Linter fixes --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-07 08:21:12 +00:00
import { NoticeStatus } from '../contexts/types';
import { noticeStore } from '../contexts/notice-store';
interface ProductGroup {
2023-08-15 12:37:50 +00:00
id: string;
title: string;
items: Product[];
url: string;
Marketplace Themes: Feature Branch (#40159) * Support for themes in in-app marketplace. Contains the changes from: https://github.com/woocommerce/woocommerce/pull/40247 https://github.com/woocommerce/woocommerce/pull/40272 https://github.com/woocommerce/woocommerce/pull/40302 https://github.com/woocommerce/woocommerce/pull/40303 https://github.com/woocommerce/woocommerce/pull/40333 https://github.com/woocommerce/woocommerce/pull/40368 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40389 * `.woocommerce-marketplace__discover`: changed `align-items` `flex-start` to `stretch` to properly display products on large and very large viewports. * Delete plugins/woocommerce/changelog/add-18026-marketplace-theme-cards Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-18027-themes-to-in-app-search Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-marketplace-theme-discover-section Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-in-app-multiple-category-filters Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-theme-no-result-style Removing from feature branch before final review * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: Dan Q <dan@danq.me> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Dan Q <danq@automattic.com>
2023-10-04 16:59:34 +00:00
itemType: ProductType;
}
2023-09-28 16:05:51 +00:00
// The fetchCache stores the results of GET fetch/apiFetch calls from the Marketplace, in RAM, for performance
const maxFetchCacheSize = 100;
const fetchCache = new Map();
function maybePruneFetchCache() {
while ( fetchCache.size > maxFetchCacheSize ) {
fetchCache.delete( fetchCache.keys().next().value );
}
}
2023-09-28 16:14:02 +00:00
// Wrapper around apiFetch() that caches results in memory
async function apiFetchWithCache( params: object ): Promise< object > {
2023-09-28 16:14:02 +00:00
// Attempt to fetch from cache:
const cacheKey = JSON.stringify( params );
if ( fetchCache.get( cacheKey ) ) {
return new Promise( ( resolve ) => {
resolve( fetchCache.get( cacheKey ) );
} );
}
// Failing that, fetch using apiCache:
return new Promise( ( resolve, reject ) => {
apiFetch( params )
.then( ( json ) => {
fetchCache.set( cacheKey, json );
maybePruneFetchCache();
resolve( json as object );
2023-09-28 16:14:02 +00:00
} )
.catch( () => {
reject();
} );
} );
}
// Wrapper around fetch() that caches results in memory
2023-10-12 09:56:46 +00:00
async function fetchJsonWithCache(
url: string,
abortSignal?: AbortSignal
): Promise< object > {
// Attempt to fetch from cache:
2023-09-28 16:05:51 +00:00
if ( fetchCache.get( url ) ) {
2023-09-28 15:09:37 +00:00
return new Promise( ( resolve ) => {
2023-09-28 16:05:51 +00:00
resolve( fetchCache.get( url ) );
2023-09-28 15:09:37 +00:00
} );
}
// Failing that, fetch from net:
return new Promise( ( resolve, reject ) => {
fetch( url, { signal: abortSignal } )
2023-09-28 15:09:44 +00:00
.then( ( response ) => {
if ( ! response.ok ) {
throw new Error( response.statusText );
}
return response.json();
} )
.then( ( json ) => {
2023-09-28 16:05:51 +00:00
fetchCache.set( url, json );
maybePruneFetchCache();
2023-09-28 15:09:44 +00:00
resolve( json );
} )
.catch( () => {
reject();
} );
} );
}
// Fetch search results for a given set of URLSearchParams from the WooCommerce.com API
2023-09-28 15:09:37 +00:00
async function fetchSearchResults(
params: URLSearchParams,
abortSignal?: AbortSignal
2023-09-28 15:09:37 +00:00
): Promise< Product[] > {
const url =
MARKETPLACE_HOST +
MARKETPLACE_SEARCH_API_PATH +
'?' +
params.toString();
// Fetch data from WCCOM API
return new Promise( ( resolve, reject ) => {
fetchJsonWithCache( url, abortSignal )
.then( ( json ) => {
/**
* Product card component expects a Product type.
* So we build that object from the API response.
*/
2023-09-29 10:02:48 +00:00
const products = ( json as SearchAPIJSONType ).products.map(
( product: SearchAPIProductType ): Product => {
return {
id: product.id,
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
slug: product.slug,
title: product.title,
image: product.image,
type: product.type,
description: product.excerpt,
vendorName: product.vendor_name,
vendorUrl: product.vendor_url,
icon: product.icon,
url: product.link,
// Due to backwards compatibility, raw_price is from search API, price is from featured API
price: product.raw_price ?? product.price,
averageRating: product.rating ?? null,
reviewsCount: product.reviews_count ?? null,
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
isInstallable: product.is_installable,
};
}
);
resolve( products );
} )
.catch( () => reject );
} );
}
// Fetch data for the discover page from the WooCommerce.com API
async function fetchDiscoverPageData(): Promise< ProductGroup[] > {
let url = '/wc/v3/marketplace/featured';
if ( LOCALE.userLocale ) {
url = `${ url }?locale=${ LOCALE.userLocale }`;
}
try {
return ( await apiFetchWithCache( {
path: url.toString(),
} ) ) as Promise< ProductGroup[] >;
} catch ( error ) {
return [];
}
}
Marketplace Themes: Feature Branch (#40159) * Support for themes in in-app marketplace. Contains the changes from: https://github.com/woocommerce/woocommerce/pull/40247 https://github.com/woocommerce/woocommerce/pull/40272 https://github.com/woocommerce/woocommerce/pull/40302 https://github.com/woocommerce/woocommerce/pull/40303 https://github.com/woocommerce/woocommerce/pull/40333 https://github.com/woocommerce/woocommerce/pull/40368 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40389 * `.woocommerce-marketplace__discover`: changed `align-items` `flex-start` to `stretch` to properly display products on large and very large viewports. * Delete plugins/woocommerce/changelog/add-18026-marketplace-theme-cards Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-18027-themes-to-in-app-search Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-marketplace-theme-discover-section Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-in-app-multiple-category-filters Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-theme-no-result-style Removing from feature branch before final review * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: Dan Q <dan@danq.me> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Dan Q <danq@automattic.com>
2023-10-04 16:59:34 +00:00
function fetchCategories( type: ProductType ): Promise< CategoryAPIItem[] > {
const url = new URL( MARKETPLACE_HOST + MARKETPLACE_CATEGORY_API_PATH );
if ( LOCALE.userLocale ) {
Marketplace Themes: Feature Branch (#40159) * Support for themes in in-app marketplace. Contains the changes from: https://github.com/woocommerce/woocommerce/pull/40247 https://github.com/woocommerce/woocommerce/pull/40272 https://github.com/woocommerce/woocommerce/pull/40302 https://github.com/woocommerce/woocommerce/pull/40303 https://github.com/woocommerce/woocommerce/pull/40333 https://github.com/woocommerce/woocommerce/pull/40368 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40389 * `.woocommerce-marketplace__discover`: changed `align-items` `flex-start` to `stretch` to properly display products on large and very large viewports. * Delete plugins/woocommerce/changelog/add-18026-marketplace-theme-cards Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-18027-themes-to-in-app-search Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-marketplace-theme-discover-section Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-in-app-multiple-category-filters Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-theme-no-result-style Removing from feature branch before final review * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: Dan Q <dan@danq.me> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Dan Q <danq@automattic.com>
2023-10-04 16:59:34 +00:00
url.searchParams.set( 'locale', LOCALE.userLocale );
}
// We don't define parent for extensions since that is provided by default
// This is to ensure the old marketplace continues to work when this isn't defined
if ( type === ProductType.theme ) {
url.searchParams.set( 'parent', 'themes' );
}
return (
fetchJsonWithCache( url.toString() ) as Promise< CategoryAPIItem[] >
)
2023-08-09 13:04:35 +00:00
.then( ( json ) => {
return json;
} )
.catch( () => {
return [];
} );
}
2023-09-26 12:12:14 +00:00
async function fetchSubscriptions(): Promise< Array< Subscription > > {
const url = '/wc/v3/marketplace/subscriptions';
return await apiFetch( { path: url.toString() } );
}
async function refreshSubscriptions(): Promise< Array< Subscription > > {
const url = '/wc/v3/marketplace/refresh';
return await apiFetch( {
path: url.toString(),
method: 'POST',
} );
}
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
function connectProduct( subscription: Subscription ): Promise< void > {
if ( subscription.active === true ) {
return Promise.resolve();
}
const url = '/wc/v3/marketplace/subscriptions/connect';
const data = new URLSearchParams();
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
data.append( 'product_key', subscription.product_key );
return apiFetch( {
path: url.toString(),
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
} );
}
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
function disconnectProduct( subscription: Subscription ): Promise< void > {
if ( subscription.active === false ) {
return Promise.resolve();
}
const url = '/wc/v3/marketplace/subscriptions/disconnect';
const data = new URLSearchParams();
data.append( 'product_key', subscription.product_key );
return apiFetch( {
path: url.toString(),
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
} );
}
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
type WpAjaxReponse = {
success: boolean;
data: WpAjaxResponseData;
};
type WpAjaxResponseData = {
errorMessage?: string;
activateUrl?: string;
};
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
function wpAjax(
action: string,
data: {
slug?: string;
plugin?: string;
theme?: string;
success?: boolean;
}
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
): Promise< WpAjaxReponse > {
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
return new Promise( ( resolve, reject ) => {
if ( ! window.wp.updates ) {
reject( __( 'Please reload and try again', 'woocommerce' ) );
return;
}
window.wp.updates.ajax( action, {
...data,
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
success: ( response: WpAjaxResponseData ) => {
resolve( {
success: true,
data: response,
} );
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
},
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
error: ( error: WpAjaxResponseData ) => {
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
reject( {
success: false,
data: {
message: error.errorMessage,
},
} );
},
} );
} );
}
function activateProduct( subscription: Subscription ): Promise< void > {
if ( subscription.local.active === true ) {
return Promise.resolve();
}
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
const url = '/wc/v3/marketplace/subscriptions/activate';
const data = new URLSearchParams();
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
data.append( 'product_key', subscription.product_key );
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
return apiFetch( {
path: url.toString(),
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
} )
.then( () => Promise.resolve() )
.catch( () =>
Promise.reject( {
success: false,
data: {
message: sprintf(
// translators: %s is the product name.
__(
'%s could not be activated. Please activate it manually.',
'woocommerce'
),
subscription.product_name
),
},
} )
);
}
function getInstallUrl( subscription: Subscription ): Promise< string > {
return apiFetch( {
path:
'/wc/v3/marketplace/subscriptions/install-url?product_key=' +
subscription.product_key,
} ).then( ( response ) => {
return ( response as { data: { url: string } } )?.data.url;
} );
}
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
function downloadProduct( productType: string, zipSlug: string ) {
return wpAjax( 'install-' + productType, {
// The slug prefix is required for the install to use WCCOM install filters.
slug: zipSlug,
} );
}
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
function installProduct( subscription: Subscription ): Promise< void > {
return connectProduct( subscription ).then( () => {
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
return downloadProduct(
subscription.product_type,
subscription.zip_slug
)
Update/my subscriptions wp installer (#40990) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Remove unnecessary is_null check --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-06 08:35:43 +00:00
.then( () => {
return activateProduct( subscription );
} )
.catch( ( error ) => {
// If install fails disconnect the product
return disconnectProduct( subscription ).finally( () =>
Promise.reject( error )
);
} );
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
} );
}
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
function updateProduct( subscription: Subscription ): Promise< WpAjaxReponse > {
My subscriptions error notices (#41124) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Add error notices * Move update to functions * Add notice store * Fix linter errors * Remove temp file * Add changefile(s) from automation for the following project(s): woocommerce * Don't autoremove notices * Add status to notices * Send just required path field * Subvscribe hover color * Css linter fix * Fix error notice style * Update manage button text * Linter fixes --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-07 08:21:12 +00:00
return wpAjax( 'update-' + subscription.product_type, {
slug: subscription.local.slug,
[ subscription.product_type ]: subscription.local.path,
} );
}
function addNotice(
productKey: string,
message: string,
status?: NoticeStatus,
options?: Partial< Options >
) {
if ( status === NoticeStatus.Error ) {
dispatch( noticeStore ).addNotice(
productKey,
message,
status,
options
);
} else {
if ( ! options?.icon ) {
options = {
...options,
icon: <Icon icon="saved" />,
};
}
My subscriptions error notices (#41124) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Add error notices * Move update to functions * Add notice store * Fix linter errors * Remove temp file * Add changefile(s) from automation for the following project(s): woocommerce * Don't autoremove notices * Add status to notices * Send just required path field * Subvscribe hover color * Css linter fix * Fix error notice style * Update manage button text * Linter fixes --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-07 08:21:12 +00:00
dispatch( 'core/notices' ).createSuccessNotice( message, options );
}
}
const removeNotice = ( productKey: string ) => {
dispatch( noticeStore ).removeNotice( productKey );
};
const subscriptionToProduct = ( subscription: Subscription ): Product => {
return {
id: subscription.product_id,
title: subscription.product_name,
image: '',
type: subscription.product_type as ProductType,
description: '',
vendorName: '',
vendorUrl: '',
icon: subscription.product_icon,
url: subscription.product_url,
price: -1,
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
averageRating: null,
reviewsCount: null,
isInstallable: false,
};
};
// Append UTM parameters to a URL, being aware of existing query parameters
const appendURLParams = (
url: string,
utmParams: Array< [ string, string ] >
): string => {
Marketplace Themes: Feature Branch (#40159) * Support for themes in in-app marketplace. Contains the changes from: https://github.com/woocommerce/woocommerce/pull/40247 https://github.com/woocommerce/woocommerce/pull/40272 https://github.com/woocommerce/woocommerce/pull/40302 https://github.com/woocommerce/woocommerce/pull/40303 https://github.com/woocommerce/woocommerce/pull/40333 https://github.com/woocommerce/woocommerce/pull/40368 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40375 https://github.com/woocommerce/woocommerce/pull/40389 * `.woocommerce-marketplace__discover`: changed `align-items` `flex-start` to `stretch` to properly display products on large and very large viewports. * Delete plugins/woocommerce/changelog/add-18026-marketplace-theme-cards Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-18027-themes-to-in-app-search Removing from feature branch before final review * Delete plugins/woocommerce/changelog/add-marketplace-theme-discover-section Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-in-app-multiple-category-filters Removing from feature branch before final review * Delete plugins/woocommerce/changelog/update-theme-no-result-style Removing from feature branch before final review * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: Dan Q <dan@danq.me> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Dan Q <danq@automattic.com>
2023-10-04 16:59:34 +00:00
if ( ! url ) {
return url;
}
const urlObject = new URL( url );
if ( ! urlObject ) {
return url;
}
utmParams.forEach( ( [ key, value ] ) => {
urlObject.searchParams.set( key, value );
} );
return urlObject.toString();
};
const renewUrl = ( subscription: Subscription ): string => {
return appendURLParams( MARKETPLACE_CART_PATH, [
[ 'renew_product', subscription.product_id.toString() ],
[ 'product_key', subscription.product_key ],
[ 'order_id', subscription.order_id.toString() ],
] );
};
const subscribeUrl = ( subscription: Subscription ): string => {
return appendURLParams( MARKETPLACE_CART_PATH, [
[ 'add-to-cart', subscription.product_id.toString() ],
] );
};
const connectUrl = (): string => {
const wccomSettings = getAdminSetting( 'wccomHelper', {} );
if ( ! wccomSettings.connectURL ) {
return '';
}
return appendURLParams( wccomSettings.connectURL, [
[ 'redirect_admin_url', encodeURIComponent( window.location.href ) ],
] );
};
export {
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
ProductGroup,
appendURLParams,
connectProduct,
fetchCategories,
My subscription product updates (#40752) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-10-27 04:08:27 +00:00
fetchDiscoverPageData,
fetchSearchResults,
2023-09-26 12:12:14 +00:00
fetchSubscriptions,
refreshSubscriptions,
getInstallUrl,
Marketplace: Add "Add to Store" button for free and WordPress.org products #43616 (#43983) * Marketplace: Add "Add to Store" button for free and WordPress.org products (#43616) * Marketplace: Install free .org plugins with Add to Store button * Marketplace: addressed feedback for the the new install free products flow - Moved notices to the top of the modal - Updated notice styles slightly - Updated the CreateOrderSuccessResponse to reflect API changes * Marketplace: Require the Helper orders API file * Marketplace: fix linter errors * Marketplace: form encode when submitting the request The body is encoded anyways by the WordPress core. However, if I don't do it here, I can't create a valid signature to be verified by Woo.com. I could have just submitted a JSON too, but this seamed easier since the body is parsed on Woo.com automatically when it's in this form. * Add changefile(s) from automation for the following project(s): woocommerce * Marketplace: remove "~" character in imports and use relative paths * Marketplace: fix margins in the product with the Add to Store button * Marketplace: Add conditions to hide the button We hide it if: - the product is already installed - user doesn't have the right capability - if the product is just installed using our flow and there is no page refresh * Marketplace: don't show Add to Store button on Themes and on Discover * Marketplace: fix linting * Marketplace: hide ratings from the product if "is-small" class exists * Marketplace: fix linting errors --------- Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 20:02:20 +00:00
downloadProduct,
activateProduct,
installProduct,
My subscriptions error notices (#41124) * Marketplace: Populate the table rows with components * Marketplace: add links to dropdown menu and fix fallback product icons * Marketplace: fix popover width * Add My subscriptions install (#40630) * Marketplace: add plugin install from the subscriptions page Co-authored-by: berislav grgičak <berislav.grgicak@gmail.com> * Marketplace: Use the activation function to show install button --------- Co-authored-by: raicem <unalancem@gmail.com> * Add WP updates script to the extensions page * Add update button * Add update data to subscriptions * Update plugins * Prevent update if license unavailable * Add changefile(s) from automation for the following project(s): woocommerce * Remove all data from API * Linter fixes * Linter fixes * Remove merge string * Update link style * Add comment for updates.js * Prevent updates if required data is missing * Return removed slug code * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Switch to WP installer * Use WP installer * Remove install endpoint * Fix php warning * Add download_link if subscription exists * My subscriptions action modals (#40934) * Add renew modal * Update install to run until new data loaded * Add activate modal * Add connect modal * Add renew button * Renewal button * Rename activate to connect * Add subscribe button * Add action buttons * Remove unused const * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce-admin/client/marketplace/components/my-subscriptions/my-subscriptions.scss Co-authored-by: And Finally <andfinally@users.noreply.github.com> * Update import path --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> * Use product slugs for installing * Add store for installing state * Add theme install support * Product activate endpoint * Activate after install * PHP warning * Update context * Debugging * Install context * Linter * Simplify context * Use Redux instead of context * Add changefile(s) from automation for the following project(s): woocommerce * Replace ~ with relative paths * Add error notices * Move update to functions * Add notice store * Fix linter errors * Remove temp file * Add changefile(s) from automation for the following project(s): woocommerce * Don't autoremove notices * Add status to notices * Send just required path field * Subvscribe hover color * Css linter fix * Fix error notice style * Update manage button text * Linter fixes --------- Co-authored-by: raicem <unalancem@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2023-11-07 08:21:12 +00:00
updateProduct,
addNotice,
removeNotice,
renewUrl,
subscribeUrl,
subscriptionToProduct,
connectUrl,
};