Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
><slot name="menu">
<div class="flex flex-column lg:flex-row lg:align-items-center gap-2">
<PButton
v-if="hasSidebar"
:icon="menuButtonIcon"
plain
text
Expand All @@ -37,6 +38,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial

<template #end>
<div class="flex align-items-center flex-shrink-0">
<slot name="action-button"></slot>
<PButton
v-if="loggedUser"
text
Expand Down Expand Up @@ -215,6 +217,11 @@ export default defineComponent({
? `${this.getUserFullName.substring(0, 15)}...`
: this.getUserFullName
},
hasSidebar() {
return this.$route.matched.some(
(record) => record.components != null && 'sidebar' in record.components
)
},
menuButtonIcon() {
if (this.isUnderOverlayBreakpoint) {
return 'ti ti-menu-2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
},
file() {
return (
this.project?.files[this.filePath] || this.upload?.files[this.filePath]
this.project?.files?.[this.filePath] || this.upload?.files?.[this.filePath]

Check warning on line 129 in web-app/packages/lib/src/modules/project/components/FileDetailSidebar.vue

View workflow job for this annotation

GitHub Actions / JavaScript code convention check

Insert `⏎·······`
)
},
fileName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const breadcrumps = computed(() => {
})

const projectFiles = computed(() => {
let files = projectStore.project.files
let files = projectStore.project.files ?? []
if (projectStore.uploads[projectStore.project.path] && diff.value) {
files = {
...files,
Expand Down
7 changes: 6 additions & 1 deletion web-app/packages/lib/src/modules/project/projectApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
UpdateProjectCollaboratorPayload,
UpdatePublicFlagParams,
ProjectCollaborator,
AddProjectCollaboratorPayload
AddProjectCollaboratorPayload,
ProjectV2Response
} from '@/modules/project/types'

export const ProjectApi = {
Expand All @@ -39,6 +40,10 @@ export const ProjectApi = {
return ProjectModule.httpService(`/v1/project/${namespace}/${projectName}`)
},

async getProjectV2(id: string): Promise<AxiosResponse<ProjectV2Response>> {
return ProjectModule.httpService(`/v2/projects/${id}`)
},

async createProject(
namespace: string,
data: CreateProjectParams,
Expand Down
37 changes: 36 additions & 1 deletion web-app/packages/lib/src/modules/project/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
ProjectVersionListItem,
UpdateProjectCollaboratorPayload,
UpdatePublicFlagParams,
ProjectCollaborator
ProjectCollaborator,
ProjectV2Response
} from '@/modules/project/types'
import { useUserStore } from '@/modules/user/store'

Expand Down Expand Up @@ -170,6 +171,29 @@
})
}
},
setProjectV2(payload: { project: ProjectV2Response }) {
this.project = {
...(this.project ?? {}),
// Transofrm ProjectV2Response to EnhancedProjectDetail , we can skip files
id: payload.project.id,
name: payload.project.name,
namespace: payload.project.workspace.name,
workspace_id: payload.project.workspace.id,
role: payload.project.role,
path: [payload.project.workspace.name, payload.project.name].join('/'),
created: payload.project.created_at,
updated: payload.project.updated_at,
access: undefined,
version: payload.project.version,
// Leave as undefined in this time. When full implementation needed, we can use it.
files: undefined,
creator: undefined,
disk_usage: payload.project.size,
has_conflict: undefined,
permissions: undefined,
tags: undefined
}
},
setProjects(payload: ProjectsPayload) {
this.projects = payload.projects
this.projectsCount = payload.count
Expand Down Expand Up @@ -489,6 +513,17 @@
}
},

async getProjectV2(projectId: string) {
const notificationStore = useNotificationStore()

try {
const projectResponse = await ProjectApi.getProjectV2(projectId)
this.setProjectV2({ project: projectResponse.data })
} catch {
await notificationStore.error({ text: 'Failed to load project data' })
}
},

async unsubscribeProject(payload) {
const notificationStore = useNotificationStore()

Expand Down Expand Up @@ -749,7 +784,7 @@
FileSaver.saveAs(payload.url)
notificationStore.closeNotification()
this.cancelDownloadArchive()
} catch (e) {

Check warning on line 787 in web-app/packages/lib/src/modules/project/store.ts

View workflow job for this annotation

GitHub Actions / JavaScript code convention check

'e' is defined but never used. Allowed unused caught errors must match /^_/u
notificationStore.error({ text: errorMessage })
this.cancelDownloadArchive()
}
Expand Down
15 changes: 15 additions & 0 deletions web-app/packages/lib/src/modules/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ export interface Project {
created?: string
}

export interface ProjectV2Response {
id: string
name: string
version: string
public: boolean
size: number
created_at: string
updated_at: string
workspace: {
id: number
name: string
}
role: ProjectRoleName | null
}

export interface ProjectListItem extends Project {
access: ProjectAccess
creator: number | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
<div class="flex flex-column align-items-center p-4 text-center">
<p>No changeset for current layer</p>
</div>
console.log('getChangeset', this.namespace, this.projectName,
this.version_id, this.path)
</template>
</PDataTable>
</app-section>
Expand Down
Loading