Skip to content

Commit 0314ce5

Browse files
authored
PR Preview: document and simplify targetParams (#2052)
Adds a docstring about the structure of targetParams in the PR Preview modals. Also, simplifies the condition used to decide whether we've received a PR number or a URL.
1 parent d28d36a commit 0314ce5

File tree

1 file changed

+5
-4
lines changed
  • packages/playground/website/src/github/preview-pr

1 file changed

+5
-4
lines changed

packages/playground/website/src/github/preview-pr/form.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ interface PreviewPRFormProps {
1313

1414
const urlParams = new URLSearchParams(window.location.search);
1515

16+
// This structure is from plugin-proxy.php
17+
// where we set allowed inputs for WordPress and Gutenberg repositories
1618
export const targetParams = {
1719
wordpress: {
1820
repo: 'wordpress-develop',
1921
workflow: 'Test%20Build%20Processes',
2022
artifact: 'wordpress-build-',
23+
pull: 'github.com/wordpress/wordpress-develop/pull'
2124
},
2225
gutenberg: {
2326
repo: 'gutenberg',
2427
workflow: 'Build%20Gutenberg%20Plugin%20Zip',
2528
artifact: 'gutenberg-plugin',
29+
pull: 'github.com/wordpress/gutenberg/pull'
2630
},
2731
};
2832

@@ -73,10 +77,7 @@ export default function PreviewPRForm({
7377
if (
7478
prNumber
7579
.toLowerCase()
76-
.includes('github.com/wordpress/wordpress-develop/pull') ||
77-
prNumber
78-
.toLowerCase()
79-
.includes('github.com/wordpress/gutenberg/pull')
80+
.includes(targetParams[target].pull)
8081
) {
8182
prNumber = prNumber.match(/\/pull\/(\d+)/)![1];
8283
}

0 commit comments

Comments
 (0)