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

feat(adoption-insights): add frontend plugin for adoption insights #464

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

Conversation

Eswaraiahsapram
Copy link
Contributor

@Eswaraiahsapram Eswaraiahsapram commented Mar 4, 2025

Hey, I just made a Pull Request!

Fixes - RHDHPAI-571

This PR introduces frontend changes for the new Adoption Insights plugin, enhancing the experience by providing key insights into adoption metrics.

Changes Implemented

✅ Added UI components to display Adoption Insights metrics.
✅ Integrated data visualization using Recharts to present trends effectively.
✅ Integrated date range using MUI x-date-pickers
✅ Added Unit tests
✅ Implemented pagination.

Screen recording

Screen.Recording.2025-03-11.at.2.45.59.PM.mov

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Mar 4, 2025

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/adoption-insights/packages/app none v0.0.0
backend workspaces/adoption-insights/packages/backend none v0.0.0
@red-hat-developer-hub/backstage-plugin-adoption-insights workspaces/adoption-insights/plugins/adoption-insights none v0.0.1

@ShiranHi
Copy link

@Eswaraiahsapram it looks amazing!

I have a few questions:

  1. Can we change the title from "Active Users" to "Active users"?
  2. Can we add the "Export CSV" button to the "Active users" card?
  3. Can we display a double dash (--) when there is no data in a cell? I noticed this is already implemented in the "Top catalog entities" card.
  4. Can we add a clickable link to catalog entity and template names so that users are directed to the corresponding page when they click on them?
  5. In the header dropdown labeled "All time", can we rename it to "Date range" instead of "Date Range"?
  6. Regarding the "Date range" dropdown with the calendar view:
    A. Can we reduce the title size to match the design?
    B. Can we make the "Start date" field pre-selected?
    C. Can we include the date format (e.g., mm/dd/yyyy) as a placeholder in the field?
    D. Can we align the date picker width to match the text fields?

@Eswaraiahsapram
Copy link
Contributor Author

Eswaraiahsapram commented Mar 11, 2025

@Eswaraiahsapram it looks amazing!

I have a few questions:

  1. Can we change the title from "Active Users" to "Active users"?
  2. Can we add the "Export CSV" button to the "Active users" card?
  3. Can we display a double dash (--) when there is no data in a cell? I noticed this is already implemented in the "Top catalog entities" card.
  4. Can we add a clickable link to catalog entity and template names so that users are directed to the corresponding page when they click on them?
  5. In the header dropdown labeled "All time", can we rename it to "Date range" instead of "Date Range"?
  6. Regarding the "Date range" dropdown with the calendar view:
    A. Can we reduce the title size to match the design?
    B. Can we make the "Start date" field pre-selected?
    C. Can we include the date format (e.g., mm/dd/yyyy) as a placeholder in the field?
    D. Can we align the date picker width to match the text fields?

@ShiranHi thanks for the feedback!

I forgot to update the screenshots earlier. I'm adding a new screen recording now. Please let me know if anything needs to update.

Regarding aligning the date picker width with the text fields, there are some limitations with the StaticDatePicker in MUI. However, I’ll explore possible adjustments to improve the alignment.

@ShiranHi
Copy link

Thanks for the video! I can now see more cards. I have a few follow-up questions:

  1. "Top 3 templates" card: Can we reduce the padding between the columns so they are closer together?
  2. "Active users" tooltip: Can we adjust the layout to match the design?
  3. "Top 3 techdocs" card: The content in the Entity column should be clickable as well.
  4. "X searches" card: The tooltip needs some adjustments to align with the design.
  5. For the empty state, instead of "No data available" can we change it to "No results for this time range."?

isYesterday,
} from 'date-fns';

