Skip to content

Dyn 9702 template files support#89

Open
Chloepeg wants to merge 13 commits into
DynamoDS:masterfrom
Chloepeg:DYN-9702-template-files-support
Open

Dyn 9702 template files support#89
Chloepeg wants to merge 13 commits into
DynamoDS:masterfrom
Chloepeg:DYN-9702-template-files-support

Conversation

@Chloepeg

@Chloepeg Chloepeg commented May 13, 2026

Copy link
Copy Markdown
Contributor

Purpose

This PR addresses DYN-9702 https://jira.autodesk.com/browse/DYN-9702 The changes in the code aim to add Templates support to the Dynamo Home UI, allowing users to view and open template files directly from the Home page.

This PR works with : DynamoDS/Dynamo#17107

DYN-9702-Gif

Changes :

  • Added a DynamoHome callback for receiving template metadata from the Dynamo host.
  • Added the Home UI data flow for Templates, including a Templates context and rendering support in the Home page.
  • Added a Templates section with grid/list view support and persisted view mode settings.
  • Added a Templates info tooltip on the heading question mark icon.
  • Added local development mock data for Templates while production builds wait for template data from Dynamo.

Declarations

Check these if you believe they are true

Release Notes

Added template file support to Dynamo Home. The Home page now shows a Templates section with grid and list views. Added a Templates info tooltip

Reviewers

@zeusongit
@DynamoDS/eidos

FYIs

@dnenov
@johnpierson
@jnealb

Chloepeg added 12 commits March 3, 2026 12:50
- Enhance CustomDropdown component to support divider and header option types
- Add template options to Sidebar "New" dropdown with visual grouping
- Add template data structure in home.ts assets
- Update dropdown styling for divider and header elements
- Add TypeScript types for dropdown option kinds (item/divider/header)
- Update package dependencies
- Add Templates section above Recent section on home page
- Implement templates data loading from home.ts (dev) and backend (prod)
- Add independent grid/list view toggle for Templates section
- Add templatesPageViewMode setting for view preference persistence
- Map template data structure (date -> DateModified) for component compatibility
- Add receiveTemplatesDataFromDotNet window function for backend integration
- Add "Templates" translation key to locale files
- Reuse existing GraphGridItem and GraphTable components for templates display
…down

- Add newWorkspaceWithTemplate utility function
- Implement listener pattern for template data sharing between Sidebar and PageRecent
- Map hardcoded dropdown options to real template files from backend
- Update TypeScript types for listener pattern
- Add TemplatesContext to manage template state centrally
- Update Sidebar and PageRecent to use useTemplates() hook
- Remove duplicate global handlers to prevent race conditions
- Aligns with existing React patterns
Update template matching logic to use new filenames:
- Template 1: matches 'Create a Graph.dyn' (was Template_00_)
- Template 2: matches 'Import & Export Workflow.dyn' (was Template_01_)
Drop down menu on side panel removed, will be added back later

- Remove Template 1 and Template 2 options from Sidebar dropdown
- Remove newWorkspaceWithTemplate function from utility.ts
- Remove divider/header support from CustomDropdown component
- Remove template data from home.ts assets
- Update type definitions to remove template-related types
TemplatesContext requires templates export in development mode
Fix module path in TemplatesContext.tsx and restore package-lock.json metadata.
Display Recent files section above Templates section on the home page.

Visual reordering only, there is no functional changes to either section
Add info icon with tooltip to the Templates section title that appears when
hovering over the Template heading

Changes:
- Add tooltip component to Templates title in PageRecent.tsx
- Add tooltip text to locale file (en.json)
- Extend Tooltip component to support right-side positioning with arrow
- Update tooltip styling for wider layout to fit space inbetween
- Position tooltip to the right of the title with left-pointing arrow
- Add QuestionMarkIcon import to PageRecent component
- Tooltip now appears when hover over the icon instead of the header
- Text updated
@Chloepeg Chloepeg marked this pull request as ready for review May 20, 2026 15:01
Comment thread src/components/TemplatesContext.tsx Outdated
const TemplatesContext = createContext<any[]>([]);

// Provider component that wraps the app components
export const TemplatesProvider = ({ children }) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug 5 — Untyped prop] children is untyped. Should be { children: React.ReactNode }.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TemplatesProvider has now an explicit TemplatesProviderProps type with children: ReactNode

Comment thread src/components/Recent/PageRecent.tsx Outdated
};

// Handles mouse click over each template row
const handleTemplateRowClick = (row: Row) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug 1 — Duplicate handler] handleTemplateRowClick is byte-for-byte identical to handleRowClick. Delete this and pass handleRowClick directly to both GraphTable instances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the duplicate handleTemplateRowClick and now template table rows reuse the existing handleRowClick

