[go: up one dir, main page]

Skip to content

Replace isEmpty from lodash with null check

What does this MR do and why?

Replaces lodash isEmpty with a simpler !== null check.

Why: We either expect activeItem to be an object of the type AiCatalogItem or null. isEmpty from lodash also checks for empty strings, empty arrays, even boolean values. IMO it makes the code less readable because when now reading the code, especially without TypeScript, I do not know anymore whether we check for null, no array items, or else.

I went a step further and moved the check directly into the template. We want to keep the logic in the <template> blocks as minimal as possible. However, IMO activeItem !== null is short and primitive. The computed property was only used once and it had no benefit to move this logic into a computed prop, to use it multiple times.

Screenshots or screen recordings

No visual changes

How to set up and validate locally

  1. Enable the feature flag: echo "Feature.enable(:global_ai_catalog)" | rails c
  2. If needed, add some seed data: echo "FactoryBot.create_list(:ai_catalog_agent, 10, project_id: 1000000)" | rails c
  3. If needed, add some seed data: echo "FactoryBot.create_list(:ai_catalog_flow, 10, project_id: 1000000)" | rails c
  4. Visit http://gdk.test:3000/explore/ai-catalog/agents
  5. Open a drawer by clicking on an item
  6. Visit http://gdk.test:3000/explore/ai-catalog/flows
  7. Open a drawer by clicking on an item

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading