From 48c0a92339db999c598fe24cdc9302b28cffa14d Mon Sep 17 00:00:00 2001 From: ArnaudTa <33383276+ArnaudTA@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:19:28 +0100 Subject: [PATCH 1/2] fix: :ambulance: fix not displayed repositories in admin view --- apps/client/src/views/admin/AdminProject.vue | 174 +++++++++++-------- 1 file changed, 104 insertions(+), 70 deletions(-) diff --git a/apps/client/src/views/admin/AdminProject.vue b/apps/client/src/views/admin/AdminProject.vue index 566ec9a4d..bdf74b21f 100644 --- a/apps/client/src/views/admin/AdminProject.vue +++ b/apps/client/src/views/admin/AdminProject.vue @@ -2,8 +2,7 @@ import { onBeforeMount, ref } from 'vue' // @ts-ignore '@gouvminint/vue-dsfr' missing types import { getRandomId } from '@gouvminint/vue-dsfr' -import type { Environment, Log, PluginsUpdateBody, ProjectService, ProjectV2 } from '@cpn-console/shared' -import { sortArrByObjKeyAsc } from '@cpn-console/shared' +import type { Environment, Log, PluginsUpdateBody, ProjectService, ProjectV2, Repo } from '@cpn-console/shared' import fr from 'javascript-time-ago/locale/fr' import TimeAgo from 'javascript-time-ago' import { useSnackbarStore } from '@/stores/snackbar.js' @@ -39,37 +38,38 @@ const logsId = 'logsView' const project = computed(() => projectStore.projectsById[props.projectId]) const environments = ref() +const repositories = ref() // Add locale-specific relative date/time formatting rules. TimeAgo.addLocale(fr) // Create relative date/time formatter. const timeAgo = new TimeAgo('fr-FR') -const repoRows = computed(() => { - if (!project.value.repositories?.length) { - return [[{ - text: 'Aucun dépôt existant', - cellAttrs: { - colspan: headerRepos.length, - }, - }]] - } - return sortArrByObjKeyAsc(project.value.repositories, 'internalRepoName') - .map(({ internalRepoName, isInfra, externalRepoUrl, isPrivate, createdAt }) => ( - [ - internalRepoName, - isInfra ? 'Infra' : 'Applicatif', - isPrivate ? 'oui' : 'non', - externalRepoUrl || '-', - { - text: timeAgo.format(new Date(createdAt)), - title: (new Date(createdAt)).toLocaleString(), - component: 'span', - }, - ] - ), - ) -}) +// const repoRows = computed(() => { +// if (!project.value.repositories?.length) { +// return [[{ +// text: 'Aucun dépôt existant', +// cellAttrs: { +// colspan: headerRepos.length, +// }, +// }]] +// } +// return sortArrByObjKeyAsc(project.value.repositories, 'internalRepoName') +// .map(({ internalRepoName, isInfra, externalRepoUrl, isPrivate, createdAt }) => ( +// [ +// internalRepoName, +// isInfra ? 'Infra' : 'Applicatif', +// isPrivate ? 'oui' : 'non', +// externalRepoUrl || '-', +// { +// text: timeAgo.format(new Date(createdAt)), +// title: (new Date(createdAt)).toLocaleString(), +// component: 'span', +// }, +// ] +// ), +// ) +// }) function unSelectProject() { router.push({ name: 'ListProjects' }) @@ -109,12 +109,13 @@ async function transferOwnerShip(nextOwnerId: string) { async function getProjectDetails() { try { - const [envs] = await Promise.all([ + const [projectDetails] = await Promise.all([ project.value.refresh(), reloadProjectServices(), showLogs(0), ]) - environments.value = envs.environments + environments.value = projectDetails.environments + repositories.value = projectDetails.repositories } catch (error) { console.trace(error) } @@ -314,49 +315,49 @@ async function getProjectLogs({ offset, limit }: { offset: number, limit: number :key="environmentsCtKey" title="Environnements" > - - - {{ header }} - - - - - {{ env.name }} - {{ stageStore.stages.find(stage => stage.id === env.stageId)?.name ?? 'Type inconnu...' }} - - - +