E530 refactor: create a dynamic empty content component by abdimo101 · Pull Request #1985 · SciCatProject/frontend · GitHub
[go: up one dir, main page]

Skip to content

refactor: create a dynamic empty content component#1985

Merged
abdimo101 merged 9 commits intomasterfrom
empty-content-handling
Sep 16, 2025
Merged

refactor: create a dynamic empty content component#1985
abdimo101 merged 9 commits intomasterfrom
empty-content-handling

Conversation

@abdimo101
Copy link
Member
@abdimo101 abdimo101 commented Aug 29, 2025

Description

This PR introduces a reusable EmptyContentComponent to make visual feedback consistent when no data is available with dynamic messages and icons.

Motivation

Background on use case, changes needed

Fixes:

Please provide a list of the fixes implemented in this PR

Changes:

Please provide a list of the changes implemented by this PR

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Introduce a reusable EmptyContentComponent for consistent empty-state UI and replace all inline no-data placeholders across tables and dashboards with this new component.

New Features:

  • Add EmptyContentComponent with customizable message, icon, reload, and action buttons

Enhancements:

  • Extend DynamicMatTableComponent to support emptyMessage and emptyIcon inputs and improve its change detection timing
  • Replace existing hardcoded no-data markup in dynamic tables, logbooks, proposals, datasets, files, and instruments dashboards with EmptyContentComponent

Build:

  • Import EmptyContentModule in shared and DynamicMatTable modules

Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The manual setTimeout + cdr.detectChanges in DynamicMatTableComponent feels like a workaround—consider using a more robust lifecycle hook or OnPush change detection strategy instead of an arbitrary delay.
  • EmptyContentComponent currently only accepts static strings for messages and icons; consider supporting translation keys or integrating with your i18n/TranslatePipe so the content can be localized.
  • If you need richer empty states in the future, think about adding content projection or a custom template input to EmptyContentComponent so consumers can inject complex markup beyond a simple icon and text.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The manual setTimeout + cdr.detectChanges in DynamicMatTableComponent feels like a workaround—consider using a more robust lifecycle hook or OnPush change detection strategy instead of an arbitrary delay.
- EmptyContentComponent currently only accepts static strings for messages and icons; consider supporting translation keys or integrating with your i18n/TranslatePipe so the content can be localized.
- If you need richer empty states in the future, think about adding content projection or a custom template input to EmptyContentComponent so consumers can inject complex markup beyond a simple icon and text.

## Individual Comments

### Comment 1
<location> `src/app/shared/modules/dynamic-material-table/table/dynamic-mat-table.component.ts:463` </location>
<code_context>
       this.init = true;
-    }, 1000);
+      this.cdr.detectChanges();
+    }, 10);

     if (this.dataSource) {
</code_context>

<issue_to_address>
Consider reducing the setTimeout delay further or refactoring to avoid arbitrary timeouts for initialization.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

this.init = true;
}, 1000);
this.cdr.detectChanges();
}, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider reducing the setTimeout delay further or refactoring to avoid arbitrary timeouts for initialization.

@abdimo101 abdimo101 requested a review from Junjiequan August 29, 2025 13:05
@abdimo101 abdimo101 changed the title refactor: create a customizable empty content component refactor: create a dynamic empty content component Sep 1, 2025
Comment on lines +91 to +95
<app-empty-content
message="No logbook available."
icon="book"
>
</app-empty-content>
Copy link
Member

Choose a reason for hiding this comment

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

This indentation looks not right here?

Comment on lines +93 to +97
<app-empty-content
message="No logbook available."
icon="book"
>
</app-empty-content>
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@abdimo101 abdimo101 merged commit 45fe3e9 into master Sep 16, 2025
9 checks passed
@abdimo101 abdimo101 deleted the empty-content-handling branch September 16, 2025 08:27
Junjiequan added a commit that referenced this pull request Sep 19, 2025
This PR introduces a reusable `EmptyContentComponent` to make visual
feedback consistent when no data is available with dynamic messages and
icons.

Background on use case, changes needed

