From 25058602b2dabd29c9275defadaffd7ec21f99a6 Mon Sep 17 00:00:00 2001
From: Neil McCorrison <nmccorrison@gitlab.com>
Date: Thu, 19 Nov 2020 09:53:09 +0000
Subject: [PATCH] Removed DAST On-demand landing page

---
 .../components/on_demand_scans_app.vue        | 17 +---
 .../on_demand_scans_empty_state.vue           | 50 ------------
 .../components/on_demand_scans_form.vue       |  3 -
 .../281833-remove-dast-ondemand-landing.yml   |  5 ++
 .../components/on_demand_scans_app_spec.js    | 35 +-------
 .../components/on_demand_scans_form_spec.js   | 11 ---
 .../on_demans_scans_empty_state_spec.js       | 79 -------------------
 locale/gitlab.pot                             |  6 --
 8 files changed, 9 insertions(+), 197 deletions(-)
 delete mode 100644 ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_empty_state.vue
 create mode 100644 ee/changelogs/unreleased/281833-remove-dast-ondemand-landing.yml
 delete mode 100644 ee/spec/frontend/on_demand_scans/components/on_demans_scans_empty_state_spec.js

diff --git a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_app.vue b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_app.vue
index 18dc6c307a4..0b60e9a70d9 100644
--- a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_app.vue
+++ b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_app.vue
@@ -1,12 +1,10 @@
 <script>
 import OnDemandScansForm from './on_demand_scans_form.vue';
