fix: STRF-11856 - Filter list of channels from getStoreChannels() to storefront channels #1180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Filter the response from
getStoreChannels()
intheme-api-client.js
by channel type. Only includestorefront
channels.This change was requested by users of
stencil-cli
who were finding that the list of URLs given when runningstencil start
orstencil push
included choices that are not valid. Specifically any channel that is not a "storefront" channel is not a valid choice as there is no template to display, for example on a marketplace channel that connects to facebook there is no storefront to display.We are going to filter the list of choices we present to be specifically storefront channels. The changes in this PR are utilized by:
stencil-start.js
stencil-push.js
stencil-pull.js
stencil-download.js
Implementation details
In order to support filtering the channels we needed to add an additional v3 api call (
/v3/channels
).Previously the
getStoreChannels()
intheme-api-client.js
was making a call to GET/v3/sites
and returning this entire list as possible channels. This output looks like:The
url
seen above is what we list when asking for a channel selection but not all of the "sites" seen above are storefront channels. In order to get that information we needed to add a GET to/v3/channels
which will give back results like:I am filtering the list of sites we receive by the channel ids that have a type of
storefront
. It looks like maybe I could also filter by channels that have"is_listable_from_ui": true
.Tickets / Documentation
Screenshots (if appropriate)
I added a couple
marketplace
channels to my test store. Here is an example of howstencil start
looks when using currentmaster
:The last two choices seen above are my
marketplace
channels. With the channels in this PR we will start filtering to only return channels with a type ofstorefront
. These are the results with my changes:All three of the above output URLs are
storefront
channels.Here is an example of positive results with the
stencil push
command as well:stencil pull
stencil download
cc @bigcommerce/storefront-team