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: consolidate tables #730

Merged
merged 17 commits into from
May 17, 2022
Merged

refactor: consolidate tables #730

merged 17 commits into from
May 17, 2022

Conversation

ClementTsang
Copy link
Owner

@ClementTsang ClementTsang commented May 15, 2022

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 the table drawing code, similar to #710.


This serves as somewhat of an intermediary refactor to unify some scrollable table code - in particular, in regards to drawing. This is almost a parallel refactor as #710, which did something similar for time graphs. However, this one has a bit more work in regards to the concepts of component state, in particular, for width calculation caching and scroll position management.

The short term goals of this PR is to cut down on duplicate code across the codebase for doing essentially the same thing. This makes it easier to change all the scrollable tables at once, as opposed to having to duplicate work across each widget each time I need to address an issue, or add a feature. It is also far easier to test a single implementation than multiple.

This also serves as a good way to give some 2+ year old code some polish and eyeball time, and it should also make it much easier to implement sorting across all scrollable widgets that would need it, something I've wanted to do for a long time and has been in the backlog for years now.


Both of these consolidation PRs can also be seen as initial work done for #374 and #571, both of which were originally tackled in #265, #488, and #571, though at a bit of a smaller scale for each PR. As such, these changes are kinda "temporary", in the sense that they are changes for now that may be changed again in the near future as I figure out and refactor other core bits of code. However, if I tried to fit even bigger changes in, the PRs would become a bit too massive IMO to work with.

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

Disk and temp tables now share the same drawing logic, as well as
consolidating the "text table" states into one single state, as opposed
to two separate states (one for scroll and one for width calculations).

BTW I know this is kinda an ugly design - creating a giant struct to
call a function - hopefully that's temporary, I want to do a bigger
refactor to consolidate more stuff together and therefore avoid this
problem, but baby steps, right?
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2022

Codecov Report

Merging #730 (3032730) into master (45680da) will increase coverage by 3.42%.
The diff coverage is 27.49%.

❗ Current head 3032730 differs from pull request most recent head 01574c8. Consider uploading reports for the commit 01574c8 to get more accurate results

@@            Coverage Diff             @@
##           master     #730      +/-   ##
==========================================
+ Coverage   20.78%   24.20%   +3.42%     
==========================================
  Files          53       56       +3     
  Lines       13620    12922     -698     
==========================================
+ Hits         2831     3128     +297     
+ Misses      10789     9794     -995     
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%> (+0.44%) ⬆️
src/canvas/dialogs/dd_dialog.rs 0.00% <0.00%> (ø)
src/canvas/widgets/battery_display.rs 0.00% <0.00%> (ø)
... and 35 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 45680da...01574c8. Read the comment docs.

ClementTsang and others added 9 commits May 15, 2022 21:02
A bunch of work towards also refactoring how the process widget
gathers and converts data.
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.
…o_tables

Refactors how the process widget to work with the (maybe better) consolidated tables code, as well as refactoring a bunch of old logic.
@ClementTsang ClementTsang marked this pull request as ready for review May 16, 2022 19:19
@ClementTsang ClementTsang merged commit de765fc into master May 17, 2022
@ClementTsang ClementTsang deleted the consolidate_tables branch May 17, 2022 01:03
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