Skip to content

Conversation

walesch-yan
Copy link
Collaborator

This PR is a first (of probably many) PRs to try to clean up the different TaskItems components by doing two things essentially:

  • Introduce the TaskItemContainer: Every component had the exact same header rendering logic, so I created a single component to extract and centralise this code and make it easier to refacture/maintain. To make it easy to review, I did not make any changes to the code itself yet. (Will definitely in a later PR)
  • Remove dead code in TaskItems:
    This includes:
    • Now unused imports
    • deleteTask, headerOnClick and headerOnContextmethods which were moved toTaskItemContainer`
    • deleteButton, toggleChecked methods and internal state, which were present in every component but never used
    • logic related to showing 1D plots in the XRFTaskItem: it existed, but the Modal was never shown (always remained in falsy state) for now I removed it as part of a cleanup, but this could be added and/or fixed in a later PR

So while there are a lot changes in this PR, it is mainly one repetitive change in every file

Next steps are (not necessary in this order):

  • cleanup CSS
  • remove unused props
  • remove logic from global state that could be handled in component states (collapse Item for example)
  • remove unused actions related to this section
  • fix 1D plotting (if necessary)
  • refactor components

Comment on lines +70 to +77
if (
specialTaskCSS === 'Characterisation' &&
diffractionPlanLength === undefined
) {
taskCSS += ' warning';
break;
}
taskCSS += ' success';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So there is a special style for characterisations that is applied if the Task has been collected but no diffraction plan was chosen

Copy link
Member

Choose a reason for hiding this comment

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

Ok

Comment on lines -290 to -294
let taskCSS = this.props.selected
? 'task-head task-head-selected'
: 'task-head';

taskCSS += ' uncollected';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the css applied to characterisation items was slightly different from the others, due to the warning style that I explained in another comment. The uncollected class does also only exist in this component. However, this one only sets the background to the same color as task-head does, hence I removed it (it was unnecessary)

Comment on lines -86 to -98
getPlot(state) {
if (state === TASK_UNCOLLECTED) {
return <span />;
}

return (
<div className="float-end">
<a href="#" onClick={this.showXRFPlot}>
Plot available
</a>
</div>
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this component was supposed to render a link for the plot, but it is never rendered, hence I removed all logic related to 1d plots in XRFTaskItem

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it would be super nice if we could try to get those plots work again :).

import { Component } from 'react';
import { Collapse, ProgressBar } from 'react-bootstrap';

import {
Copy link
Member

Choose a reason for hiding this comment

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

Nice, :)

@marcus-oscarsson
Copy link
Member

I guess some of the CSS could be moved to a separate css file but I think this PR is good as it is. It could be done in a future PR.

@marcus-oscarsson marcus-oscarsson force-pushed the yw-add-TaskItemContainer branch from 27f956e to 7f50313 Compare July 8, 2025 13:02
@marcus-oscarsson marcus-oscarsson merged commit ad7f75c into develop Jul 8, 2025
16 checks passed
@marcus-oscarsson marcus-oscarsson deleted the yw-add-TaskItemContainer branch July 8, 2025 13:09
@walesch-yan
Copy link
Collaborator Author

I guess some of the CSS could be moved to a separate css file but I think this PR is good as it is. It could be done in a future PR.

Oh Yes definitely, that's why it was on my next steps task list;) Just wanted to keep this PR as simple as possible:)

Copy link
Collaborator

@axelboc axelboc left a comment

Choose a reason for hiding this comment

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

image

Wow, that was a lot of duplicated code! 😮

Nice clean-up here and in other PRs generally like #1790. Always satisfying. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants