diff --git a/src/modules/resource/components/resource-page/FilesViewHeader.vue b/src/modules/resource/components/resource-page/FilesViewHeader.vue index eca57684837f923bc238e2e445c39a0a0dd64aef..c5fd04f01e347aed707ec77f0f6bb6ef601da2ff 100644 --- a/src/modules/resource/components/resource-page/FilesViewHeader.vue +++ b/src/modules/resource/components/resource-page/FilesViewHeader.vue @@ -152,6 +152,18 @@ <b>{{ `${$t("page.resource.usageRights")}: ` }}</b> {{ resource.usageRights }} </li> + <li v-if="resource.resourceTypeOption.RepoUrl"> + <b>{{ `${$t("resourceType.gitlab.domainLabel")} ` }}</b> + {{ resource.resourceTypeOption.RepoUrl }} + </li> + <li v-if="resource.resourceTypeOption.ProjectId"> + <b>{{ `${$t("resourceType.gitlab.projectLabel")} ` }}</b> + {{ gitlabInformation.project ? gitlabInformation.project.name : "" }} + </li> + <li v-if="resource.resourceTypeOption.Branch"> + <b>{{ `${$t("resourceType.gitlab.referenceLabel")} ` }}</b> + {{ resource.resourceTypeOption.Branch }} + </li> </ul> </b-popover> </b-row> @@ -173,8 +185,12 @@ import type { ProjectQuotaReturnObject, UserObject, } from "@coscine/api-client/dist/types/Coscine.Api.Project"; -import type { ResourceTypeInformation } from "@coscine/api-client/dist/types/Coscine.Api.Resources"; +import type { + Project, + ResourceTypeInformation, +} from "@coscine/api-client/dist/types/Coscine.Api.Resources"; import type { VisitedResourceObject } from "../../types"; +import type { GitlabInformation } from "@/modules/resource/types"; export default defineComponent({ name: "FilesViewHeader", @@ -185,6 +201,7 @@ export default defineComponent({ type: String, }, }, + setup() { const resourceStore = useResourceStore(); const projectStore = useProjectStore(); @@ -193,6 +210,18 @@ export default defineComponent({ return { resourceStore, projectStore, userStore }; }, + data() { + return { + gitlabInformation: { + domain: "", + accessToken: "", + project: null, + reference: null, + } as GitlabInformation, + gitlabProjects: [] as Project[] | null, + }; + }, + computed: { isOwner(): boolean | undefined { return this.projectStore.currentUserRoleIsOwner; @@ -247,7 +276,24 @@ export default defineComponent({ return undefined; }, }, + + async mounted() { + await this.getGitlabProjectName(); + }, + methods: { + async getGitlabProjectName() { + this.gitlabProjects = await this.resourceStore.getGitlabAllProjects( + this.resource?.resourceTypeOption.RepoUrl, + this.resource?.resourceTypeOption.AccessToken + ); + if (this.gitlabProjects) { + this.gitlabInformation.project = + this.gitlabProjects.find( + (p) => p.id === this.resource?.resourceTypeOption.ProjectId + ) ?? null; + } + }, edit() { if ( this.resource &&