forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): prefill parameters for workflow submit form. Fixes argoproj#…
…1214 Signed-off-by: Sairam Arunachalam <sair.aruna@gmail.com>
- Loading branch information
Showing
4 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Method to extract a key from query parameter. The query parameter will be of the following format | ||
* ?parameters[key]=value. | ||
* This method will extract the key from the query parameter. | ||
* @param inputString | ||
* @returns | ||
*/ | ||
function extractKey(inputString: string): string | null { | ||
// Use regular expression to match the key within square brackets | ||
const match = inputString.match(/parameters\[(.*?)\]/); | ||
|
||
// If a match is found, return the captured key | ||
if (match) { | ||
return match[1]; | ||
} | ||
|
||
// If no match is found, return null or an empty string | ||
return null; // Or return ''; | ||
} | ||
|
||
export function getWorkflowParametersFromQuery(): {[key: string]: string} { | ||
const queryParams = new URLSearchParams(location.search); | ||
|
||
const parameters: {[key: string]: string} = {}; | ||
for (const [key, value] of queryParams.entries()) { | ||
const q = extractKey(key); | ||
if (q) { | ||
parameters[q] = value; | ||
} | ||
} | ||
|
||
return parameters; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters