Skip to content
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

wf-details: do not change chosen log tab automatically #353

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Version 0.9.1 (UNRELEASED)
- Changes the workflow progress bar to always display it as full for finished workflows.
- Changes the interactive session notification by adding a message stating that the session will be closed after a specified number of days inactivity.
- Changes the workflow-details page to make it possible to scroll through the list of workflow steps in the job logs section.
- Changes the workflow-details page to not automatically refresh the selected job when viewing the related logs, but keeping the user-selected one active.

Version 0.9.0 (2023-01-19)
--------------------------
Expand Down
25 changes: 17 additions & 8 deletions reana-ui/src/pages/workflowDetails/components/WorkflowLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,27 @@ EngineLogs.propTypes = {
};

function JobLogs({ logs }) {
const [selectedStep, setSelectedStep] = useState();

useEffect(() => {
function chooseLastStepID(logs) {
const failedStepId = findKey(logs, (log) => log.status === "failed");
if (failedStepId) return setSelectedStep(failedStepId);
if (failedStepId) return failedStepId;

const runningStepId = findKey(logs, (log) => log.status === "running");
if (runningStepId) return setSelectedStep(runningStepId);
if (runningStepId) return runningStepId;

// Return the last step id if there are no failed or running steps.
return Object.keys(logs).pop();
}

const logKeys = Object.keys(logs);
setSelectedStep(logKeys[logKeys.length - 1]);
}, [logs]);
const lastStepID = chooseLastStepID(logs);
const [selectedStep, setSelectedStep] = useState(lastStepID);

useEffect(() => {
// Only update the shown step logs if there was no log displayed before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely. Sometimes I'm seeing job logs but the job button status still says "created". Perhaps this could be improved as part of #354? (Anyway, for real physics analysis payloads, when jobs may be running for hours, this time difference shouldn't really appear in the Web UI.)

// and there is one ready to be displayed now
if (lastStepID && !selectedStep) {
setSelectedStep(lastStepID);
}
}, [logs, lastStepID, selectedStep]);

const steps = Object.entries(logs).map(([id, log]) => ({
key: id,
Expand Down
Loading