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

refactor: update process widget code #729

Merged
merged 7 commits into from
May 16, 2022

Conversation

ClementTsang
Copy link
Owner

Description

A description of the change and what it does. If relevant (such as any change that modifies the UI), please provide screenshots of the change:

Refactors how the process widget to work with the (maybe better) consolidated tables code, as well as refactoring a bunch of old logic.

Testing

If relevant, please state how this was tested. All changes must be tested to work:

Please also indicate which platforms were tested. All platforms directly affected by the change must be tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts

@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 385f205 to 0e41747 Compare May 15, 2022 08:42
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2022

Codecov Report

Merging #729 (cc6d7b8) into consolidate_tables (69ec526) will increase coverage by 2.95%.
The diff coverage is 29.51%.

@@                  Coverage Diff                   @@
##           consolidate_tables     #729      +/-   ##
======================================================
+ Coverage               21.23%   24.18%   +2.95%     
======================================================
  Files                      54       56       +2     
  Lines                   13606    12918     -688     
======================================================
+ Hits                     2889     3124     +235     
+ Misses                  10717     9794     -923     
Impacted Files Coverage Δ
src/app.rs 0.04% <0.00%> (+<0.01%) ⬆️
src/app/data_harvester.rs 0.00% <0.00%> (ø)
src/app/data_harvester/network/heim.rs 0.00% <ø> (ø)
src/app/data_harvester/processes/linux.rs 19.83% <0.00%> (-0.68%) ⬇️
src/app/data_harvester/processes/mod.rs 0.00% <0.00%> (-83.34%) ⬇️
src/app/data_harvester/processes/unix.rs 6.66% <ø> (ø)
src/app/query.rs 0.00% <0.00%> (ø)
src/canvas/components/time_graph.rs 69.03% <0.00%> (ø)
src/canvas/dialogs/dd_dialog.rs 0.00% <0.00%> (ø)
src/canvas/widgets/battery_display.rs 0.00% <0.00%> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69ec526...cc6d7b8. Read the comment docs.

@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from eecf396 to 129eb97 Compare May 15, 2022 09:09
@ClementTsang ClementTsang mentioned this pull request May 15, 2022
15 tasks
@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch 5 times, most recently from 79cec5d to c1d3b4e Compare May 15, 2022 22:31
src/utils/gen_util.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +32 to +38
if app_state
.proc_state
.widget_states
.get(&app_state.current_widget.widget_id)
.map(|p| matches!(p.mode, ProcWidgetMode::Grouped))
.unwrap_or(false)
{
Copy link
Owner Author

Choose a reason for hiding this comment

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

Another example of how its a bit annoying how its currently done with a mapping, where it needs an unwrap in the case it "fails". Ideally bind this to the PWS.

@ClementTsang ClementTsang marked this pull request as ready for review May 15, 2022 23:01
@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 0fcab5a to 9c5efc5 Compare May 15, 2022 23:03
Comment on lines +97 to +102
// TODO: [Refactor] This is an ugly hack to add the disabled style...
// this could be solved by storing style locally to the widget.
for row in &mut proc_widget_state.table_data.data {
if let TableRow::Styled(_, style) = row {
*style = style.patch(self.colours.disabled_text_style);
Copy link
Owner Author

Choose a reason for hiding this comment

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

Not a fan of this but its fine for now...

@@ -24,7 +30,7 @@ pub struct TextTableTitle<'a> {

pub struct TextTable<'a> {
pub table_gap: u16,
pub is_force_redraw: bool,
pub is_force_redraw: bool, // TODO: Is this force redraw thing needed? Or is there a better way?
Copy link
Owner Author

Choose a reason for hiding this comment

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

Not a fan of this bit. Fix in the future!

@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 9c5efc5 to b0686ea Compare May 15, 2022 23:25
Comment on lines +77 to +96
const CPU_PERCENT: CellContent = CellContent::Simple(Cow::Borrowed("CPU%"));
const MEM_PERCENT: CellContent = CellContent::Simple(Cow::Borrowed("Mem%"));
const MEM: CellContent = CellContent::Simple(Cow::Borrowed("Mem"));
const READS_PER_SECOND: CellContent = CellContent::Simple(Cow::Borrowed("R/s"));
const WRITES_PER_SECOND: CellContent = CellContent::Simple(Cow::Borrowed("W/s"));
const TOTAL_READ: CellContent = CellContent::Simple(Cow::Borrowed("T.Read"));
const TOTAL_WRITE: CellContent = CellContent::Simple(Cow::Borrowed("T.Write"));
const STATE: CellContent = CellContent::Simple(Cow::Borrowed("State"));
const PROCESS_NAME: CellContent = CellContent::Simple(Cow::Borrowed("Name"));
const COMMAND: CellContent = CellContent::Simple(Cow::Borrowed("Command"));
const PID: CellContent = CellContent::Simple(Cow::Borrowed("PID"));
const COUNT: CellContent = CellContent::Simple(Cow::Borrowed("Count"));
const USER: CellContent = CellContent::Simple(Cow::Borrowed("User"));

const SHORTCUT_CPU_PERCENT: CellContent = CellContent::Simple(Cow::Borrowed("CPU%(c)"));
const SHORTCUT_MEM_PERCENT: CellContent = CellContent::Simple(Cow::Borrowed("Mem%(m)"));
const SHORTCUT_MEM: CellContent = CellContent::Simple(Cow::Borrowed("Mem(m)"));
const SHORTCUT_PROCESS_NAME: CellContent = CellContent::Simple(Cow::Borrowed("Name(n)"));
const SHORTCUT_COMMAND: CellContent = CellContent::Simple(Cow::Borrowed("Command(n)"));
const SHORTCUT_PID: CellContent = CellContent::Simple(Cow::Borrowed("PID(p)"));
Copy link
Owner Author

Choose a reason for hiding this comment

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

Kinda gross. Feel like there's a better way to do this...

Comment on lines +811 to +814
if is_disabled {
TableRow::Styled(contents, tui::style::Style::default())
} else {
TableRow::Raw(contents)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Part of the ugly hack for disabled entries.

@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from b0686ea to 580d02a Compare May 15, 2022 23:31
@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 580d02a to 98e88f9 Compare May 15, 2022 23:34
@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 98e88f9 to 2646887 Compare May 15, 2022 23:43
@ClementTsang ClementTsang force-pushed the refactor_process_widget_into_tables branch from 2646887 to 0831a56 Compare May 16, 2022 01:02
Bugs squashed:
- Incorrect column sizing for flex cases
- Case where the sort menu bounds were still existing despite being
  hidden
- Proc widget not actually taking into account the calculated row widths
  in some cases during data conversion.
@ClementTsang ClementTsang merged commit b65a910 into consolidate_tables May 16, 2022
@ClementTsang ClementTsang deleted the refactor_process_widget_into_tables branch May 16, 2022 18:53
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.

None yet

2 participants