Skip to content

Commit

Permalink
Merge branch '61036-fix-ingress-base-domain-text' into 'master'
Browse files Browse the repository at this point in the history
Fix base domain help text update

Closes #61036

See merge request gitlab-org/gitlab-ce!27746
  • Loading branch information
Tim Zallmann committed Apr 29, 2019
2 parents 119daae + 36624f2 commit 6050de1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 36 deletions.
12 changes: 4 additions & 8 deletions app/assets/javascripts/clusters/clusters_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,10 @@ export default class Clusters {
this.store.acknowledgeSuccessfulUpdate(appId);
}

toggleIngressDomainHelpText(ingressPreviousState, ingressNewState) {
const { externalIp, status } = ingressNewState;
const helpTextHidden = status !== APPLICATION_STATUS.INSTALLED || !externalIp;
const domainSnippetText = `${externalIp}${INGRESS_DOMAIN_SUFFIX}`;

if (ingressPreviousState.status !== status) {
this.ingressDomainHelpText.classList.toggle('hide', helpTextHidden);
this.ingressDomainSnippet.textContent = domainSnippetText;
toggleIngressDomainHelpText({ externalIp }, { externalIp: newExternalIp }) {
if (externalIp !== newExternalIp) {
this.ingressDomainHelpText.classList.toggle('hide', !newExternalIp);
this.ingressDomainSnippet.textContent = `${newExternalIp}${INGRESS_DOMAIN_SUFFIX}`;
}
}

Expand Down
5 changes: 5 additions & 0 deletions changelogs/unreleased/61036-fix-ingress-base-domain-text.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Fix base domain help text update
merge_request: 27746
author:
type: fixed
35 changes: 7 additions & 28 deletions spec/frontend/clusters/clusters_bundle_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { loadHTMLFixture } from 'helpers/fixtures';
import { setTestTimeout } from 'helpers/timeout';
import $ from 'jquery';

const { INSTALLING, INSTALLABLE, INSTALLED, NOT_INSTALLABLE } = APPLICATION_STATUS;
const { INSTALLING, INSTALLABLE, INSTALLED } = APPLICATION_STATUS;

describe('Clusters', () => {
setTestTimeout(1000);
Expand Down Expand Up @@ -317,13 +317,12 @@ describe('Clusters', () => {
let ingressNewState;

beforeEach(() => {
ingressPreviousState = { status: INSTALLABLE };
ingressNewState = { status: INSTALLED, externalIp: '127.0.0.1' };
ingressPreviousState = { externalIp: null };
ingressNewState = { externalIp: '127.0.0.1' };
});

describe(`when ingress application new status is ${INSTALLED}`, () => {
describe(`when ingress have an external ip assigned`, () => {
beforeEach(() => {
ingressNewState.status = INSTALLED;
cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);
});

Expand All @@ -338,31 +337,11 @@ describe('Clusters', () => {
});
});

describe(`when ingress application new status is different from ${INSTALLED}`, () => {
describe(`when ingress does not have an external ip assigned`, () => {
it('hides custom domain help text', () => {
ingressNewState.status = NOT_INSTALLABLE;
cluster.ingressDomainHelpText.classList.remove('hide');

cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);

expect(cluster.ingressDomainHelpText.classList.contains('hide')).toEqual(true);
});
});

describe('when ingress application new status and old status are the same', () => {
it('does not display custom domain help text', () => {
ingressPreviousState.status = INSTALLED;
ingressNewState.status = ingressPreviousState.status;

cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);

expect(cluster.ingressDomainHelpText.classList.contains('hide')).toEqual(true);
});
});

describe(`when ingress new status is ${INSTALLED} and there isn’t an ip assigned`, () => {
it('does not display custom domain help text', () => {
ingressPreviousState.externalIp = '127.0.0.1';
ingressNewState.externalIp = null;
cluster.ingressDomainHelpText.classList.remove('hide');

cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);

Expand Down

0 comments on commit 6050de1

Please sign in to comment.