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

✨ adding filter& sort by analysis to Application-inventory table #2100

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

HadasahR
Copy link

@HadasahR HadasahR commented Sep 18, 2024

adding the ability to sort and filter by analysis status in the application inventory table.
before the change:

Screenshot from 2024-10-13 12-01-44
after the change :
Screenshot from 2024-10-13 12-05-47
UI test PR: konveyor/tackle-ui-tests#1238
this PR is using functions added in #2152

@mguetta1 mguetta1 marked this pull request as draft September 18, 2024 17:15
@HadasahR HadasahR changed the title adding filter by analysis to Application inventory table ✨adding filter by analysis to Application inventory table Sep 19, 2024
@HadasahR HadasahR changed the title ✨adding filter by analysis to Application inventory table ✨adding filter by analysis to Application-inventory table Sep 19, 2024
@HadasahR HadasahR changed the title ✨adding filter by analysis to Application-inventory table ✨ adding filter by analysis to Application-inventory table Sep 19, 2024
@HadasahR HadasahR closed this Sep 22, 2024
@HadasahR HadasahR reopened this Sep 22, 2024
@HadasahR HadasahR force-pushed the hadassah_application-inventoy-table-add-filtering-by-analysis branch from 0fa725a to c142659 Compare September 22, 2024 10:13
@HadasahR HadasahR marked this pull request as ready for review September 22, 2024 10:29
@HadasahR HadasahR changed the title ✨ adding filter by analysis to Application-inventory table ✨ adding filter& sort by analysis to Application-inventory table Sep 24, 2024
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.98%. Comparing base (b654645) to head (fc87877).
Report is 246 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2100      +/-   ##
==========================================
+ Coverage   39.20%   41.98%   +2.78%     
==========================================
  Files         146      175      +29     
  Lines        4857     5630     +773     
  Branches     1164     1415     +251     
==========================================
+ Hits         1904     2364     +460     
- Misses       2939     3145     +206     
- Partials       14      121     +107     
Flag Coverage Δ
client 41.98% <ø> (+2.78%) ⬆️
server ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mguetta1 mguetta1 marked this pull request as draft September 26, 2024 19:08
@mguetta1 mguetta1 marked this pull request as ready for review September 26, 2024 20:04
Copy link
Collaborator

@rszwajko rszwajko left a comment

Choose a reason for hiding this comment

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

The code for new functionality is added in the correct places but there are some problems with mapping state values. Unfortunately adding code to legacy class of this size is never easy :)

General comments:

  1. wording: the PR title is OK (you could start with a capital letter though), the description is repeating the title so you could skip it. However leave a link to the issue/bug you are fixing i.e. Resolves: [BUG] Need to be able to filter & sort by application analysis status #1745 . In git history you will find some examples
  2. check out your IDE configuration - it seems the IDE is not auto-formatting on save action. We have a script for linting - run from command line (in the project root) npm run lint . You will see the list of all violations (we somehow accumulated few of them). Then you can fix (only) yours. General cleanup is a candidate for another PR (npm run lint -- --fix will auto-fix all easy formatting problems in the whole project)

@HadasahR
Copy link
Author

HadasahR commented Sep 26, 2024 via email

@HadasahR HadasahR force-pushed the hadassah_application-inventoy-table-add-filtering-by-analysis branch from 185573c to 614c152 Compare October 13, 2024 07:59
@HadasahR HadasahR force-pushed the hadassah_application-inventoy-table-add-filtering-by-analysis branch from 614c152 to 9d163db Compare October 13, 2024 09:11
Copy link
Collaborator

@rszwajko rszwajko left a comment

Choose a reason for hiding this comment

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

The PR is going the right direction but it needs a preliminary refactoring - extracting presets creation to a re-usable function . I recommend to create a small PR for that and then re-use this functionality in this PR. Ping me if you need help with that.

what: t("terms.analysis").toLowerCase(),
}) + "...",

selectOptions: Object.values(applications)
Copy link
Collaborator

Choose a reason for hiding this comment

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

applications is already an array - no need to use Object.values

}) + "...",

selectOptions: Object.values(applications)
.map((a) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to re-use the same mapper for sorting so let's create a named function for that.
The steps remain the same i.e. (pseudo-code)

const mapAnalysisStateToLabel = (value: TaskState) => {
   // for consistency let's use the same wa of converting as the rest of the code
   const presetKey: IconedStatusPreset = getTaskStatus(value);
  // as for now the presets are created inside the  IconedStatus
  // we need refactor this code and extract this functionality to a function i.e.buildPresets() 
  // this is best to do under a different PR 
   const presets = buildPresets(t);
   // IMHO fallback to "Unknown" makes most sense
   const label = presets[presetKey]?.label ?? t("terms.unknown");
   return label;
}

Links:
getTaskStatus(value)

Copy link

@TalyaNaima TalyaNaima Nov 3, 2024

Choose a reason for hiding this comment

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

the functions mentioned here are pushed in #2152

return { value, label };
})
.filter((v, i, a) => a.findIndex((v2) => v2.label === v.label) === i)
.sort((a, b) => a.value.localeCompare(b.value)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should sort on label - note also that universalComparator helper adds some extra power to localeCompare ("natural sorting")

@@ -345,6 +348,7 @@ export const ApplicationsTable: React.FC = () => {
businessService: app.businessService?.name || "",
tags: app.tags?.length || 0,
effort: app.effort || 0,
analysis: app.tasks.currentAnalyzer?.state || "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should sort on labels visible on the screen - see the propsed mapAnalysisStateToLabel below

rszwajko pushed a commit to rszwajko/tackle2-ui that referenced this pull request Nov 6, 2024
mguetta1 pushed a commit to HadasahR/tackle2-ui that referenced this pull request Nov 18, 2024
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