-import OnDemandScansEmptyState from './on_demand_scans_empty_state.vue';
 
 export default {
   name: 'OnDemandScansApp',
   components: {
     OnDemandScansForm,
-    OnDemandScansEmptyState,
   },
   props: {
     helpPagePath: {
@@ -36,19 +34,10 @@ export default {
 
 <template>
   <div>
-    <template v-if="showForm">
-      <on-demand-scans-form
-        :help-page-path="helpPagePath"
-        :project-path="projectPath"
-        :default-branch="defaultBranch"
-        @cancel="showForm = false"
-      />
-    </template>
-    <on-demand-scans-empty-state
-      v-else
+    <on-demand-scans-form
       :help-page-path="helpPagePath"
-      :empty-state-svg-path="emptyStateSvgPath"
-      @createNewScan="showForm = true"
+      :project-path="projectPath"
+      :default-branch="defaultBranch"
     />
   </div>
 </template>
diff --git a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_empty_state.vue b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_empty_state.vue
deleted file mode 100644
index ae76f37d2f8..00000000000
--- a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_empty_state.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-<script>
-import { GlButton, GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui';
-
-export default {
-  name: 'OnDemandScansEmptyState',
-  components: {
-    GlButton,
-    GlEmptyState,
-    GlLink,
-    GlSprintf,
-  },
-  props: {
-    helpPagePath: {
-      type: String,
-      required: true,
-    },
-    emptyStateSvgPath: {
-      type: String,
-      required: true,
-    },
-  },
-};
-</script>
-
-<template>
-  <div>
-    <gl-empty-state :svg-path="emptyStateSvgPath" :title="s__('OnDemandScans|On-demand Scans')">
-      <template #description>
-        <gl-sprintf
-          :message="
-            s__(
-              'OnDemandScans|Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST. %{helpLinkStart}More information%{helpLinkEnd}',
-            )
-          "
-        >
-          <template #helpLink="{ content }">
-            <gl-link :href="helpPagePath">
-              {{ content }}
-            </gl-link>
-          </template>
-        </gl-sprintf>
-      </template>
-      <template #actions>
-        <gl-button data-testid="run-scan-button" variant="success" @click="$emit('createNewScan')">
-          {{ s__('OnDemandScans|Create new DAST scan') }}
-        </gl-button>
-      </template>
-    </gl-empty-state>
-  </div>
-</template>
diff --git a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
index c1bec43f82c..1a6cb8e9eec 100644
--- a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
+++ b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
@@ -230,9 +230,6 @@ export default {
         >
           {{ s__('OnDemandScans|Run scan') }}
         </gl-button>
-        <gl-button data-testid="on-demand-scan-cancel-button" @click="$emit('cancel')">
-          {{ __('Cancel') }}
-        </gl-button>
       </div>
     </template>
   </gl-form>
diff --git a/ee/changelogs/unreleased/281833-remove-dast-ondemand-landing.yml b/ee/changelogs/unreleased/281833-remove-dast-ondemand-landing.yml
new file mode 100644
index 00000000000..17ad011e18c
--- /dev/null
+++ b/ee/changelogs/unreleased/281833-remove-dast-ondemand-landing.yml
@@ -0,0 +1,5 @@
+---
+title: Removed On-demand landing page
+merge_request: 47867
+author:
+type: changed
diff --git a/ee/spec/frontend/on_demand_scans/components/on_demand_scans_app_spec.js b/ee/spec/frontend/on_demand_scans/components/on_demand_scans_app_spec.js
index fd80f0b2522..c9a1dc12f35 100644
--- a/ee/spec/frontend/on_demand_scans/components/on_demand_scans_app_spec.js
+++ b/ee/spec/frontend/on_demand_scans/components/on_demand_scans_app_spec.js
@@ -1,7 +1,6 @@
 import { shallowMount } from '@vue/test-utils';
 import { merge } from 'lodash';
 import OnDemandScansApp from 'ee/on_demand_scans/components/on_demand_scans_app.vue';
-import OnDemandScansEmptyState from 'ee/on_demand_scans/components/on_demand_scans_empty_state.vue';
 import OnDemandScansForm from 'ee/on_demand_scans/components/on_demand_scans_form.vue';
 import { TEST_HOST } from 'helpers/test_constants';
 
@@ -14,17 +13,10 @@ const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/security/configuration
 describe('OnDemandScansApp', () => {
   let wrapper;
 
-  const findOnDemandScansEmptyState = () => wrapper.find(OnDemandScansEmptyState);
   const findOnDemandScansForm = () => wrapper.find(OnDemandScansForm);
 
-  const expectEmptyState = () => {
-    expect(wrapper.find(OnDemandScansForm).exists()).toBe(false);
-    expect(wrapper.find(OnDemandScansEmptyState).exists()).toBe(true);
-  };
-
   const expectForm = () => {
     expect(wrapper.find(OnDemandScansForm).exists()).toBe(true);
-    expect(wrapper.find(OnDemandScansEmptyState).exists()).toBe(false);
   };
 
   const createComponent = options => {
@@ -55,26 +47,8 @@ describe('OnDemandScansApp', () => {
     wrapper = null;
   });
 
-  describe('empty state', () => {
-    it('renders an empty state by default', () => {
-      expectEmptyState();
-    });
-
-    it('passes correct props to GlEmptyState', () => {
-      expect(findOnDemandScansEmptyState().props()).toMatchObject({
-        emptyStateSvgPath,
-        helpPagePath,
-      });
-    });
-  });
-
   describe('form', () => {
-    beforeEach(async () => {
-      findOnDemandScansEmptyState().vm.$emit('createNewScan');
-      await wrapper.vm.$nextTick();
-    });
-
-    it('renders the form when clicking on the primary button', () => {
+    it('renders the form', () => {
       expectForm();
     });
 
@@ -85,12 +59,5 @@ describe('OnDemandScansApp', () => {
         defaultBranch,
       });
     });
-
-    it('shows the empty state on cancel', async () => {
-      findOnDemandScansForm().vm.$emit('cancel');
-      await wrapper.vm.$nextTick();
-
-      expectEmptyState();
-    });
   });
 });
diff --git a/ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js b/ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
index 9ac33507b44..fba6c17fd80 100644
--- a/ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
+++ b/ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
@@ -47,7 +47,6 @@ describe('OnDemandScansForm', () => {
   const findByTestId = testId => subject.find(`[data-testid="${testId}"]`);
   const findAlert = () => findByTestId('on-demand-scan-error');
   const findSubmitButton = () => findByTestId('on-demand-scan-submit-button');
-  const findCancelButton = () => findByTestId('on-demand-scan-cancel-button');
 
   const setFormData = () => {
     subject.find(OnDemandScansScannerProfileSelector).vm.$emit('input', scannerProfiles[0].id);
@@ -227,14 +226,4 @@ describe('OnDemandScansForm', () => {
       });
     });
   });
-
-  describe('cancel', () => {
-    it('emits cancel event on click', () => {
-      mountShallowSubject();
-      jest.spyOn(subject.vm, '$emit');
-      findCancelButton().vm.$emit('click');
-
-      expect(subject.vm.$emit).toHaveBeenCalledWith('cancel');
-    });
-  });
 });
diff --git a/ee/spec/frontend/on_demand_scans/components/on_demans_scans_empty_state_spec.js b/ee/spec/frontend/on_demand_scans/components/on_demans_scans_empty_state_spec.js
deleted file mode 100644
index f532042c756..00000000000
--- a/ee/spec/frontend/on_demand_scans/components/on_demans_scans_empty_state_spec.js
+++ /dev/null
@@ -1,79 +0,0 @@
-import { GlEmptyState, GlSprintf } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import OnDemandScansEmptyState from 'ee/on_demand_scans/components/on_demand_scans_empty_state.vue';
-import { TEST_HOST } from 'helpers/test_constants';
-
-const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-scans`;
-const emptyStateSvgPath = `${TEST_HOST}/assets/illustrations/alert-management-empty-state.svg`;
-
-const GlEmptyStateStub = {
-  props: GlEmptyState.props,
-  template: `
-    <div>
-      <slot name="description" />
-      <slot name="actions" />
-    </div>
-  `,
-};
-
-describe('OnDemandScansEmptyState', () => {
-  let wrapper;
-
-  const findEmptyState = () => wrapper.find(GlEmptyStateStub);
-  const findRunScanButton = () => wrapper.find('[data-testid="run-scan-button"]');
-
-  const createComponent = (props = {}) => {
-    wrapper = shallowMount(OnDemandScansEmptyState, {
-      propsData: {
-        helpPagePath,
-        emptyStateSvgPath,
-        ...props,
-      },
-      stubs: {
-        GlEmptyState: GlEmptyStateStub,
-        GlSprintf,
-        GlButton: { template: '<button><slot /></button>' },
-      },
-    });
-  };
-
-  beforeEach(() => {
-    createComponent();
-  });
-
-  afterEach(() => {
-    wrapper.destroy();
-    wrapper = null;
-  });
-
-  it('renders empty state', () => {
-    expect(wrapper.find(GlEmptyStateStub).exists()).toBe(true);
-  });
-
-  it('passes correct props to GlEmptyState', () => {
-    expect(findEmptyState().props()).toMatchObject({
-      svgPath: emptyStateSvgPath,
-      title: 'On-demand Scans',
-    });
-  });
-
-  it('renders the description', () => {
-    expect(wrapper.text()).toContain(
-      'Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST.',
-    );
-    expect(wrapper.text()).toContain('More information');
-  });
-
-  it('renders the run scan button', () => {
-    const button = findRunScanButton();
-
-    expect(button.exists()).toBe(true);
-    expect(button.text()).toBe('Create new DAST scan');
-  });
-
-  it('clicking on the run scan button emits createNewScan event', () => {
-    findRunScanButton().vm.$emit('click');
-
-    expect(wrapper.emitted().createNewScan).toBeTruthy();
-  });
-});
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 84da7259be9..8e006074e91 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -18925,9 +18925,6 @@ msgstr ""
 msgid "OnDemandScans|Create a new site profile"
 msgstr ""
 
-msgid "OnDemandScans|Create new DAST scan"
-msgstr ""
-
 msgid "OnDemandScans|Manage profiles"
 msgstr ""
 
@@ -18952,9 +18949,6 @@ msgstr ""
 msgid "OnDemandScans|Scanner profile"
 msgstr ""
 
-msgid "OnDemandScans|Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST. %{helpLinkStart}More information%{helpLinkEnd}"
-msgstr ""
-
 msgid "OnDemandScans|Select one of the existing profiles"
 msgstr ""
 
-- 
2.30.9