Comment thread src/components/Recent/PageRecent.tsx Outdated
// Map templates to match Graph structure for table view (templates use 'date' instead of 'DateModified')
const templatesForTable = templates.map(template => ({
...template,
DateModified: template.date || template.DateModified || '',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug 2 — Split normalization] The date → DateModified mapping is done twice: here in templatesForTable, and again inline at line 225 for the grid view (DateModified={template.date || template.DateModified || ''}). This normalization should happen once in TemplatesContext so all consumers get a consistent shape. Consumers should not need to know whether the field is called date or DateModified.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved the date to DateModified normalization into TemplatesContext, so consumers now receive a consistent template shape. PageRecent no longer maps templates for the table view or handles the inline date || DateModified fallback in the grid view.

Comment thread src/components/Recent/PageRecent.tsx Outdated
updateSettings({ templatesPageViewMode: templatesViewMode });

// Send settings to Dynamo to save
saveHomePageSettings({ ...settings, templatesPageViewMode: templatesViewMode });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug 3 — Stale closure] saveHomePageSettings closes over settings, but settings is excluded from deps via the eslint-disable below. If settings changes independently (e.g. a sidebar width update), this call sends stale data. Either add settings to the deps array, or thread only the changed key into the save call rather than spreading the whole settings object.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both view-mode save effects now create a merged settings object and pass the same payload to updateSettings and saveHomePageSettings

Comment thread src/assets/home.ts
Thumbnail: img
}
];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Minor 9 — Missing newline at EOF] File ends without a trailing newline. Add one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread src/index.css Outdated
left: 50%;
max-width: 300px;
transform: translateX(-50%);
max-width: 500px; /* Increased width to make it wider */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Minor 10 — Global tooltip width change] max-width changed from 300px → 500px for all .tooltip-box elements. This silently widens every tooltip in the app, not just the templates one. If the wider width is only needed for the templates tooltip, scope it with a modifier class (e.g. .tooltip-box.wide) rather than changing the global default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed back the default tooltip width to 300px and added a scoped template-info-tooltip class so only the Templates info tooltip uses the wider 500px width

Comment thread tsconfig.json
// "rootDirs": ["./src"], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["./types", "./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */
"types": ["react", "node", "jest"], /* Specify type package names to be included without being referenced in a source file. */
// "typeRoots": ["./types", "./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Minor 11 — typeRoots commented out] The custom ./types directory is no longer listed as a typeRoot. Verify that the global declarations in types/index.d.ts (including the newly added receiveTemplatesDataFromDotNet) are still resolved by running tsc --noEmit before merge.

@johnpierson

Copy link
Copy Markdown
Member

@Chloepeg - added some comments from Claude, please let me know if any are too out there

@jnealb

jnealb commented Jun 10, 2026

Copy link
Copy Markdown

Claude comments: [
pr89-review-checklist.md

@jasonstratton jasonstratton left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think John caught most of it.

I wanted to point out that clicking a template just opens the template file directly, but the Jira issue specified "new from template".

The other is that there are no additional tests for the additions to PageRecent.tsx or the new file TemplatesContext.tsx

Comment thread src/components/Recent/PageRecent.tsx Outdated
updateSettings({ templatesPageViewMode: templatesViewMode });

// Send settings to Dynamo to save
saveHomePageSettings({ ...settings, templatesPageViewMode: templatesViewMode });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good catch!

Comment thread src/components/TemplatesContext.tsx Outdated
import { createContext, useContext, useState, useEffect } from 'react';

// Create the context
const TemplatesContext = createContext<any[]>([]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TemplatesContext is untyped as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TemplatesContext now uses explicit TemplateInput and Template types instead of any[]

Comment thread src/components/Recent/PageRecent.tsx Outdated
setIsDisabled(true);

const contextData = row.original.ContextData;
openFile(contextData);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I may be confused here, bhen clicking on the template, it should be creating a copy of the template and opening it (or something like that)? And not opening the template file directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DynamoHome only passes the selected row path to the host via openFile. The paired Dynamo branch (DynamoDS/Dynamo#17107) detects when that path belongs to TemplateFiles and opens it as a template/new editable workspace.

PageRecent cleanup:
Removed duplicate handleTemplateRowClick.
Removed inline template normalization.
Uses new TemplatesSection.
Both view-mode save effects now use one merged settings payload.

New Templates component:
Added src/components/Recent/TemplatesSection.tsx.
Added empty co-located TemplatesSection.module.css for repo convention.

TemplatesContext:
Replaced any[] with TemplateInput / Template types.
Typed children.
Normalizes template data once in the context.

Tooltip/CSS:
Added optional tooltipClassName.
Restored global tooltip width to 300px.
Scoped Templates tooltip width to 500px.
Removed unused arrow-right tooltip CSS.

Localization:
Added title.text.templates and recent.templates.tooltip across all locale files.
Renamed old tooltip.text.templates usage to recent.templates.tooltip.

Types:
Updated Graph shape to use DateModified.
Added optional Author / Description.
Added tooltipClassName to Tooltip.
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