Skip to content

feat(ui) Add framework for template/module state and editing templates/modules to UI #14029

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

chriscollins3456
Copy link
Collaborator

@chriscollins3456 chriscollins3456 commented Jul 10, 2025

This PR introduces a comprehensive framework for managing customizable page templates and modules in the DataHub UI, enabling users to dynamically add and organize widgets on their home pages.

Key Features

🏗️ Template & Module Framework

  • Page Template Context: New React context managing both personal and global templates
  • Module Operations: Centralized system for adding existing modules and creating new ones
  • Dynamic Module Menu: Updated useAddModuleMenu hook with context-based module addition

🎯 Built-in Modules

  • Default Modules: "Your Assets" and "Domains" modules ready for immediate use
  • Admin Module Support: Framework for admin-created modules with proper fragment structure
  • Position Control: Add modules to specific row locations (left/right sides)

🧪 Testing & Quality

  • Comprehensive Tests: high coverage with proper context mocking
  • Type Safety: Full TypeScript support with PageModuleFragment and AddModuleHandlerInput types
  • Updated Test Suite: All existing tests updated to match new implementation

UI/UX Impact

Users can now customize their home page by adding relevant modules through a clean, organized dropdown menu. This establishes the foundation for a fully personalized DataHub experience.

Technical Notes

  • Context-based state management for template editing
  • Proper handling of module positioning and persistence
  • Framework ready for future Quick Link and Documentation modules

NOTE: the diff is deceptively high with at least 70% being tests here

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Jul 10, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Jul 10, 2025
Copy link

alwaysmeticulous bot commented Jul 10, 2025

🔴 Meticulous spotted visual differences in 18 of 1162 screens tested: view and approve differences detected.

Meticulous evaluated ~7 hours of user flows against your PR.

Last updated for commit cd0b4e5. This comment will update as new commits are pushed.

const personalTemplate = user?.settings?.homePage?.pageTemplate || null;
const globalTemplate = settings.globalHomePageSettings?.defaultTemplate || null;

if (!userLoaded || !globalSettingsLoaded) return null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we'll probably want to add some loading state here later

Comment on lines +73 to 81
const quickLink = {
title: 'Quick Link',
key: 'quick-link',
label: <MenuItem description="Choose links that are important" title="Quick Link" icon="LinkSimple" />,
onClick: () => {
// TODO: open up modal to add a quick link
},
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

decided to hardcode these here so we can have easy onClick handlers here instead of in a constants class. open to changing this up though

Comment on lines +30 to +50
} else {
// Add to existing row
const { rowIndex } = position;
if (rowIndex >= newRows.length) {
// Create new row if index is out of bounds
newRows.push({
modules: [module],
});
} else {
const row = { ...newRows[rowIndex] };
const newModules = [...(row.modules || [])];

if (position.rowSide === 'left') {
newModules.unshift(module);
} else {
newModules.push(module);
}

row.modules = newModules;
newRows[rowIndex] = row;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can update the logic in here for adding a 4th module to the next row.

once we add more logic it probably makes sense to break all this into a helper utility function with even more tests on it

Copy link

codecov bot commented Jul 10, 2025

Bundle Report

Changes will increase total bundle size by 3.82kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
datahub-react-web-esm 21.99MB 3.82kB (0.02%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: datahub-react-web-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 3.82kB 18.36MB 0.02%

Files in assets/index-*.js:

  • ./src/app/homeV3/template/components/AddModuleButton.tsx → Total Size: 1.98kB

  • ./src/app/homeV3/template/Template.tsx → Total Size: 1.05kB

  • ./src/app/homeV3/template/components/addModuleMenu/useAddModuleMenu.tsx → Total Size: 3.57kB

  • ./src/app/homeV3/modules/hooks/useModulesAvailableToAdd.ts → Total Size: 1.06kB

  • ./src/app/homeV3/templateRow/TemplateRow.tsx → Total Size: 635 bytes

  • ./src/app/homeV3/context/PageTemplateContext.tsx → Total Size: 1.54kB

  • ./src/app/homeV3/context/hooks/useModuleOperations.ts → Total Size: 2.54kB

  • ./src/app/homeV3/templateRow/utils.ts → Total Size: 474 bytes

  • ./src/app/homeV3/context/hooks/useTemplateOperations.ts → Total Size: 2.47kB

  • ./src/app/homeV3/modules/utils.ts → Total Size: 606 bytes

  • ./src/app/homeV3/context/hooks/useTemplateState.ts → Total Size: 909 bytes

  • ./src/app/homeV3/HomePageContent.tsx → Total Size: 856 bytes

Copy link

codecov bot commented Jul 10, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
3088 2 3086 41
View the full list of 3 ❄️ flaky tests
search cypress/e2e/search/searchFilters.js::cypress/e2e/search/searchFilters.js

Flake rate in main: 20.90% (Passed 53 times, Failed 14 times)

Stack Traces | 16.6s run time
2025-07-14T19:57:09.619Z
Timed out retrying after 10000ms: Expected to find element: `[data-testid=update-filters`, but never found it.
glossary cypress/e2e/glossaryV2/v2_glossary.js::cypress/e2e/glossaryV2/v2_glossary.js

Flake rate in main: 66.67% (Passed 8 times, Failed 16 times)

Stack Traces | 63.3s run time
2025-07-14T19:54:13.659Z
Timed out retrying after 10000ms: Expected to find content: 'CypressGlossaryTerm' but never did.
glossary sidebar navigation test cypress/e2e/glossaryV2/v2_glossary_navigation.js::cypress/e2e/glossaryV2/v2_glossary_navigation.js

Flake rate in main: 88.00% (Passed 3 times, Failed 22 times)

Stack Traces | 105s run time
2025-07-14T19:55:59.991Z
Timed out retrying after 10000ms: Expected to find content: 'CypressGlosssaryNavigationTerm' but never did.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

name,
type,
scope,
visibility: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that we don't have visibility attribute in UpsertPageModuleInput

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Jul 11, 2025
@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Jul 14, 2025
import { DataHubPageModuleType, EntityType, PageModuleScope } from '@types';

// Input types for the methods
export interface CreateModuleInput {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that we already have CreateModuleInput and AddModuleInput in context/types.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes i actually fix this in a followup PR that is currently blocked from being put up by a few things. i have such a weave of PRs right now, is it cool if I just handle these duplicate types in a followup once that PR comes into plat?

className?: string;
originRowIndex?: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's edge case but if we get more that 3 modules in a single row we will wrap them during the rendering and rowIndex can be increased because of it. So in this case we could add module in the wrong place. Maybe it's possible to preprocess PageTemplateFragment (global and personal) to get rows wrapped in the state before rendering instead of wrapping them during rendering. What do you think about?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm is it okay if we handle that in a separate ticket? this is such a monster PR and so many things depend on this getting in that I'd like to handle anything like edge cases in followups if possible

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-submitter-response Issue/request has been reviewed but requires a response from the submitter product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants