-
-
Notifications
You must be signed in to change notification settings - Fork 73
Use custom rendering for input step #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
25de2cc
66af9d3
b9dd319
fa6a3fa
f914f78
db32237
5573b02
dd8a373
3aff4e3
6cbd44e
114f58e
4909e06
a9d290a
d95057f
86d5c28
c777af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,39 +41,6 @@ export default function ConsoleLogCard(props: ConsoleLogCardProps) { | |
| props.onStepToggle(props.step.id); | ||
| }; | ||
|
|
||
| const showMoreLogs = () => { | ||
| let startByte = props.stepBuffer.startByte - LOG_FETCH_SIZE; | ||
| if (startByte < 0) startByte = 0; | ||
| props.onMoreConsoleClick(props.step.id, startByte); | ||
| }; | ||
|
|
||
| const getTruncatedLogWarning = () => { | ||
| if (props.stepBuffer.lines && props.stepBuffer.startByte > 0) { | ||
| return ( | ||
| <button | ||
| onClick={showMoreLogs} | ||
| className={ | ||
| "pgv-show-more-logs jenkins-button jenkins-!-warning-color" | ||
| } | ||
| > | ||
| There’s more to see - {prettySizeString(props.stepBuffer.startByte)}{" "} | ||
| of logs hidden | ||
| </button> | ||
| ); | ||
| } | ||
| return undefined; | ||
| }; | ||
|
|
||
| const prettySizeString = (size: number) => { | ||
| const kib = 1024; | ||
| const mib = 1024 * 1024; | ||
| const gib = 1024 * 1024 * 1024; | ||
| if (size < kib) return `${size}B`; | ||
| if (size < mib) return `${(size / kib).toFixed(2)}KiB`; | ||
| if (size < gib) return `${(size / mib).toFixed(2)}MiB`; | ||
| return `${(size / gib).toFixed(2)}GiB`; | ||
| }; | ||
|
|
||
| const messages = useMessages(); | ||
|
|
||
| return ( | ||
|
|
@@ -162,18 +129,117 @@ export default function ConsoleLogCard(props: ConsoleLogCardProps) { | |
| </div> | ||
|
|
||
| {props.isExpanded && ( | ||
| <ConsoleLogBody | ||
| step={props.step} | ||
| stepBuffer={props.stepBuffer} | ||
| onMoreConsoleClick={props.onMoreConsoleClick} | ||
| isExpanded={false} | ||
| onStepToggle={props.onStepToggle} | ||
| /> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function ConsoleLogBody(props: ConsoleLogCardProps) { | ||
| const inputStep = props.step.inputStep; | ||
| if (inputStep && !inputStep.parameters) { | ||
| function handler(id: string, action: string) { | ||
| fetch(`../input/${id}/${action}`, { | ||
| method: "POST", | ||
| headers: (window as any).crumb.wrap({}), | ||
| }) | ||
| .then((res) => { | ||
| console.log(res); | ||
|
||
| return true; | ||
| }) | ||
| .catch((err) => { | ||
| console.error(err); | ||
| }); | ||
| } | ||
|
|
||
| const ok = () => { | ||
| return handler(inputStep.id, "proceedEmpty"); | ||
| }; | ||
|
|
||
| const abort = () => { | ||
| return handler(inputStep.id, "abort"); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <div style={{ paddingTop: "0.5rem" }}> | ||
| {getTruncatedLogWarning()} | ||
| <Suspense> | ||
| <ConsoleLogStream | ||
| logBuffer={props.stepBuffer} | ||
| onMoreConsoleClick={props.onMoreConsoleClick} | ||
| step={props.step} | ||
| maxHeightScale={0.65} | ||
| /> | ||
| </Suspense> | ||
| <div className={"console-output-line"}> | ||
| <a style={{ width: "30px" }} className={"console-line-number"} /> | ||
| <p style={{ fontWeight: "var(--font-bold-weight)" }}> | ||
| {inputStep.message} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| )} | ||
| <div className={"console-output-line"}> | ||
| <a style={{ width: "30px" }} className={"console-line-number"} /> | ||
| <div | ||
| className={"jenkins-buttons-row jenkins-buttons-row--equal-width"} | ||
| > | ||
| <button | ||
| onClick={ok} | ||
| className={"jenkins-button jenkins-button--primary"} | ||
| > | ||
| {inputStep.ok} | ||
|
||
| </button> | ||
| <button onClick={abort} className={"jenkins-button"}> | ||
| {inputStep.cancel} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| const prettySizeString = (size: number) => { | ||
| const kib = 1024; | ||
| const mib = 1024 * 1024; | ||
| const gib = 1024 * 1024 * 1024; | ||
| if (size < kib) return `${size}B`; | ||
| if (size < mib) return `${(size / kib).toFixed(2)}KiB`; | ||
| if (size < gib) return `${(size / mib).toFixed(2)}MiB`; | ||
| return `${(size / gib).toFixed(2)}GiB`; | ||
| }; | ||
|
|
||
| const showMoreLogs = () => { | ||
| let startByte = props.stepBuffer.startByte - LOG_FETCH_SIZE; | ||
| if (startByte < 0) startByte = 0; | ||
| props.onMoreConsoleClick(props.step.id, startByte); | ||
| }; | ||
|
|
||
| const getTruncatedLogWarning = () => { | ||
| if (props.stepBuffer.lines && props.stepBuffer.startByte > 0) { | ||
| return ( | ||
| <button | ||
| onClick={showMoreLogs} | ||
| className={ | ||
| "pgv-show-more-logs jenkins-button jenkins-!-warning-color" | ||
| } | ||
| > | ||
| There’s more to see - {prettySizeString(props.stepBuffer.startByte)}{" "} | ||
| of logs hidden | ||
| </button> | ||
| ); | ||
| } | ||
| return undefined; | ||
| }; | ||
|
|
||
| return ( | ||
| <div style={{ paddingTop: "0.5rem" }}> | ||
| {getTruncatedLogWarning()} | ||
| <Suspense> | ||
janfaracik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <ConsoleLogStream | ||
| logBuffer={props.stepBuffer} | ||
| onMoreConsoleClick={props.onMoreConsoleClick} | ||
| step={props.step} | ||
| maxHeightScale={0.65} | ||
| /> | ||
| </Suspense> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package io.jenkins.plugins.pipelinegraphview.utils; | ||
|
|
||
| public record PipelineInputStep(String message, String cancel, String id, String ok, boolean parameters) {} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jackson with our current config can't serialise the parameters object (if not more) so just map what we need |
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the values of type? Could it be set to input instead of a new field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its STEP, it could be but I need a number of fields anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I missed deleting this comment after a further look through the rest of the code