Skip to content

Commit

Permalink
Merge pull request #602 from cloud-pi-native/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudTA committed Aug 28, 2023
2 parents 43baeff + f232325 commit 7ba71ea
Show file tree
Hide file tree
Showing 73 changed files with 1,262 additions and 652 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ screenshots
downloads

# init-db
apps/server/src/init/db/imports/data.js
apps/server/src/init/db/imports/data

# act
**/act/artifacts
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ screenshots
downloads

# init-db
apps/server/src/init/db/imports/data.js
apps/server/src/init/db/imports/data

# act
**/act/artifacts
Expand Down
1 change: 1 addition & 0 deletions apps/client/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
2 changes: 1 addition & 1 deletion apps/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = {
'comma-dangle': [2, 'always-multiline'],
'vue/no-v-html': 0,
'no-irregular-whitespace': 0,
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
Expand Down
2 changes: 1 addition & 1 deletion apps/client/cypress/e2e/specs/admin/logs.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Administration logs', () => {
})

it('Should display logs list, loggedIn as admin', () => {
cy.getByDataTestid('logCountInfo').should('contain', `Total : ${logCount} logs`)
cy.getByDataTestid('logCountInfo').should('contain', `Total : ${logCount} événements`)
logs.forEach(log => {
cy.getByDataTestid(`${log.id}-json`)
})
Expand Down
27 changes: 22 additions & 5 deletions apps/client/cypress/e2e/specs/create-project.e2e.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { getModelById } from '../support/func.js'

describe('Create Project', () => {
const project = {
orgName: 'mi',
name: 'project01',
description: 'Application de prise de rendez-vous en préfécture.',
}

beforeEach(() => {
cy.kcLogin('test')
})
Expand All @@ -10,11 +16,6 @@ describe('Create Project', () => {
cy.intercept('GET', '/api/v1/projects').as('getProjects')

const owner = getModelById('user', 'cb8e5b4b-7b7b-40f5-935f-594f48ae6565')
const project = {
orgName: 'mi',
name: 'project01',
description: 'Application de prise de rendez-vous en préfécture.',
}

cy.goToProjects()
.getByDataTestid('createProjectLink').click()
Expand All @@ -36,4 +37,20 @@ describe('Create Project', () => {

cy.assertCreateProjects([project.name])
})

it('Should not create a project if name is already taken', () => {
cy.intercept('POST', '/api/v1/projects').as('postProject')
cy.intercept('GET', '/api/v1/projects').as('getProjects')

cy.goToProjects()
.getByDataTestid('createProjectLink').click()
.get('select#organizationId-select').select(project.orgName)
.getByDataTestid('nameInput').find('input').type(`${project.name}`)
cy.getByDataTestid('createProjectBtn').should('be.enabled').click()

cy.wait('@postProject').its('response.statusCode').should('eq', 400)
cy.getByDataTestid('snackbar').within(() => {
cy.get('p').should('contain', `Le projet "${project.name}" existe déjà`)
})
})
})
4 changes: 2 additions & 2 deletions apps/client/cypress/e2e/specs/dashboard.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Dashboard', () => {
.goToProjects()
.getByDataTestid(`projectTile-${projectToKeep.name}`).click()
.getByDataTestid('menuDashboard').click()
.getByDataTestid('descriptionP').should('not.exist')
.getByDataTestid('descriptionP').should('have.class', 'disabled')
.getByDataTestid('setDescriptionBtn').click()
.getByDataTestid('descriptionInput').clear().type(description1)
.getByDataTestid('saveDescriptionBtn').click()
Expand All @@ -73,7 +73,7 @@ describe('Dashboard', () => {
.getByDataTestid('descriptionInput').clear()
.getByDataTestid('saveDescriptionBtn').click()
.wait('@updateProject').its('response.statusCode').should('eq', 200)
.getByDataTestid('descriptionP').should('not.exist')
.getByDataTestid('descriptionP').should('have.class', 'disabled')
})

it('Should not be able to archive a project if not owner', () => {
Expand Down
4 changes: 1 addition & 3 deletions apps/client/cypress/e2e/specs/environments.e2e.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getModel, getModelById } from '../support/func.js'
import { getModelById } from '../support/func.js'

describe('Manage project environments', () => {
const project0 = getModelById('project', '011e7860-04d7-461f-912d-334c622d38c5')
Expand All @@ -20,8 +20,6 @@ describe('Manage project environments', () => {
cy.intercept('GET', '/api/v1/projects').as('getProjects')
cy.intercept('GET', '/api/v1/admin/projects').as('getAdminProjects')

let environments

cy.kcLogin('tcolin')
cy.visit('/')
.getByDataTestid('menuAdministrationBtn').click()
Expand Down
6 changes: 3 additions & 3 deletions apps/client/cypress/e2e/specs/repos.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Add repos into project', () => {
cy.assertAddRepo(project, repos)
})

it.skip('Should update a repo', () => {
it('Should update a repo', () => {
cy.intercept('GET', '/api/v1/projects').as('getProjects')
cy.intercept('PUT', '/api/v1/projects/*/repositories/*').as('putRepo')
let repos
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('Add repos into project', () => {
})
})

it.skip('Should generate a GitLab CI for a repo', () => {
it('Should generate a GitLab CI for a repo', () => {
cy.intercept('POST', '/api/v1/projects/*/repositories').as('postRepo')
cy.intercept('GET', '/api/v1/projects').as('getProjects')

Expand Down Expand Up @@ -228,7 +228,7 @@ describe('Add repos into project', () => {
cy.assertAddRepo(project, [repo])
})

it.skip('Should delete a repo', () => {
it('Should delete a repo', () => {
const repos = [
{
internalRepoName: 'repo01',
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const routes = [
{
path: '/login',
name: 'Login',
beforeEnter: async (to, from) => {
beforeEnter: async (_to, _from) => {
const userStore = useUserStore()
await userStore.login()
},
Expand All @@ -36,7 +36,7 @@ const routes = [
{
path: '/logout',
name: 'Logout',
beforeEnter: async (to, from) => {
beforeEnter: async (_to, _from) => {
const userStore = useUserStore()
await userStore.logout()
},
Expand Down
5 changes: 5 additions & 0 deletions apps/client/src/views/admin/ListClusters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,10 @@ watch(clusters, () => {
@cancel="cancel()"
/>
</div>
<div
v-if="!clusterList.length"
>
<p>Aucun cluster enregistré</p>
</div>
</div>
</template>
41 changes: 32 additions & 9 deletions apps/client/src/views/admin/ListLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const showLogs = async (key) => {
await getAllLogs({ offset: offset.value, limit: step })
}
const sliceLog = (log) => {
const slicedLog = { ...log }
delete slicedLog.action
delete slicedLog.createdAt
delete slicedLog.updatedAt
return slicedLog
}
const getAllLogs = async ({ offset, limit }, isDisplayingSuccess = true) => {
isUpdating.value = true
try {
Expand All @@ -54,14 +62,14 @@ onMounted(async () => {
<h1
class="fr-h3"
>
Logs des services associés à la chaîne DSO
Journaux des services associés à la chaîne DSO
</h1>
<div
class="flex justify-between"
>
<DsfrAlert
v-if="!isUpdating"
:description="!logsLength ? 'Aucun logs en base de donnée.' : `Total : ${logsLength} logs`"
:description="!logsLength ? 'Aucun événement à afficher' : `Total : ${logsLength} événements`"
data-testid="logCountInfo"
type="info"
small
Expand All @@ -77,15 +85,30 @@ onMounted(async () => {
/>
</div>
<JsonViewer
<div
v-for="log in logs"
:key="log.id"
:data-testid="`${log.id}-json`"
:value="log"
class="json-box"
copyable
boxed
/>
:class="`my-5 border-solid ${log.data?.failed ? 'border-red-100' : 'border-zinc-100'}`"
>
<div
class="flex flex-wrap justify-between"
>
<DsfrBadge
:label="log.action"
:type="log.data?.failed ? 'error' : 'success'"
/>
<DsfrBadge
:label="(new Date(log.createdAt)).toLocaleString()"
no-icon
/>
</div>
<JsonViewer
:data-testid="`${log.id}-json`"
:value="sliceLog(log)"
class="json-box !my-0"
copyable
/>
</div>
<div
class="flex justify-between"
>
Expand Down
70 changes: 39 additions & 31 deletions apps/client/src/views/admin/ListOrganizations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,47 @@ const isUpdatingOrganization = ref(null)
const isOrgAlreadyTaken = computed(() => allOrganizations.value.find(org => org.name === newOrg.value.name))
const setRows = () => {
rows.value = sortArrByObjKeyAsc(allOrganizations.value, 'name')
?.map(({ label, name, source, active, createdAt, updatedAt }) => ([
{
component: 'input',
value: label,
class: 'fr-input fr-text-default--info',
'data-testid': `${name}-label-input`,
onBlur: (event) => {
const data = event.target.value
if (data !== label) {
preUpdateOrganization({ name, key: 'label', data })
}
rows.value = allOrganizations.value.length
? sortArrByObjKeyAsc(allOrganizations.value, 'name')
?.map(({ label, name, source, active, createdAt, updatedAt }) => ([
{
component: 'input',
value: label,
class: 'fr-input fr-text-default--info',
'data-testid': `${name}-label-input`,
onBlur: (event) => {
const data = event.target.value
if (data !== label) {
preUpdateOrganization({ name, key: 'label', data })
}
},
},
},
name,
source,
{
component: 'input',
type: 'checkbox',
checked: active,
'data-testid': `${name}-active-cbx`,
class: 'fr-checkbox-group--sm',
title: active ? `Désactiver l'organisation ${name}` : `Réactiver l'organisation ${name}`,
onClick: (event) => {
const data = event.target.checked
if (data !== active) {
preUpdateOrganization({ name, key: 'active', data })
}
name,
source,
{
component: 'input',
type: 'checkbox',
checked: active,
'data-testid': `${name}-active-cbx`,
class: 'fr-checkbox-group--sm',
title: active ? `Désactiver l'organisation ${name}` : `Réactiver l'organisation ${name}`,
onClick: (event) => {
const data = event.target.checked
if (data !== active) {
preUpdateOrganization({ name, key: 'active', data })
}
},
},
},
formatDate(createdAt),
formatDate(updatedAt),
]))
formatDate(createdAt),
formatDate(updatedAt),
]))
: [[{
text: 'Aucune organisation, veuillez en ajouter une.',
cellAttrs: {
colspan: headers.length,
align: 'center',
},
}]]
}
const getAllOrganizations = async () => {
Expand Down
53 changes: 30 additions & 23 deletions apps/client/src/views/admin/ListProjects.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { onMounted, ref, computed } from 'vue'
import { onMounted, ref } from 'vue'
import { useAdminProjectStore } from '@/stores/admin/project.js'
import { useSnackbarStore } from '@/stores/snackbar.js'
import { formatDate, statusDict, sortArrByObjKeyAsc } from 'shared'
Expand Down Expand Up @@ -27,28 +27,35 @@ const headers = [
const rows = ref([])
const setRows = () => {
rows.value = sortArrByObjKeyAsc(allProjects.value, 'name')
?.map(({ organizationId, name, description, roles, status, locked, createdAt, updatedAt }) => ([
organizations.value?.find(org => org.id === organizationId).label,
name,
description ?? '',
roles[0].user.email,
{
component: 'v-icon',
name: statusDict.status[status].icon,
title: `Le projet ${name} est ${statusDict.status[status].wording}`,
fill: statusDict.status[status].color,
},
{
component: 'v-icon',
name: statusDict.locked[locked].icon,
title: `Le projet ${name} est ${statusDict.locked[locked].wording}`,
fill: statusDict.locked[locked].color,
},
formatDate(createdAt),
formatDate(updatedAt),
]),
)
rows.value = allProjects.value.length
? sortArrByObjKeyAsc(allProjects.value, 'name')
?.map(({ organizationId, name, description, roles, status, locked, createdAt, updatedAt }) => ([
organizations.value?.find(org => org.id === organizationId).label,
name,
description ?? '',
roles[0].user.email,
{
component: 'v-icon',
name: statusDict.status[status].icon,
title: `Le projet ${name} est ${statusDict.status[status].wording}`,
fill: statusDict.status[status].color,
},
{
component: 'v-icon',
name: statusDict.locked[locked].icon,
title: `Le projet ${name} est ${statusDict.locked[locked].wording}`,
fill: statusDict.locked[locked].color,
},
formatDate(createdAt),
formatDate(updatedAt),
]),
)
: [[{
text: 'Aucun projet existant',
cellAttrs: {
colspan: headers.length,
},
}]]
}
const getAllProjects = async () => {
Expand Down
Loading

0 comments on commit 7ba71ea

Please sign in to comment.