export const getDateRange = (value: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel we might be able put some of these into the common plugin once we have it.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Member

@karthikjeeyar karthikjeeyar left a comment

Choose a reason for hiding this comment

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

@Eswaraiahsapram This looks great 🎉, I have added few comments, PTAL.

FYI, Sonarcloud issues has to be fixed too.

Comment on lines +122 to +128
href={entityLink({
kind: parseEntityRef(techdoc.entityRef)?.kind,
namespace:
parseEntityRef(techdoc.entityRef)?.namespace ??
'default',
name: parseEntityRef(techdoc.entityRef)?.name,
})}
Copy link
Member

Choose a reason for hiding this comment

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

index-page link takes you to non-existent page, for this index-page we should redirect to the home page of the docs plugin - /docs?filters%5Buser%5D=all&limit=20

image

Comment on lines +144 to +149
href={entityLink({
kind: parseEntityRef(techdoc.entityRef)?.kind,
namespace:
parseEntityRef(techdoc.entityRef)?.namespace ??
'default',
name: parseEntityRef(techdoc.entityRef)?.name,
Copy link
Member

Choose a reason for hiding this comment

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

Refer my previous comment. since both of them using same logic extract it to a variable or function.

Comment on lines +70 to +79
<CardWrapper title="Top techdocs">
<Box
display="flex"
justifyContent="center"
alignItems="center"
height={200}
>
<Typography>No results for this time range.</Typography>
</Box>
</CardWrapper>
Copy link
Member

Choose a reason for hiding this comment

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

Extract this into a component called EmptyChartState and reuse it in all the charts to avoid code duplication.

alignItems="center"
height={200}
>
<Typography>No results for this time range.</Typography>
Copy link
Member

Choose a reason for hiding this comment

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

Should this be date range?

Suggested change
<Typography>No results for this time range.</Typography>
<Typography>No results for this date range.</Typography>

<TableCell sx={{ width: '20%' }}>
<Link
component="a"
href={`/${plugin.plugin_id}`}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have a dedicated page for plugin, so this just take the user to a non-existent page. It is better to remove link and leave it as text.

</div>
<Typography
variant="body2"
style={{ color: theme.palette.text.primary, fontSize: '14px' }}
Copy link
Member

Choose a reason for hiding this comment

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

please avoid px and use relative units (rem for fontsize) so it can scale up/down but px cant.

Suggested change
style={{ color: theme.palette.text.primary, fontSize: '14px' }}
style={{ color: theme.palette.text.primary, fontSize: '0.875rem' }}

<Box mr={3}>
<Typography
sx={{
fontSize: '14px',
Copy link
Member

Choose a reason for hiding this comment

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

refer to my previous comment about using rem.

<Button
variant="text"
startIcon={<FileDownloadOutlinedIcon />}
onClick={handleCSVDownload}
Copy link
Member

Choose a reason for hiding this comment

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

debounce this CSVDownload method, some users may double click the button and currently it calls the API and downloads it multiple times.

handleDateRangeClick(event);
}}
>
Date range...
Copy link
Member

Choose a reason for hiding this comment

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

In figma design it reads Select from calendar...

boxShadow: 4,
borderRadius: 2,
border: theme => `1px solid ${theme.palette.grey[300]}`,
backgroundColor: 'white',
Copy link
Member

Choose a reason for hiding this comment

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

This adds white color background in dark mode as well, so let us not set background color explicitly.

Suggested change
backgroundColor: 'white',

) : (
visibleTemplates?.map(template => (
<TableRow
key={template.entityRef}
Copy link
Member

@karthikjeeyar karthikjeeyar Mar 13, 2025

Choose a reason for hiding this comment

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

I have changed this to lowercase in the response in this commit , Please rebase with main and align with that changes.

Suggested change
key={template.entityRef}
key={template.entityref}

Copy link
Member

Choose a reason for hiding this comment

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

The changes applies to Techdocs.tsx as well

Comment on lines +120 to +122
kind: parseEntityRef(template.entityRef).kind,
namespace: 'default',
name: parseEntityRef(template.entityRef)?.name,
Copy link
Member

Choose a reason for hiding this comment

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

nit:
parseEntityRef method is used multiple places in this file and in Techdocs.tsx, can you move it to a local variable in the top of files, so you can refer that variable to get kind and name information?.

},
}}
>
{parseEntityRef(template.entityRef).name}
Copy link
Member

Choose a reason for hiding this comment

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

parseEntityRef function can throw error and crash the UI if the entityRef is a empty object {} or null, so it better to add safety checks before calling this function.

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.

4 participants