Please provide a list of the fixes implemented in this PR

* https://jira.ess.eu/browse/SWAP-3168

Please provide a list of the changes implemented by this PR

* changes made

- [ ] Included for each change/fix?
- [ ] Passing? (Merge will not be approved unless this is checked)

- [ ] swagger documentation updated \[required\]
- [ ] official documentation updated \[nice-to-have\]

If you have updated the official documentation, please provide PR # and
URL of the pages where the updates are included

- [ ] Does it require a specific version of the backend
- which version of the backend is required:

Introduce a reusable EmptyContentComponent for consistent empty-state UI
and replace all inline no-data placeholders across tables and dashboards
with this new component.

New Features:
- Add EmptyContentComponent with customizable message, icon, reload, and
action buttons

Enhancements:
- Extend DynamicMatTableComponent to support emptyMessage and emptyIcon
inputs and improve its change detection timing
- Replace existing hardcoded no-data markup in dynamic tables, logbooks,
proposals, datasets, files, and instruments dashboards with
EmptyContentComponent

Build:
- Import EmptyContentModule in shared and DynamicMatTable modules

---------

Co-authored-by: Jay <b331998513@gmail.com>
Junjiequan added a commit that referenced this pull request Sep 19, 2025
This PR introduces a reusable `EmptyContentComponent` to make visual
feedback consistent when no data is available with dynamic messages and
icons.

Background on use case, changes needed

Please provide a list of the fixes implemented in this PR

* https://jira.ess.eu/browse/SWAP-3168

Please provide a list of the changes implemented by this PR

* changes made

- [ ] Included for each change/fix?
- [ ] Passing? (Merge will not be approved unless this is checked)

- [ ] swagger documentation updated \[required\]
- [ ] official documentation updated \[nice-to-have\]

If you have updated the official documentation, please provide PR # and
URL of the pages where the updates are included

- [ ] Does it require a specific version of the backend
- which version of the backend is required:

Introduce a reusable EmptyContentComponent for consistent empty-state UI
and replace all inline no-data placeholders across tables and dashboards
with this new component.

New Features:
- Add EmptyContentComponent with customizable message, icon, reload, and
action buttons

Enhancements:
- Extend DynamicMatTableComponent to support emptyMessage and emptyIcon
inputs and improve its change detection timing
- Replace existing hardcoded no-data markup in dynamic tables, logbooks,
proposals, datasets, files, and instruments dashboards with
EmptyContentComponent

Build:
- Import EmptyContentModule in shared and DynamicMatTable modules

---------

Co-authored-by: Jay <b331998513@gmail.com>
Junjiequan added a commit that referenced this pull request Sep 19, 2025
This PR introduces a reusable `EmptyContentComponent` to make visual
feedback consistent when no data is available with dynamic messages and
icons.

Background on use case, changes needed

Please provide a list of the fixes implemented in this PR

* https://jira.ess.eu/browse/SWAP-3168

Please provide a list of the changes implemented by this PR

* changes made

- [ ] Included for each change/fix?
- [ ] Passing? (Merge will not be approved unless this is checked)

- [ ] swagger documentation updated \[required\]
- [ ] official documentation updated \[nice-to-have\]

If you have updated the official documentation, please provide PR # and
URL of the pages where the updates are included

- [ ] Does it require a specific version of the backend
- which version of the backend is required:

Introduce a reusable EmptyContentComponent for consistent empty-state UI
and replace all inline no-data placeholders across tables and dashboards
with this new component.

New Features:
- Add EmptyContentComponent with customizable message, icon, reload, and
action buttons

Enhancements:
- Extend DynamicMatTableComponent to support emptyMessage and emptyIcon
inputs and improve its change detection timing
- Replace existing hardcoded no-data markup in dynamic tables, logbooks,
proposals, datasets, files, and instruments dashboards with
EmptyContentComponent

Build:
- Import EmptyContentModule in shared and DynamicMatTable modules

---------

Co-authored-by: Jay <b331998513@gmail.com>
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.

2 participants

0