Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 💄 disable cluster selection when creating a zone #1431

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
19 changes: 7 additions & 12 deletions apps/client/cypress/components/specs/zone-form.ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ describe('ZoneForm.vue', () => {
.clear()
.type('Cette zone de déploiement est publique.')
cy.getByDataTestid('addZoneBtn').should('be.enabled')
cy.get('#clusters-select')
.click()
cy.getByDataTestid(`${props.allClusters[0].id}-clusters-select-tag`)
.click()
cy.getByDataTestid('addZoneBtn').should('be.enabled')
})

it('Should mount a new zone ZoneForm without clusters', () => {
Expand Down Expand Up @@ -80,11 +75,6 @@ describe('ZoneForm.vue', () => {
.clear()
.type('Cette zone de déploiement est publique.')
cy.getByDataTestid('addZoneBtn').should('be.enabled')
cy.get('#clusters-select h6')
.click()
cy.get('#clusters-select .fr-tag')
cy.should('contain', 'Aucune sélection, 0 choix disponibles')
cy.getByDataTestid('addZoneBtn').should('be.enabled')
})

it('Should mount an update ZoneForm', () => {
Expand Down Expand Up @@ -122,8 +112,13 @@ describe('ZoneForm.vue', () => {
.clear()
.type('Cette zone de déploiement est privée.')
cy.getByDataTestid('updateZoneBtn').should('be.enabled')
cy.get('#clusters-select')
.should('not.exist')
cy.get('#clusters-select h6')
.click()
cy.getByDataTestid(`${props.allClusters[0].id}-clusters-select-tag`)
.should('be.visible')
.click()
cy.getByDataTestid(`${props.allClusters[0].id}-clusters-select-tag`)
.should('be.disabled')
cy.getByDataTestid('updateZoneBtn').should('be.enabled')
})
})
18 changes: 10 additions & 8 deletions apps/client/cypress/e2e/specs/admin/zones.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ describe('Administration zones', () => {
.should('have.value', zone.description)
.and('be.enabled')
cy.get('#clusters-select')
.should('not.exist')
.should('exist')
.and('be.disabled')
cy.getByDataTestid('updateZoneBtn')
.should('be.enabled')
cy.getByDataTestid('cancelZoneBtn')
Expand Down Expand Up @@ -100,7 +101,8 @@ describe('Administration zones', () => {
.should('have.value', updatedZone.description)
.and('be.enabled')
cy.get('#clusters-select')
.should('not.exist')
.should('exist')
.and('be.disabled')
cy.getByDataTestid('updateZoneBtn')
.should('be.enabled')
cy.getByDataTestid('cancelZoneBtn')
Expand Down Expand Up @@ -141,10 +143,8 @@ describe('Administration zones', () => {
cy.getByDataTestid('descriptionInput')
.clear()
.type(newZone.description)
newZone.clusterIds.forEach((id) => {
cy.getByDataTestid(`${id}-clusters-select-tag`)
.click()
})
cy.get('#clusters-select')
.should('not.exist')
cy.getByDataTestid('addZoneBtn')
.should('be.enabled')
.click()
Expand All @@ -170,7 +170,8 @@ describe('Administration zones', () => {
.should('have.value', newZone.description)
.and('be.enabled')
cy.get('#clusters-select')
.should('not.exist')
.should('exist')
.and('be.disabled')
cy.getByDataTestid('updateZoneBtn')
.should('be.enabled')
cy.getByDataTestid('cancelZoneBtn')
Expand All @@ -180,7 +181,8 @@ describe('Administration zones', () => {
.should('be.visible')
.click()
cy.get('#clusters-select')
.should('not.exist')
.should('exist')
.and('be.disabled')
cy.getByDataTestid('cancelZoneBtn')
.click()
})
Expand Down
26 changes: 11 additions & 15 deletions apps/client/src/components/ZoneForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ const errorSchema = computed<SharedZodError | undefined>(() => {
})
const isZoneValid = computed(() => !errorSchema.value)

function updateClusters(value: string[]) {
localZone.value.clusterIds = value
}

function addZone() {
if (isZoneValid.value) emit('add', localZone.value)
}
Expand Down Expand Up @@ -117,21 +113,28 @@ onBeforeMount(() => {
hint="Facultatif. Attention, ces informations seront visibles par les utilisateurs de la console."
/>
<div
v-if="props.isNewZone"
mathieulaude marked this conversation as resolved.
Show resolved Hide resolved
v-if="!props.isNewZone"
class="fr-mb-2w"
>
<ChoiceSelector
id="clusters-select"
:wrapped="false"
:disabled="true"
label="Clusters associés"
:description="!props.isNewZone ? 'Veuillez procéder aux associations dans le formulaire des clusters concernés.' : 'Sélectionnez les clusters autorisés à utiliser cette zone.'"
description="Veuillez procéder aux associations dans le formulaire des clusters concernés."
:options="props.allClusters"
:options-selected="props.allClusters.filter(({ id }) => localZone.clusterIds?.includes(id))"
:options-selected="props.associatedClusters"
label-key="label"
value-key="id"
@update="(_c: Cluster[], clusterIds: Cluster['id'][]) => updateClusters(clusterIds)"
/>
</div>
<DsfrAlert
v-if="props.associatedClusters.length"
class="mt-5"
data-testid="associatedClustersAlert"
description="La zone ne peut être supprimée, car des clusters y sont associés."
small
/>
<div
class="flex space-x-10 mt-5"
>
Expand Down Expand Up @@ -161,13 +164,6 @@ onBeforeMount(() => {
@click="cancel()"
/>
</div>
<DsfrAlert
v-if="props.associatedClusters.length"
class="mt-5"
data-testid="associatedClustersAlert"
description="La zone ne peut être supprimée, car des clusters y sont associés."
small
/>
<div
v-if="localZone.id && !props.associatedClusters.length"
data-testid="deleteZoneZone"
Expand Down
Loading