Skip to content

Commit cdf6290

Browse files
authored
Remove null steps that are added (#135)
## Motivation for the change, related issues The [resolveBlueprintFromURL](https://github.com/Automattic/wp-calypso/blob/99caa52a8105ebbe0ad78e911665815ca522df2e/client/landing/stepper/declarative-flow/internals/steps-repository/playground/lib/resolve-blueprint-from-url.ts#L64-L89) function returns a steps: `[null, null, null]` array. This happens when `importWxrQueryArg` is `null` or `query.get( 'import-site' )` is `null` or `query.get( 'theme' )` is `null`. If these values are `null` the step is added as a `null` value. It should not be added at all. https://linear.app/a8c/issue/DOTOBRD-124/wrong-blueprints-steps-from-resolveblueprintfromurl-url-url Props to @zaerl for the investigation ## Implementation details - Filter falsy value out (easier to just look at both commits)
1 parent 481ee95 commit cdf6290

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

packages/playground/website/src/lib/state/url/resolve-blueprint-from-url.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
BlueprintDeclaration,
33
BlueprintBundle,
44
Blueprint,
5+
StepDefinition,
56
} from '@wp-playground/client';
67
import {
78
getBlueprintDeclaration,
@@ -66,30 +67,33 @@ export async function resolveBlueprintFromURL(
6667
plugins: query.getAll('plugin'),
6768
steps: [
6869
importWxrQueryArg &&
69-
/^(http(s?)):\/\//i.test(importWxrQueryArg) && {
70+
/^(http(s?)):\/\//i.test(importWxrQueryArg) &&
71+
({
7072
step: 'importWxr',
7173
file: {
7274
resource: 'url',
7375
url: importWxrQueryArg,
7476
},
75-
},
77+
} as StepDefinition),
7678
query.get('import-site') &&
77-
/^(http(s?)):\/\//i.test(query.get('import-site')!) && {
79+
/^(http(s?)):\/\//i.test(query.get('import-site')!) &&
80+
({
7881
step: 'importWordPressFiles',
7982
wordPressFilesZip: {
8083
resource: 'url',
8184
url: query.get('import-site')!,
8285
},
83-
},
84-
query.get('theme') && {
85-
step: 'installTheme',
86-
themeData: {
87-
resource: 'wordpress.org/themes',
88-
slug: query.get('theme')!,
89-
},
90-
progress: { weight: 2 },
91-
},
92-
],
86+
} as StepDefinition),
87+
query.get('theme') &&
88+
({
89+
step: 'installTheme',
90+
themeData: {
91+
resource: 'wordpress.org/themes',
92+
slug: query.get('theme')!,
93+
},
94+
progress: { weight: 2 },
95+
} as StepDefinition),
96+
].filter(Boolean),
9397
};
9498
source = {
9599
type: 'none',

0 commit comments

Comments
 (0)