Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion components/project-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ProjectDetails extends HTMLElement {
renderCleanup = new CleanupRegistry()
/** @type {Function|null} Unsubscribe function for project ready listener */
_unsubProject = null
/** @type {string|null} Track manifest key to prevent duplicate renders */
_currentManifestKey = null

style = `
sequence-panel {
Expand Down Expand Up @@ -118,10 +120,26 @@ class ProjectDetails extends HTMLElement {
try { this._unsubProject?.() } catch {}
this.renderCleanup.run()
this.cleanup.run()
this._currentManifestKey = null
}

render() {
const project = this.Project ?? TPEN.activeProject

if (!project) {
console.error('No project data available to render')
return
}

const manifestKey = JSON.stringify(project?.manifest ?? [])
const manifestId = Array.isArray(project?.manifest) ? project.manifest[0] : project?.manifest

// Only render if manifest has changed or first render
if (this._currentManifestKey === manifestKey) {
return
}
this._currentManifestKey = manifestKey

Comment thread
cubap marked this conversation as resolved.
Comment thread
cubap marked this conversation as resolved.
const projectOwner = Object.entries(project.collaborators).find(([userID, u]) => u.roles.includes('OWNER'))?.[1].profile.displayName
const collaboratorCount = Object.keys(project.collaborators).length

Expand All @@ -143,7 +161,7 @@ class ProjectDetails extends HTMLElement {
<p>
${collaboratorCount < 3 ? "Collaborators: "+Object.entries(project.collaborators).map(([userID, u]) => u.profile.displayName).join(', ') : `${collaboratorCount} collaborator${collaboratorCount===1? '' : 's'}`}
</p>
<sequence-panel manifest-id="${project.manifest}"></sequence-panel>
${manifestId ? `<sequence-panel manifest-id="${manifestId}"></sequence-panel>` : ''}
`
// Clear previous render-specific listeners before adding new ones
this.renderCleanup.run()
Expand Down
6 changes: 3 additions & 3 deletions interfaces/manage-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ TPEN.eventDispatcher.on('tpen-project-loaded', () => {
leaveProjectBtn.href = `/project/leave?projectID=${projectID}`
}

// Render the page with permissions check
render()
// Apply project context with permissions check
applyProjectContext()
})

document.getElementById('export-project-btn').addEventListener('click', async () => {
Expand All @@ -63,7 +63,7 @@ document.getElementById('export-project-btn').addEventListener('click', async ()
})
})

function render() {
function applyProjectContext() {
const isManageProjectPermission = CheckPermissions.checkEditAccess('PROJECT')
if(!isManageProjectPermission) {
alert("You do not have permissions to use this page.")
Expand Down