Skip to content

Commit

Permalink
PR Preview: document and simplify targetParams (#2052)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajotka authored Dec 10, 2024
1 parent d28d36a commit 0314ce5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/playground/website/src/github/preview-pr/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ interface PreviewPRFormProps {

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

// This structure is from plugin-proxy.php
// where we set allowed inputs for WordPress and Gutenberg repositories
export const targetParams = {
wordpress: {
repo: 'wordpress-develop',
workflow: 'Test%20Build%20Processes',
artifact: 'wordpress-build-',
pull: 'github.com/wordpress/wordpress-develop/pull'
},
gutenberg: {
repo: 'gutenberg',
workflow: 'Build%20Gutenberg%20Plugin%20Zip',
artifact: 'gutenberg-plugin',
pull: 'github.com/wordpress/gutenberg/pull'
},
};

Expand Down Expand Up @@ -73,10 +77,7 @@ export default function PreviewPRForm({
if (
prNumber
.toLowerCase()
.includes('github.com/wordpress/wordpress-develop/pull') ||
prNumber
.toLowerCase()
.includes('github.com/wordpress/gutenberg/pull')
.includes(targetParams[target].pull)
) {
prNumber = prNumber.match(/\/pull\/(\d+)/)![1];
}
Expand Down

0 comments on commit 0314ce5

Please sign in to comment.