diff --git a/app/components/dynamic-scan/expiry/index.hbs b/app/components/dynamic-scan/expiry/index.hbs deleted file mode 100644 index 17c7fc4fa7..0000000000 --- a/app/components/dynamic-scan/expiry/index.hbs +++ /dev/null @@ -1,40 +0,0 @@ -
- - - {{this.timeRemaining.minutes}}:{{this.timeRemaining.seconds}} - - - {{#if this.extendtime.isRunning}} - - {{else}} - - - - - - {{/if}} - - - - {{#each this.extendTimeOptions as |time|}} - - - - {{/each}} - -
\ No newline at end of file diff --git a/app/components/dynamic-scan/index.hbs b/app/components/dynamic-scan/index.hbs deleted file mode 100644 index df945a7d03..0000000000 --- a/app/components/dynamic-scan/index.hbs +++ /dev/null @@ -1,124 +0,0 @@ - - {{#if @file.isDynamicStatusNotReady}} - - {{#if @file.isDynamicStatusNeitherNoneNorReadyNorError}} - - <:leftIcon> - - - - <:default>{{@file.statusText}} - - - {{#if @file.isDynamicStatusQueueAndHasAutomation}} - - - - {{/if}} - {{/if}} - - {{#if @file.isDynamicStatusNoneOrError}} - {{#if @file.isDynamicStatusError}} - - <:leftIcon> - - - - <:default>{{t 'errored'}} - - - - - - {{else if @file.isDynamicDone}} - - <:leftIcon> - - - - <:default>{{t 'completed'}} - - - - - - {{else}} - - <:leftIcon> - - - - <:default>{{@dynamicScanText}} - - {{/if}} - {{/if}} - - {{/if}} - - {{#if @file.isDynamicStatusReady}} - - <:leftIcon> - {{#if this.dynamicShutdown.isRunning}} - - {{else}} - - {{/if}} - - - <:default>{{t 'stop'}} - - {{/if}} - - {{#if (and @vncViewer @file.isDynamicStatusStarting)}} -
- {{t 'dynamicScanText'}} -
- {{/if}} -
- -{{#if this.showDynamicScanModal}} - -{{/if}} \ No newline at end of file diff --git a/app/components/dynamic-scan/index.ts b/app/components/dynamic-scan/index.ts deleted file mode 100644 index ba0fed9ed7..0000000000 --- a/app/components/dynamic-scan/index.ts +++ /dev/null @@ -1,106 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; -import { task } from 'ember-concurrency'; -import { action } from '@ember/object'; -import ENV from 'irene/config/environment'; -import ENUMS from 'irene/enums'; -import triggerAnalytics from 'irene/utils/trigger-analytics'; -import { tracked } from '@glimmer/tracking'; -import FileModel from 'irene/models/file'; -import PollService from 'irene/services/poll'; - -export interface DynamicScanSignature { - Args: { - vncViewer?: boolean; - onScanShutdown?: () => void; - file: FileModel; - dynamicScanText: string; - }; -} - -export default class DynamicScanComponent extends Component { - @service declare ajax: any; - @service('notifications') declare notify: NotificationService; - @service declare poll: PollService; - - @tracked showDynamicScanModal = false; - - constructor(owner: unknown, args: DynamicScanSignature['Args']) { - super(owner, args); - - this.pollDynamicStatus(); - } - - @action - openDynamicScanModal() { - triggerAnalytics( - 'feature', - ENV.csb['dynamicScanBtnClick'] as CsbAnalyticsFeatureData - ); - - this.showDynamicScanModal = true; - } - - @action - closeDynamicScanModal() { - this.showDynamicScanModal = false; - } - - @action - pollDynamicStatus() { - const file = this.args.file; - const isDynamicReady = file.isDynamicStatusReady; - - if (isDynamicReady) { - return; - } - - if (!file.id) { - return; - } - - const stopPoll = this.poll.startPolling( - () => - file - .reload() - .then((f) => { - if ( - f.dynamicStatus === ENUMS.DYNAMIC_STATUS.NONE || - f.dynamicStatus === ENUMS.DYNAMIC_STATUS.READY - ) { - stopPoll(); - } - }) - .catch(() => stopPoll()), - 5000 - ); - } - - dynamicShutdown = task({ drop: true }, async () => { - const file = this.args.file; - - file.setShuttingDown(); - - const dynamicUrl = [ENV.endpoints['dynamic'], file.id].join('/'); - - try { - await this.ajax.delete(dynamicUrl); - - this.args.onScanShutdown?.(); - - if (!this.isDestroyed) { - this.pollDynamicStatus(); - } - } catch (error) { - file.setNone(); - - this.notify.error((error as AdapterError).payload.error); - } - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - DynamicScan: typeof DynamicScanComponent; - } -} diff --git a/app/components/dynamic-scan/modal/index.scss b/app/components/dynamic-scan/modal/index.scss deleted file mode 100644 index fc5079e21e..0000000000 --- a/app/components/dynamic-scan/modal/index.scss +++ /dev/null @@ -1,29 +0,0 @@ -.dynamic-scan-modal-body { - width: 650px; -} - -.dynamic-scan-modal-alert { - background-color: var(--dynamic-scan-modal-alert-background-color); - color: var(--dynamic-scan-modal-alert-text-color); - border: 1px solid var(--dynamic-scan-modal-alert-border-color); - border-radius: var(--dynamic-scan-modal-border-radius); -} - -.device-settings-warning { - color: var(--dynamic-scan-modal-device-settings-warning-text-color); - line-height: 1.3; -} - -.bordered-box { - border: 1px solid var(--dynamic-scan-modal-border-color); - border-radius: var(--dynamic-scan-modal-border-radius); - box-sizing: border-box; - - .bordered-box-item { - padding: 0.5em 1em; - - &:not(:last-child) { - border-bottom: 1px solid var(--dynamic-scan-modal-border-color); - } - } -} diff --git a/app/components/file-chart/index.hbs b/app/components/file-chart/index.hbs index 040e160d17..efdae918ee 100644 --- a/app/components/file-chart/index.hbs +++ b/app/components/file-chart/index.hbs @@ -1,5 +1,11 @@ {{#if this.fetchUnknownAnalysisStatus.isRunning}} - + diff --git a/app/components/file-details/dynamic-scan/action/expiry/index.scss b/app/components/file-details/dynamic-scan/action/expiry/index.scss index 332de0028d..0cc114d6eb 100644 --- a/app/components/file-details/dynamic-scan/action/expiry/index.scss +++ b/app/components/file-details/dynamic-scan/action/expiry/index.scss @@ -1,20 +1,26 @@ .extend-time-btn { - border-radius: 50%; - background-color: var(--dynamic-scan-action-expiry-extend-btn-background) !important; - padding: 0 !important; + border-radius: 50%; + background-color: var( + --file-details-dynamic-scan-action-expiry-extend-btn-background + ) !important; + padding: 0 !important; - :global(.ak-icon) { - color: var(--dynamic-scan-action-expiry-extend-btn-icon-color) !important; - } + :global(.ak-icon) { + color: var( + --file-details-dynamic-scan-action-expiry-extend-btn-icon-color + ) !important; + } } .dynamic-scan-expiry-container { - background-color: var(--dynamic-scan-action-expiry-container-background-color); - padding: 0.3em 1em; - border-radius: 200px; + background-color: var( + --file-details-dynamic-scan-action-expiry-container-background-color + ); + padding: 0.3em 1em; + border-radius: 200px; } .info-btn { - border-radius: 50%; - margin-right: 0.5em; -} \ No newline at end of file + border-radius: 50%; + margin-right: 0.5em; +} diff --git a/app/components/file-details/dynamic-scan/action/index.hbs b/app/components/file-details/dynamic-scan/action/index.hbs index b208e525d2..2420c233ce 100644 --- a/app/components/file-details/dynamic-scan/action/index.hbs +++ b/app/components/file-details/dynamic-scan/action/index.hbs @@ -1,5 +1,7 @@ - {{#if @dynamicScan.isReadyOrRunning}} + {{! TODO: Logic should be replaced by comments when full DAST feature is ready }} + {{!-- {{#if @dynamicScan.isReadyOrRunning}} --}} + {{#if (or @file.isDynamicStatusReady @file.isDynamicStatusInProgress)}} {{#if @isAutomatedScan}} <:leftIcon> {{#if this.dynamicShutdown.isRunning}} @@ -21,7 +23,7 @@ {{else}} {{else}} - + {{/if}} @@ -38,10 +40,11 @@ {{/if}} - {{else if (or @file.isDynamicDone @dynamicScan.isDynamicStatusError)}} + {{!-- {{else if (or @file.isDynamicDone @dynamicScan.isDynamicStatusError)}} --}} + {{else if (or @file.isDynamicDone @file.isDynamicStatusError)}} @@ -69,6 +72,14 @@ {{#if this.showDynamicScanDrawer}} + +{{/if}} + +{{!-- {{#if this.showDynamicScanDrawer}} -{{/if}} \ No newline at end of file +{{/if}} --}} \ No newline at end of file diff --git a/app/components/file-details/dynamic-scan/action/index.ts b/app/components/file-details/dynamic-scan/action/index.ts index 3f80d275ef..cd384a5f42 100644 --- a/app/components/file-details/dynamic-scan/action/index.ts +++ b/app/components/file-details/dynamic-scan/action/index.ts @@ -63,7 +63,7 @@ export default class DynamicScanActionComponent extends Component - this.args.dynamicScan - ?.reload() - .then((ds) => { + this.file + .reload() + .then((f) => { if ( - ds.status === ENUMS.DYNAMIC_STATUS.NONE || - ds.status === ENUMS.DYNAMIC_STATUS.READY + f.dynamicStatus === ENUMS.DYNAMIC_STATUS.NONE || + f.dynamicStatus === ENUMS.DYNAMIC_STATUS.READY ) { stopPoll(); } @@ -91,11 +91,9 @@ export default class DynamicScanActionComponent extends Component { - this.args.dynamicScan?.setShuttingDown(); + this.file.setShuttingDown(); - const dynamicUrl = [ENV.endpoints['dynamicscans'], this.profileId].join( - '/' - ); + const dynamicUrl = [ENV.endpoints['dynamic'], this.file.id].join('/'); try { await this.ajax.delete(dynamicUrl); @@ -106,7 +104,7 @@ export default class DynamicScanActionComponent extends Component + {{t 'loading'}}... diff --git a/app/components/file-details/dynamic-scan/automated/index.scss b/app/components/file-details/dynamic-scan/automated/index.scss index 135a4eaa87..6d18820cf1 100644 --- a/app/components/file-details/dynamic-scan/automated/index.scss +++ b/app/components/file-details/dynamic-scan/automated/index.scss @@ -29,4 +29,4 @@ .loading-text { font-style: italic; } -} \ No newline at end of file +} diff --git a/app/components/dynamic-scan/modal/index.hbs b/app/components/file-details/dynamic-scan/drawer-old/index.hbs similarity index 67% rename from app/components/dynamic-scan/modal/index.hbs rename to app/components/file-details/dynamic-scan/drawer-old/index.hbs index 29da606b33..09434ff987 100644 --- a/app/components/dynamic-scan/modal/index.hbs +++ b/app/components/file-details/dynamic-scan/drawer-old/index.hbs @@ -4,24 +4,39 @@ @project={{@file.project}} as |dpContext| > - - <:default> -
+ + + + {{t 'modalCard.dynamicScan.title'}} + + + + + + + +
@@ -32,11 +47,11 @@ {{#if @file.minOsVersion}}
@@ -46,13 +61,13 @@ {{#each this.deviceRequirements as |dr|}} {{dr.type}} @@ -60,7 +75,7 @@ {{dr.boldValue}} @@ -80,7 +95,7 @@ {{#unless @file.showScheduleAutomatedDynamicScan}} - @@ -100,13 +115,13 @@
@@ -114,12 +129,12 @@ {{#if this.showApiScanSettings}}
{{t 'modalCard.dynamicScan.apiScanDescription' htmlSafe=true}} @@ -132,13 +147,13 @@ {{#if @file.showScheduleAutomatedDynamicScan}}
{{t 'dynamicScanAutomation'}} @@ -149,7 +164,7 @@ @variant='semi-filled' @size='small' @color='warn' - data-test-dynamicScanModal-automatedDynamicScanChip + data-test-fileDetails-dynamicScanDrawerOld-automatedDynamicScanChip > <:icon> @@ -158,7 +173,7 @@ {{t 'scheduleDynamicscanDesc'}} @@ -168,7 +183,7 @@ <:leftIcon> {{#if this.scheduleDynamicScan.isRunning}} @@ -187,14 +202,16 @@ {{/if}}
- - - <:footer> - - + - - + + \ No newline at end of file diff --git a/app/components/file-details/dynamic-scan/drawer-old/index.scss b/app/components/file-details/dynamic-scan/drawer-old/index.scss new file mode 100644 index 0000000000..992f4656f7 --- /dev/null +++ b/app/components/file-details/dynamic-scan/drawer-old/index.scss @@ -0,0 +1,40 @@ +.dynamic-scan-drawer-alert { + background-color: var( + --file-details-dynamic-scan-drawer-old-alert-background-color + ); + color: var(--file-details-dynamic-scan-drawer-old-alert-text-color); + border: 1px solid + var(--file-details-dynamic-scan-drawer-old-alert-border-color); + border-radius: var(--file-details-dynamic-scan-drawer-old-border-radius); +} + +.device-settings-warning { + color: var( + --file-details-dynamic-scan-drawer-old-device-settings-warning-text-color + ); + line-height: 1.3; +} + +.bordered-box { + border: 1px solid var(--file-details-dynamic-scan-drawer-old-border-color); + border-radius: var(--file-details-dynamic-scan-drawer-old-border-radius); + box-sizing: border-box; + + .bordered-box-item { + padding: 0.5em 1em; + + &:not(:last-child) { + border-bottom: 1px solid + var(--file-details-dynamic-scan-drawer-old-border-color); + } + } +} + +.dynamic-scan-drawer-cta { + z-index: 10; + position: absolute; + bottom: 0; + border-top: 1px solid var(--file-details-dynamic-scan-drawer-border-color); + background-color: var(--file-details-dynamic-scan-drawer-background-main); + box-shadow: var(--file-details-dynamic-scan-drawer-cta-box-shadow); +} diff --git a/app/components/dynamic-scan/modal/index.ts b/app/components/file-details/dynamic-scan/drawer-old/index.ts similarity index 94% rename from app/components/dynamic-scan/modal/index.ts rename to app/components/file-details/dynamic-scan/drawer-old/index.ts index bca12fca66..2c756ccb3e 100644 --- a/app/components/dynamic-scan/modal/index.ts +++ b/app/components/file-details/dynamic-scan/drawer-old/index.ts @@ -9,7 +9,7 @@ import Store from '@ember-data/store'; import { tracked } from '@glimmer/tracking'; import FileModel from 'irene/models/file'; -export interface DynamicScanModalSignature { +export interface FileDetailsDynamicScanDrawerOldSignature { Args: { onClose: () => void; pollDynamicStatus: () => void; @@ -17,7 +17,7 @@ export interface DynamicScanModalSignature { }; } -export default class DynamicScanModalComponent extends Component { +export default class FileDetailsDynamicScanDrawerOldComponent extends Component { @service declare intl: IntlService; @service declare ajax: any; @service declare store: Store; @@ -169,6 +169,6 @@ export default class DynamicScanModalComponent extends Component; project: AsyncBelongsTo; }; } -export default class ProxySettingsViewComponent extends Component { +export default class FileDetailsDynamicScanDrawerOldProxySettingsViewComponent extends Component { @service declare intl: IntlService; @service('notifications') declare notify: NotificationService; @service declare store: Store; @tracked proxy?: ProxySettingModel; - constructor(owner: unknown, args: ProxySettingsViewSignature['Args']) { + constructor( + owner: unknown, + args: FileDetailsDynamicScanDrawerOldProxySettingsViewSignature['Args'] + ) { super(owner, args); this.fetchProxySetting.perform(); @@ -86,6 +90,6 @@ export default class ProxySettingsViewComponent extends Component + + + + + + + + + {{this.timeRemaining.minutes}}:{{this.timeRemaining.seconds}} + + + {{#if this.extendtime.isRunning}} + + {{else}} + + + + + + {{/if}} + + + + {{#each this.extendTimeOptions as |time|}} + + + + {{/each}} + +
\ No newline at end of file diff --git a/app/components/file-details/dynamic-scan/expiry-old/index.scss b/app/components/file-details/dynamic-scan/expiry-old/index.scss new file mode 100644 index 0000000000..0cc114d6eb --- /dev/null +++ b/app/components/file-details/dynamic-scan/expiry-old/index.scss @@ -0,0 +1,26 @@ +.extend-time-btn { + border-radius: 50%; + background-color: var( + --file-details-dynamic-scan-action-expiry-extend-btn-background + ) !important; + padding: 0 !important; + + :global(.ak-icon) { + color: var( + --file-details-dynamic-scan-action-expiry-extend-btn-icon-color + ) !important; + } +} + +.dynamic-scan-expiry-container { + background-color: var( + --file-details-dynamic-scan-action-expiry-container-background-color + ); + padding: 0.3em 1em; + border-radius: 200px; +} + +.info-btn { + border-radius: 50%; + margin-right: 0.5em; +} diff --git a/app/components/dynamic-scan/expiry/index.ts b/app/components/file-details/dynamic-scan/expiry-old/index.ts similarity index 70% rename from app/components/dynamic-scan/expiry/index.ts rename to app/components/file-details/dynamic-scan/expiry-old/index.ts index ac7f979c89..38c826d41b 100644 --- a/app/components/dynamic-scan/expiry/index.ts +++ b/app/components/file-details/dynamic-scan/expiry-old/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable ember/no-observers */ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; @@ -6,61 +5,65 @@ import { inject as service } from '@ember/service'; import { later } from '@ember/runloop'; import { task } from 'ember-concurrency'; import dayjs from 'dayjs'; -import { addObserver, removeObserver } from '@ember/object/observers'; import Store from '@ember-data/store'; import FileModel from 'irene/models/file'; import DatetimeService from 'irene/services/datetime'; import { Duration } from 'dayjs/plugin/duration'; import { EmberRunTimer } from '@ember/runloop/types'; -import DynamicscanModal from 'irene/models/dynamicscan-old'; +import DynamicscanOldModel from 'irene/models/dynamicscan-old'; import ENV from 'irene/config/environment'; +import parseError from 'irene/utils/parse-error'; -export interface DynamicScanExpirySignature { +export interface FileDetailsDynamicScanExpiryOldSignature { Args: { file: FileModel; }; } -export default class DynamicScanExpiryComponent extends Component { +export default class FileDetailsDynamicScanExpiryOldComponent extends Component { @service('notifications') declare notify: NotificationService; @service declare store: Store; @service declare datetime: DatetimeService; - @tracked dynamicscan: DynamicscanModal | null = null; + @tracked dynamicscan: DynamicscanOldModel | null = null; @tracked durationRemaining: null | Duration = null; @tracked clockStop = false; @tracked extendBtnAnchorRef: HTMLElement | null = null; - constructor(owner: unknown, args: DynamicScanExpirySignature['Args']) { + constructor( + owner: unknown, + args: FileDetailsDynamicScanExpiryOldSignature['Args'] + ) { super(owner, args); - this.fetchDynaminscan.perform(); + this.fetchDynamicscan.perform(); this.clock(); - - addObserver(this.args.file, 'isReady', this.observeDeviceState); } willDestroy() { super.willDestroy(); this.clockStop = true; - - removeObserver(this.args.file, 'isReady', this.observeDeviceState); } get extendTimeOptions() { return [5, 15, 30]; } - fetchDynaminscan = task(async () => { - const id = this.args.file.id; - this.dynamicscan = await this.store.findRecord('dynamicscan-old', id); - }); + fetchDynamicscan = task(async () => { + try { + const id = this.args.file.id; + const dynamicscan = await this.store.findRecord('dynamicscan-old', id); + const expiresOn = dynamicscan ? dynamicscan.expiresOn : null; - observeDeviceState() { - this.fetchDynaminscan.perform(); - } + this.dynamicscan = dynamicscan; + + this.setScanDuration(expiresOn); + } catch (error) { + this.notify.error(parseError(error)); + } + }); get canExtend() { const duration = this.durationRemaining; @@ -99,11 +102,7 @@ export default class DynamicScanExpiryComponent extends Component <:icon> -{{else if @file.isDynamicDone}} - - -{{else if @dynamicScan.isDynamicStatusInProgress}} +{{else if @file.isDynamicStatusInProgress}} <:icon> +{{else if @file.isDynamicDone}} + + {{else}} { + get file() { + return this.args.file; + } + getColor(status: string | number | undefined, isDark: boolean) { - if ( - this.args.dynamicScan?.isDynamicStatusInProgress && - !this.args.dynamicScan?.isRunning - ) { + if (this.file?.isDynamicStatusInProgress) { return isDark ? 'warn-dark' : 'warn'; } else if (status === ENUMS.DYNAMIC_STATUS.COMPLETED) { return 'success'; @@ -30,11 +31,11 @@ export default class DynamicScanStatusChipComponent extends Component - - {{#each this.breadcrumbItems as |item|}} - - {{/each}} - +
+
+ + {{#each this.breadcrumbItems as |item|}} + + {{/each}} + - - + + - + - - + + - + +
\ No newline at end of file diff --git a/app/components/file-details/manual-scan/request-form/basic-info/index.hbs b/app/components/file-details/manual-scan/request-form/basic-info/index.hbs index 2e123e30c7..95426c7edd 100644 --- a/app/components/file-details/manual-scan/request-form/basic-info/index.hbs +++ b/app/components/file-details/manual-scan/request-form/basic-info/index.hbs @@ -26,13 +26,13 @@ data-test-manualScanBasicInfo-minOSVersionLabel local-class='basic-info-label' > - {{t 'modalCard.manual.minOSVersion'}} + {{t 'minOSVersion'}}
diff --git a/app/components/file-details/manual-scan/request-form/login-details/index.ts b/app/components/file-details/manual-scan/request-form/login-details/index.ts index b0cf19ecca..b838a6dfc6 100644 --- a/app/components/file-details/manual-scan/request-form/login-details/index.ts +++ b/app/components/file-details/manual-scan/request-form/login-details/index.ts @@ -38,7 +38,7 @@ export default class FileDetailsManualScanRequestFormLoginDetailsComponent exten { name: this.intl.t('action'), component: - 'file-details/scan-actions/manual-scan/login-details/user-role-action' as const, + 'file-details/manual-scan/request-form/login-details/user-role-action' as const, textAlign: 'center', }, ]; diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.hbs b/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.hbs deleted file mode 100644 index 96d5ae6238..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.hbs +++ /dev/null @@ -1,88 +0,0 @@ - - {{#if this.fetchCapturedApis.isRunning}} - - - - - {{t 'loading'}}... - - - - {{else if this.hasNoCapturedApi}} - - - -
- - {{t 'capturedApiEmptyTitle'}} - - - - {{t 'capturedApiEmptyDesc' htmlSafe=true}} - -
-
- {{else}} -
- - - {{t 'capturedApiTitle'}} - - - {{#if this.totalCapturedApiCount}} - - {{t 'selected'}} - ({{this.selectedCount}}/{{this.totalCapturedApiCount}}) - - {{/if}} - - - - {{#each pgc.currentPageResults as |ca|}} - - {{/each}} - -
- - - {{/if}} -
\ No newline at end of file diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.scss b/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.scss deleted file mode 100644 index 4b2ffae709..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.scss +++ /dev/null @@ -1,17 +0,0 @@ -.bordered-box { - padding: 1.25em; - border: 1px solid - var(--file-details-scan-actions-api-scan-captured-apis-border-color); - box-sizing: border-box; -} - -.loading-container { - padding: 1.5em; - height: 150px; - border-radius: var( - --file-details-scan-actions-api-scan-captured-apis-border-radius - ); - border: 1px solid - var(--file-details-scan-actions-api-scan-captured-apis-border-color); - box-sizing: border-box; -} diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.ts b/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.ts deleted file mode 100644 index 8f9d79a5f9..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/index.ts +++ /dev/null @@ -1,139 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; -import { tracked } from '@glimmer/tracking'; -import { task } from 'ember-concurrency'; -import FileModel from 'irene/models/file'; -import IntlService from 'ember-intl/services/intl'; -import Store from '@ember-data/store'; -import CapturedApiModel from 'irene/models/capturedapi'; -import ENV from 'irene/config/environment'; - -// eslint-disable-next-line ember/use-ember-data-rfc-395-imports -import { DS } from 'ember-data'; -import { PaginationProviderActionsArgs } from 'irene/components/ak-pagination-provider'; -import { action } from '@ember/object'; - -export interface FileDetailsScanActionsOldApiScanCapturedApisSignature { - Args: { - file: FileModel; - }; -} - -type CapturedApiQueryResponse = - DS.AdapterPopulatedRecordArray & { - meta: { count: number }; - }; - -export default class FileDetailsScanActionsOldApiScanCapturedApisComponent extends Component { - @service declare intl: IntlService; - @service declare ajax: any; - @service declare store: Store; - @service('notifications') declare notify: NotificationService; - - @tracked selectedCount = 0; - @tracked capturedApiResponse: CapturedApiQueryResponse | null = null; - @tracked limit = 5; - @tracked offset = 0; - - constructor( - owner: unknown, - args: FileDetailsScanActionsOldApiScanCapturedApisSignature['Args'] - ) { - super(owner, args); - - this.setSelectedCount.perform(); - this.fetchCapturedApis.perform(this.limit, this.offset); - } - - get capturedApiList() { - return this.capturedApiResponse?.toArray() || []; - } - - get totalCapturedApiCount() { - return this.capturedApiResponse?.meta?.count || 0; - } - - get hasNoCapturedApi() { - return this.totalCapturedApiCount === 0; - } - - @action - handlePrevNextAction({ limit, offset }: PaginationProviderActionsArgs) { - this.limit = limit; - this.offset = offset; - - this.fetchCapturedApis.perform(limit, offset); - } - - @action - handleItemPerPageChange({ limit }: PaginationProviderActionsArgs) { - this.offset = 0; - - this.fetchCapturedApis.perform(limit, this.offset); - } - - getSelectedApis = task(async () => { - const url = [ - ENV.endpoints['files'], - this.args.file.id, - 'capturedapis', - ].join('/'); - - const data = { fileId: this.args.file.id, is_active: true }; - - return await this.ajax.request(url, { namespace: ENV.namespace_v2, data }); - }); - - setSelectedCount = task(async () => { - try { - const selectedApis = await this.getSelectedApis.perform(); - - this.selectedCount = selectedApis.count; - } catch (error) { - const err = error as AdapterError; - this.notify.error(err.toString()); - } - }); - - toggleApi = task(async (capturedApi: CapturedApiModel) => { - try { - capturedApi.set('isActive', !capturedApi.isActive); - - await capturedApi.save(); - - this.notify.success(this.intl.t('capturedApiSaveSuccessMsg')); - - this.setSelectedCount.perform(); - } catch (err) { - const error = err as AdapterError; - let errMsg = this.intl.t('tPleaseTryAgain'); - - if (error.errors && error.errors.length) { - errMsg = error.errors[0]?.detail || errMsg; - } else if (error.message) { - errMsg = error.message; - } - - this.notify.error(errMsg); - } - }); - - fetchCapturedApis = task(async (limit: number, offset: number) => { - try { - this.capturedApiResponse = (await this.store.query('capturedapi', { - limit, - offset, - fileId: this.args.file.id, - })) as CapturedApiQueryResponse; - } catch (error) { - const err = error as AdapterError; - this.notify.error(err.toString()); - } - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::ScanActionsOld::ApiScan::CapturedApis': typeof FileDetailsScanActionsOldApiScanCapturedApisComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.hbs b/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.hbs deleted file mode 100644 index 7b5e5ee028..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.hbs +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - {{request-to-url @capturedApi.request}} - - {{#if this.handleToggleApi.isRunning}} - - {{/if}} - - - \ No newline at end of file diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.scss b/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.scss deleted file mode 100644 index ec7b5e5d52..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.scss +++ /dev/null @@ -1,8 +0,0 @@ -.api-endpoint-container { - margin-top: 0.4em; - - .api-endpoint { - word-break: break-all; - white-space: normal; - } -} diff --git a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.ts b/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.ts deleted file mode 100644 index 69535547de..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/captured-apis/overview/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Component from '@glimmer/component'; -import { task } from 'ember-concurrency'; -import CapturedApiModel from 'irene/models/capturedapi'; - -export interface FileDetailsScanActionsOldApiScanCapturedApiOverviewSignature { - Args: { - capturedApi: CapturedApiModel; - toggleApi: () => Promise; - }; -} - -export default class FileDetailsScanActionsOldApiScanCapturedApiOverviewComponent extends Component { - handleToggleApi = task(async () => { - await this.args.toggleApi(); - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::ScanActionsOld::ApiScan::CapturedApis::Overview': typeof FileDetailsScanActionsOldApiScanCapturedApiOverviewComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/api-scan/index.hbs b/app/components/file-details/scan-actions-old/api-scan/index.hbs deleted file mode 100644 index 69fd69a92d..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/index.hbs +++ /dev/null @@ -1,114 +0,0 @@ -{{#if @file.isRunningApiScan}} - - {{t 'scanning'}} - : - {{@file.apiScanProgress}}% - -{{else if @file.isApiDone}} - - <:leftIcon> - - - - <:default>{{t 'completed'}} - -{{else if @file.isApiNotDone}} - - <:leftIcon> - {{#if this.openApiScanModal.isRunning}} - - {{else}} - - {{/if}} - - - <:default>{{t 'start'}} - -{{/if}} - -{{#if this.showApiScanModal}} - - <:default> -
- {{#if this.hasDynamicScanDone}} - {{#if this.capturedApisCount}} - - - - - {{t 'modalCard.apiScan.warning' htmlSafe=true}} - - - -
- - {{t 'modalCard.apiScan.description'}} - -
- {{/if}} - -
- -
- -
- -
- {{else}} - - - - - {{t 'modalCard.apiScan.noDynamicScan'}} - - - {{/if}} -
- - - <:footer> - - - - {{#if this.capturedApisCount}} - - {{t 'modalCard.apiScan.start'}} - - {{else}} - - {{t 'close'}} - - {{/if}} - - -
-{{/if}} \ No newline at end of file diff --git a/app/components/file-details/scan-actions-old/api-scan/index.scss b/app/components/file-details/scan-actions-old/api-scan/index.scss deleted file mode 100644 index 021ee4b3b9..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/index.scss +++ /dev/null @@ -1,9 +0,0 @@ -.api-scan-modal-alert { - padding: 1em; - background-color: var( - --file-details-scan-actions-api-scan-alert-background-color - ); - color: var(--file-details-scan-actions-api-scan-alert-text-color); - border: 1px solid var(--file-details-scan-actions-api-scan-alert-border-color); - border-radius: var(--file-details-scan-actions-api-scan-border-radius); -} diff --git a/app/components/file-details/scan-actions-old/api-scan/index.ts b/app/components/file-details/scan-actions-old/api-scan/index.ts deleted file mode 100644 index cd1292d47f..0000000000 --- a/app/components/file-details/scan-actions-old/api-scan/index.ts +++ /dev/null @@ -1,131 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; -import { action } from '@ember/object'; -import ENV from 'irene/config/environment'; -import triggerAnalytics from 'irene/utils/trigger-analytics'; -import { task } from 'ember-concurrency'; -import IntlService from 'ember-intl/services/intl'; -import { tracked } from '@glimmer/tracking'; - -import FileModel from 'irene/models/file'; -import RealtimeService from 'irene/services/realtime'; -import TrailService from 'irene/services/trial'; - -export interface FileDetailsScanActionsOldApiScanSignature { - Args: { - file: FileModel; - }; -} - -export default class FileDetailsScanActionsOldApiScanComponent extends Component { - @service declare intl: IntlService; - @service declare trial: TrailService; - @service declare ajax: any; - @service('notifications') declare notify: NotificationService; - @service declare realtime: RealtimeService; - - @tracked capturedApisCount = 0; - @tracked showApiScanModal = false; - - get tStartingApiScan() { - return this.intl.t('startingApiScan'); - } - - get tPleaseTryAgain() { - return this.intl.t('pleaseTryAgain'); - } - - get hasDynamicScanDone() { - return this.args.file.isDynamicDone; - } - - /* fetch captured apis count */ - setCapturedApisCount = task(async () => { - const url = [ - ENV.endpoints['files'], - this.args.file.id, - 'capturedapis', - ].join('/'); - - const data = { fileId: this.args.file.id }; - - const apis = await this.ajax.request(url, { - namespace: ENV.namespace_v2, - data, - }); - - this.realtime.incrementProperty('CapturedApiCounter'); - - try { - this.capturedApisCount = apis.count; - } catch (error) { - this.notify.error((error as Error).toString()); - } - }); - - /* API scan modal actions */ - openApiScanModal = task({ drop: true }, async () => { - if (this.hasDynamicScanDone) { - await this.setCapturedApisCount.perform(); - } - - triggerAnalytics( - 'feature', - ENV.csb['apiScanBtnClick'] as CsbAnalyticsFeatureData - ); - - this.showApiScanModal = true; - }); - - @action - closeApiScanModal() { - this.showApiScanModal = false; - } - - /* init API scan */ - startApiScan = task(async () => { - const dynamicUrl = [ - ENV.endpoints['files'], - this.args.file.id, - ENV.endpoints['capturedApiScanStart'], - ].join('/'); - - return await this.ajax.post(dynamicUrl, { namespace: ENV.namespace_v2 }); - }); - - runApiScan = task(async () => { - try { - this.showApiScanModal = false; - - await this.startApiScan.perform(); - - triggerAnalytics( - 'feature', - ENV.csb['runAPIScan'] as CsbAnalyticsFeatureData - ); - - this.notify.success(this.tStartingApiScan); - } catch (e) { - const err = e as AdapterError; - - let errMsg = this.tPleaseTryAgain; - - if (err.errors && err.errors.length) { - errMsg = err.errors[0]?.detail || errMsg; - } else if (err.payload && err.payload.detail) { - errMsg = err.payload.detail; - } else if (err.message) { - errMsg = err.message; - } - - this.notify.error(errMsg); - } - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::ScanActionsOld::ApiScan': typeof FileDetailsScanActionsOldApiScanComponent; - 'file-details/scan-actions-old/api-scan': typeof FileDetailsScanActionsOldApiScanComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/index.hbs b/app/components/file-details/scan-actions-old/index.hbs deleted file mode 100644 index 81692b8021..0000000000 --- a/app/components/file-details/scan-actions-old/index.hbs +++ /dev/null @@ -1,92 +0,0 @@ -
- - - {{t 'scanTypes'}} - - - {{#unless @file.isActive}} - - - - {{/unless}} - - - - - - - - {{t 'staticScan'}} - - - - - - - - {{t 'dynamicScan'}} - - - - - - {{#if this.isAPIScanEnabled}} - - - {{t 'apiScan'}} - - - - - {{/if}} - - {{#unless this.isManualScanDisabled}} - - - {{t 'manualScan'}} - - - - - {{/unless}} - -
\ No newline at end of file diff --git a/app/components/file-details/scan-actions-old/index.scss b/app/components/file-details/scan-actions-old/index.scss deleted file mode 100644 index 4b990614dc..0000000000 --- a/app/components/file-details/scan-actions-old/index.scss +++ /dev/null @@ -1,10 +0,0 @@ -.scan-actions-root { - width: 100%; - border: 1px solid var(--file-details-scan-actions-old-border-color); - background-color: var(--file-details-scan-actions-old-background-color); - box-sizing: border-box; - - .scan-actions-header { - padding: 0.75em 1.5em; - } -} diff --git a/app/components/file-details/scan-actions-old/index.ts b/app/components/file-details/scan-actions-old/index.ts deleted file mode 100644 index 373791352d..0000000000 --- a/app/components/file-details/scan-actions-old/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { inject as service } from '@ember/service'; -import Component from '@glimmer/component'; - -import FileModel from 'irene/models/file'; -import OrganizationService from 'irene/services/organization'; - -export interface FileDetailsScanActionsOldSignature { - Args: { - file: FileModel; - }; -} - -export default class FileDetailsScanActionsOldComponent extends Component { - @service declare organization: OrganizationService; - - get isManualScanDisabled() { - return !this.args.file.project.get('isManualScanAvailable'); - } - - get isAPIScanEnabled() { - return this.args.file.project.get('isAPIScanEnabled'); - } -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::ScanActionsOld': typeof FileDetailsScanActionsOldComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.hbs b/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.hbs deleted file mode 100644 index 5fca30eb5b..0000000000 --- a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.hbs +++ /dev/null @@ -1,91 +0,0 @@ - -
- - {{t 'modalCard.manual.appEnv'}} - - -
- - {{t (app-environment aks.value)}} - -
-
- -
- - {{t 'minOSVersion'}} - - -
- -
-
- -
- - {{t 'modalCard.manual.appQuestion1'}} - - -
- - {{t (app-action aks.value)}} - -
-
- -
- - {{t 'modalCard.manual.poc'}} - - -
- - - -
-
-
\ No newline at end of file diff --git a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.scss b/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.scss deleted file mode 100644 index 1bada3b3a6..0000000000 --- a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.scss +++ /dev/null @@ -1,17 +0,0 @@ -.basic-info-group { - width: 100%; - display: flex; - align-items: center; - justify-content: space-between; - gap: 1.5em; - box-sizing: border-box; - - .basic-info-label { - flex: 1; - } - - .basic-info-input-container { - flex: 1; - max-width: 200px; - } -} diff --git a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.ts b/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.ts deleted file mode 100644 index a9c1a132b9..0000000000 --- a/app/components/file-details/scan-actions-old/manual-scan/basic-info/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -import Component from '@glimmer/component'; -import FileModel from 'irene/models/file'; -import ENUMS from 'irene/enums'; -import ManualscanModel from 'irene/models/manualscan'; -import { action } from '@ember/object'; - -export interface FileDetailsScanActionsOldManualScanBasicInfoSignature { - Args: { - file: FileModel; - manualscan: ManualscanModel | null; - }; -} - -export default class FileDetailsScanActionsOldManualScanBasicInfoComponent extends Component { - get environments() { - return ENUMS.APP_ENV.CHOICES.slice(0, -1); - } - - get selectedAppEnvironment() { - return this.environments.find( - (it) => it.value === this.args.manualscan?.filteredAppEnv - ); - } - - get appActions() { - return ENUMS.APP_ACTION.CHOICES.slice(0, -1); - } - - get selectedAppAction() { - return this.appActions.find( - (it) => it.value === this.args.manualscan?.filteredAppAction - ); - } - - @action - selectAppEnvironment({ value }: { value: string }) { - this.args.manualscan?.set('appEnv', value); - } - - @action - handleAppActionChange({ value }: { value: string }) { - const appAction = parseInt(value); - - this.args.manualscan?.set('appAction', appAction); - } -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::ScanActionsOld::ManualScan::BasicInfo': typeof FileDetailsScanActionsOldManualScanBasicInfoComponent; - 'file-details/scan-actions-old/manual-scan/basic-info': typeof FileDetailsScanActionsOldManualScanBasicInfoComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/manual-scan/index.hbs b/app/components/file-details/scan-actions-old/manual-scan/index.hbs deleted file mode 100644 index b9deb24fe1..0000000000 --- a/app/components/file-details/scan-actions-old/manual-scan/index.hbs +++ /dev/null @@ -1,123 +0,0 @@ -
- {{#if @file.isManualRequested}} - - <:leftIcon> - - - - <:default> - {{this.manualScanStatusText}} - - - {{else}} - - <:leftIcon> - - - - <:default>{{t 'start'}} - - {{/if}} - - {{#if this.showManualScanModal}} - - <:default> -
- - {{t 'modalCard.manual.description'}} - - - - {{#each this.manualScanFormSections as |msf|}} - - <:content> - {{#let (component msf.contentComponent) as |Component|}} - - {{/let}} - - - {{/each}} - - -
- - {{t 'modalCard.manual.additionalComments'}} - - -