@@ -123,6 +123,12 @@ export default class ProjectsListNavigation extends HTMLElement {
123123 this . shadowRoot . getElementById ( 'projectsListView' ) . innerHTML = `No projects found`
124124 }
125125 } )
126+
127+ // Handle empty recent activity signal from other components via central dispatcher
128+ TPEN . eventDispatcher . on ( 'tpen-no-recent-activity' , ( ) => {
129+ // Show the welcome/empty state message
130+ this . projects = [ ]
131+ } )
126132 }
127133 async connectedCallback ( ) {
128134 TPEN . attachAuthentication ( this )
@@ -135,22 +141,39 @@ export default class ProjectsListNavigation extends HTMLElement {
135141 return this . #projects
136142 }
137143 async render ( ) {
138- let list = this . shadowRoot . getElementById ( 'projectsListView' )
144+ const root = this . shadowRoot
145+ let list = root . getElementById ( 'projectsListView' )
139146 if ( ! this . #projects?. length ) {
140- list . innerHTML = `
141- <section class="welcome-message">
147+ const welcome = document . createElement ( 'section' )
148+ welcome . className = 'welcome-message'
149+ welcome . innerHTML = `
142150 <p><strong>Welcome to TPEN!</strong></p>
143151 <p>Get started by creating your first project or importing a manuscript.</p>
144152 <ul class="welcome-list">
145153 <li aria-label="View Tutorials"><span aria-hidden="true">📚</span> <a href="https://three.t-pen.org/category/tutorials/" target="_blank" rel="noopener noreferrer">View Tutorials</a></li>
146154 <li aria-label="Frequently Asked Questions"><span aria-hidden="true">❓</span> <a href="https://three.t-pen.org/faq/" target="_blank" rel="noopener noreferrer">Frequently Asked Questions</a></li>
147155 <li aria-label="Find IIIF Resources"><span aria-hidden="true">🖼️</span> <a href="https://iiif.io/guides/finding_resources/" target="_blank" rel="noopener noreferrer">Find IIIF Resources</a></li>
148156 </ul>
149- </section>
150157 `
158+ if ( list ) list . replaceWith ( welcome )
159+ else {
160+ const existingWelcome = root . querySelector ( 'section.welcome-message' )
161+ if ( existingWelcome ) existingWelcome . replaceWith ( welcome )
162+ else root . appendChild ( welcome )
163+ }
151164 return
152165 }
153- list . innerHTML = ""
166+ // Ensure the list element exists when we have projects
167+ if ( ! list ) {
168+ list = document . createElement ( 'ol' )
169+ list . id = 'projectsListView'
170+ if ( this . classList . contains ( 'unbounded' ) ) list . classList . add ( 'unbounded' )
171+ const existingWelcome = root . querySelector ( 'section.welcome-message' )
172+ if ( existingWelcome ) existingWelcome . replaceWith ( list )
173+ else root . appendChild ( list )
174+ } else {
175+ list . innerHTML = ""
176+ }
154177 for ( const project of this . #projects) {
155178 await ( new Project ( project . _id ) . fetch ( ) )
156179 const isManageProjectPermission = await CheckPermissions . checkEditAccess ( 'PROJECT' )
0 commit comments