diff --git a/app/adapters/device-preference.ts b/app/adapters/device-preference.ts deleted file mode 100644 index bac35352d..000000000 --- a/app/adapters/device-preference.ts +++ /dev/null @@ -1,14 +0,0 @@ -import commondrf from './commondrf'; - -export default class DevicePreferenceAdapter extends commondrf { - urlForQueryRecord(q: { id: string }) { - const url = `${this.namespace}/profiles/${q.id}/device_preference`; - return this.buildURLFromBase(url); - } -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'device-preference': DevicePreferenceAdapter; - } -} diff --git a/app/adapters/dynamicscan-mode.ts b/app/adapters/dynamicscan-mode.ts deleted file mode 100644 index e96e47031..000000000 --- a/app/adapters/dynamicscan-mode.ts +++ /dev/null @@ -1,15 +0,0 @@ -import commondrf from './commondrf'; - -export default class DynamicscanModeAdapter extends commondrf { - urlForQueryRecord(q: { id: string }) { - const url = `${this.namespace}/profiles/${q.id}/dynamicscan_mode`; - - return this.buildURLFromBase(url); - } -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'dynamicscan-mode': DynamicscanModeAdapter; - } -} diff --git a/app/adapters/dynamicscan-old.ts b/app/adapters/dynamicscan-old.ts deleted file mode 100644 index 55cd0af69..000000000 --- a/app/adapters/dynamicscan-old.ts +++ /dev/null @@ -1,31 +0,0 @@ -import DynamicscanOldModel from 'irene/models/dynamicscan-old'; -import commondrf from './commondrf'; - -export default class DynamicscanOldAdapter extends commondrf { - _buildURL(_: string | null, id: string | number) { - const baseurl = `${this.namespace}/dynamicscan`; - - if (id) { - return this.buildURLFromBase(`${baseurl}/${encodeURIComponent(id)}`); - } - - return this.buildURLFromBase(baseurl); - } - - extendTime(snapshot: DynamicscanOldModel, time: number) { - const id = snapshot.id; - const modelName = 'dynamicscan'; - - const url = this.buildURL(modelName, id) + '/extend'; - - return this.ajax(url, 'POST', { - data: { time }, - }); - } -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'dynamicscan-old': DynamicscanOldAdapter; - } -} diff --git a/app/adapters/project-available-device.ts b/app/adapters/project-available-device.ts deleted file mode 100644 index 6ea05f001..000000000 --- a/app/adapters/project-available-device.ts +++ /dev/null @@ -1,64 +0,0 @@ -import commondrf from './commondrf'; - -interface ProjectAvailableDevicesQueryObj { - projectId: string | number; - manualDevices?: boolean; -} -export default class ProjectAvailableDeviceAdapter extends commondrf { - _buildURL( - modelName: string | number, - id: string | number, - namespace = this.namespace - ) { - const baseURL = `${namespace}/projects`; - - if (id) { - return this.buildURLFromBase(`${baseURL}/${encodeURIComponent(id)}`); - } - - return this.buildURLFromBase(baseURL); - } - - _buildNestedURL( - modelName: string | number, - query: ProjectAvailableDevicesQueryObj - ) { - let url = ''; - - if (query.manualDevices) { - url = this.getAvailableManualDevicesURL(query); - - delete query.manualDevices; - } else { - const projectURL = this._buildURL(modelName, query.projectId); - url = [projectURL, 'available-devices'].join('/'); - } - - return url; - } - - urlForQuery( - query: ProjectAvailableDevicesQueryObj, - modelName: K - ) { - return this._buildNestedURL(modelName, query); - } - - getAvailableManualDevicesURL(query: ProjectAvailableDevicesQueryObj) { - const projectURL = this._buildURL( - 'project', - query.projectId, - this.namespace_v2 - ); - - const url = projectURL + '/available_manual_devices'; - - return url; - } -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'project-available-device': ProjectAvailableDeviceAdapter; - } -} diff --git a/app/components/file-details/dynamic-scan/action/drawer/automated-dast/index.ts b/app/components/file-details/dynamic-scan/action/drawer/automated-dast/index.ts index fab532018..a34d17ef2 100644 --- a/app/components/file-details/dynamic-scan/action/drawer/automated-dast/index.ts +++ b/app/components/file-details/dynamic-scan/action/drawer/automated-dast/index.ts @@ -138,7 +138,7 @@ export default class FileDetailsDynamicScanDrawerAutomatedDastComponent extends value: this.intl.t( deviceType([ this.automatedDastDevicePreferences?.dsAutomatedDeviceType ?? - ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE, + ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE, ]) ), hidden: this.isAnyDevicePrefSelected, diff --git a/app/components/file-details/dynamic-scan/action/drawer/device-pref-table/type/index.ts b/app/components/file-details/dynamic-scan/action/drawer/device-pref-table/type/index.ts index d8dc589e9..b791ce339 100644 --- a/app/components/file-details/dynamic-scan/action/drawer/device-pref-table/type/index.ts +++ b/app/components/file-details/dynamic-scan/action/drawer/device-pref-table/type/index.ts @@ -10,8 +10,8 @@ export interface FileDetailsDynamicScanDrawerDevicePrefTableTypeSignature { } export default class FileDetailsDynamicScanDrawerDevicePrefTableTypeComponent extends Component { - isPhoneDevice = ENUMS.DEVICE_TYPE.PHONE_REQUIRED; - isTabletDevice = ENUMS.DEVICE_TYPE.TABLET_REQUIRED; + isPhoneDevice = ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED; + isTabletDevice = ENUMS.DS_DEVICE_TYPE.TABLET_REQUIRED; } declare module '@glint/environment-ember-loose/registry' { diff --git a/app/components/file-details/dynamic-scan/drawer-old/index.hbs b/app/components/file-details/dynamic-scan/drawer-old/index.hbs deleted file mode 100644 index beaaf110e..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/index.hbs +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - {{t 'modalCard.dynamicScan.title'}} - - - - - - - -
- - - - - {{t 'modalCard.dynamicScan.warning'}} - - - - {{#if @file.minOsVersion}} -
- - {{t 'modalCard.dynamicScan.deviceRequirements'}} - - - - {{#each this.deviceRequirements as |dr|}} - - - {{dr.type}} - - - - - {{dr.boldValue}} - - - {{dr.value}} - - - {{/each}} - -
- {{/if}} - -
- -
- - {{#unless @file.showScheduleAutomatedDynamicScan}} - - {{t 'note'}}: - {{t 'modalCard.dynamicScan.deviceSettingsWarning'}} - - {{/unless}} - -
- -
- -
- - - - - - - {{#if this.showApiScanSettings}} -
- - {{t 'modalCard.dynamicScan.apiScanDescription' htmlSafe=true}} - - - - - -
- {{/if}} - - {{#if @file.showScheduleAutomatedDynamicScan}} -
- - - {{t 'dynamicScanAutomation'}} - - - - <:icon> - - - - - - - {{t 'scheduleDynamicscanDesc'}} - - - - - <:leftIcon> - {{#if this.scheduleDynamicScan.isRunning}} - - {{else}} - - {{/if}} - - - <:default> - {{t 'scheduleDynamicscan'}} - - - -
- {{/if}} -
-
-
- - - - {{t 'cancel'}} - - - - {{t 'modalCard.dynamicScan.start'}} - - -
-
\ 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 deleted file mode 100644 index 8f439f493..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/index.scss +++ /dev/null @@ -1,37 +0,0 @@ -.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 { - 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/file-details/dynamic-scan/drawer-old/index.ts b/app/components/file-details/dynamic-scan/drawer-old/index.ts deleted file mode 100644 index 3e38e382a..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/index.ts +++ /dev/null @@ -1,241 +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 IntlService from 'ember-intl/services/intl'; -import Store from '@ember-data/store'; -import { tracked } from '@glimmer/tracking'; - -import ENV from 'irene/config/environment'; -import ENUMS from 'irene/enums'; -import triggerAnalytics from 'irene/utils/trigger-analytics'; -import type FileModel from 'irene/models/file'; -import type { DevicePreferenceContext } from 'irene/components/project-preferences-old/provider'; -import type IreneAjaxService from 'irene/services/ajax'; - -export interface FileDetailsDynamicScanDrawerOldSignature { - Args: { - onClose: () => void; - pollDynamicStatus: () => void; - file: FileModel; - dpContext: DevicePreferenceContext; - }; -} - -export default class FileDetailsDynamicScanDrawerOldComponent extends Component { - @service declare intl: IntlService; - @service declare ajax: IreneAjaxService; - @service declare store: Store; - @service('browser/window') declare window: Window; - @service('notifications') declare notify: NotificationService; - - @tracked showApiScanSettings = false; - @tracked isApiScanEnabled = false; - - get tStartingScan() { - return this.intl.t('startingScan'); - } - - get devicePrefContext() { - return this.args.dpContext; - } - - get tScheduleDynamicscanSuccess() { - return this.intl.t('scheduleDynamicscanSuccess'); - } - - get tPleaseTryAgain() { - return this.intl.t('pleaseTryAgain'); - } - - get projectPlatform() { - return this.args.file.project.get('platform'); - } - - get profileId() { - return this.args.file.profile.get('id'); - } - - get deviceRequirements() { - const file = this.args.file; - - return [ - { - type: this.intl.t('modalCard.dynamicScan.osVersion'), - boldValue: `${file.project.get('platformDisplay')} ${ - file.minOsVersion - } `, - value: this.intl.t('modalCard.dynamicScan.orAbove'), - }, - file.supportedCpuArchitectures && { - type: this.intl.t('modalCard.dynamicScan.processorArchitecture'), - boldValue: file.supportedCpuArchitectures, - }, - file.supportedDeviceTypes && { - type: this.intl.t('modalCard.dynamicScan.deviceTypes'), - boldValue: file.supportedDeviceTypes, - }, - ].filter(Boolean) as { type: string; boldValue: string; value?: string }[]; - } - - @action - enableApiScan(event: Event, checked: boolean) { - this.showApiScanSettings = checked; - this.isApiScanEnabled = !!checked; - } - - startDynamicScan = task(async () => { - try { - const data = { - isApiScanEnabled: this.isApiScanEnabled === true, - }; - - const file = this.args.file; - const dynamicUrl = [ENV.endpoints['dynamic'], file.id].join('/'); - - await this.ajax.put(dynamicUrl, { data }); - - this.args.onClose(); - - file.setBootingStatus(); - - this.args.pollDynamicStatus(); - - this.notify.success(this.tStartingScan); - } catch (error) { - const err = error as AdapterError; - let errMsg = this.tPleaseTryAgain; - - if (err.errors && err.errors.length) { - errMsg = err.errors[0]?.detail || errMsg; - } else if (err.payload.message) { - errMsg = err.payload.message; - } else if (err.message) { - errMsg = err.message; - } - - this.notify.error(errMsg); - - this.args.file.setDynamicStatusNone(); - } - }); - - scheduleDynamicScan = task({ drop: true }, async () => { - try { - const file = this.args.file; - - const scheduleAutomationUrl = [ - ENV.endpoints['dynamic'], - file.id, - ENV.endpoints['scheduleDynamicscanAutomation'], - ].join('/'); - - await this.ajax.post(scheduleAutomationUrl, { - data: { id: file.id }, - }); - - file.setInQueueStatus(); - - this.args.onClose(); - - this.notify.success(this.tScheduleDynamicscanSuccess, { - clearDuration: 5000, - }); - } catch (e) { - const err = e as AdapterError; - let errMsg = this.tPleaseTryAgain; - - if (err.payload) { - Object.keys(err.payload).forEach((p) => { - errMsg = err.payload[p]; - if (typeof errMsg !== 'string') { - errMsg = err.payload[p][0]; - } - - this.notify.error(errMsg); - }); - - return; - } else if (err.errors && err.errors.length) { - errMsg = err.errors[0]?.detail || errMsg; - } else if (err.message) { - errMsg = err.message; - } - - this.notify.error(errMsg); - } - }); - - get currentDevicePref() { - return { - device_type: this.devicePrefContext.selectedDeviceType?.value, - platform_version: this.devicePrefContext.selectedVersion, - }; - } - - get deviceTypeIsAny() { - return ( - this.currentDevicePref.device_type === ENUMS.DEVICE_TYPE.NO_PREFERENCE - ); - } - - get devicePlatformVersionIsAny() { - return this.currentDevicePref.platform_version === '0'; - } - - @action - pickRandomItemFromList(list: T[]) { - return list[Math.floor(Math.random() * list.length)]; // NOSONAR - } - - @action - runDynamicScan() { - if (this.deviceTypeIsAny || this.devicePlatformVersionIsAny) { - this.saveDevicePrefToLocalStorage.perform(); - } - - triggerAnalytics( - 'feature', - ENV.csb['runDynamicScan'] as CsbAnalyticsFeatureData - ); - - this.startDynamicScan.perform(); - } - - saveDevicePrefToLocalStorage = task(async () => { - const modifiedDevicePref = { ...this.currentDevicePref }; - - if (this.deviceTypeIsAny) { - modifiedDevicePref.device_type = ENUMS.DEVICE_TYPE.PHONE_REQUIRED; - } - - if ( - this.devicePlatformVersionIsAny && - this.devicePrefContext.filteredDevices?.length - ) { - const randomDevice = this.pickRandomItemFromList( - this.devicePrefContext.filteredDevices - ); - - modifiedDevicePref.platform_version = - randomDevice?.platformVersion as string; - } - - this.window.localStorage.setItem( - 'actualDevicePrefData', - JSON.stringify({ ...this.currentDevicePref, file_id: this.args.file.id }) - ); - - this.devicePrefContext.updateDevicePref( - modifiedDevicePref.device_type, - modifiedDevicePref.platform_version, - true - ); - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::DynamicScan::DrawerOld': typeof FileDetailsDynamicScanDrawerOldComponent; - } -} diff --git a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.hbs b/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.hbs deleted file mode 100644 index 7a8c4cfbb..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.hbs +++ /dev/null @@ -1,51 +0,0 @@ -{{#if this.proxy.hasProxyUrl}} - - - - - {{t 'enable'}} - {{t 'proxySettingsTitle'}} - - - - - - - {{t 'edit'}} - - - - - {{t 'proxySettingsRouteVia'}} - {{this.proxy.host}}:{{this.proxy.port}} - - -{{/if}} \ No newline at end of file diff --git a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.scss b/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.scss deleted file mode 100644 index 4ed742f9b..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.scss +++ /dev/null @@ -1,11 +0,0 @@ -.bordered-box { - border: 1px solid - var(--file-details-dynamic-scan-drawer-old-proxy-settings-view-border-color); - padding: 1.25em; - box-sizing: border-box; -} - -.api-proxy-toggle { - margin-left: 0; - margin-right: 0; -} diff --git a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.ts b/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.ts deleted file mode 100644 index bf5c9c49d..000000000 --- a/app/components/file-details/dynamic-scan/drawer-old/proxy-settings-view/index.ts +++ /dev/null @@ -1,85 +0,0 @@ -import Component from '@glimmer/component'; -import ENV from 'irene/config/environment'; -import triggerAnalytics from 'irene/utils/trigger-analytics'; -import { inject as service } from '@ember/service'; -import { task } from 'ember-concurrency'; -import { tracked } from '@glimmer/tracking'; -import type IntlService from 'ember-intl/services/intl'; -import type Store from '@ember-data/store'; -import type { AsyncBelongsTo } from '@ember-data/model'; - -import type ProxySettingModel from 'irene/models/proxy-setting'; -import type ProfileModel from 'irene/models/profile'; -import type ProjectModel from 'irene/models/project'; -import parseError from 'irene/utils/parse-error'; - -export interface FileDetailsDynamicScanDrawerOldProxySettingsViewSignature { - Args: { - profile: AsyncBelongsTo; - project: AsyncBelongsTo; - }; -} - -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: FileDetailsDynamicScanDrawerOldProxySettingsViewSignature['Args'] - ) { - super(owner, args); - - this.fetchProxySetting.perform(); - } - - get projectId() { - return this.args.project.get('id'); - } - - fetchProxySetting = task(async () => { - try { - const profileId = this.args.profile.get('id'); - - if (profileId) { - this.proxy = await this.store.findRecord('proxy-setting', profileId); - } - } catch (error) { - this.notify.error(parseError(error, this.intl.t('somethingWentWrong'))); - } - }); - - /* Proxy enable or disable */ - toggleProxy = task(async (event) => { - try { - const enabled = event.target.checked; - - this.proxy?.set('enabled', enabled); - - await this.proxy?.save(); - - const statusText = enabled ? this.intl.t('on') : this.intl.t('off'); - - this.notify.info( - `${this.intl.t('proxyTurned')} ${statusText.toUpperCase()}` - ); - - const analyticsData = enabled - ? ENV.csb['enableProxy'] - : ENV.csb['disableProxy']; - - triggerAnalytics('feature', analyticsData as CsbAnalyticsFeatureData); - } catch (error) { - this.notify.error(parseError(error, this.intl.t('pleaseTryAgain'))); - } - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::DynamicScan::DrawerOld::ProxySettingsView': typeof FileDetailsDynamicScanDrawerOldProxySettingsViewComponent; - } -} diff --git a/app/components/file-details/dynamic-scan/expiry-old/index.hbs b/app/components/file-details/dynamic-scan/expiry-old/index.hbs deleted file mode 100644 index 922b7627b..000000000 --- a/app/components/file-details/dynamic-scan/expiry-old/index.hbs +++ /dev/null @@ -1,69 +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/file-details/dynamic-scan/expiry-old/index.scss b/app/components/file-details/dynamic-scan/expiry-old/index.scss deleted file mode 100644 index 0cc114d6e..000000000 --- a/app/components/file-details/dynamic-scan/expiry-old/index.scss +++ /dev/null @@ -1,26 +0,0 @@ -.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/file-details/dynamic-scan/expiry-old/index.ts b/app/components/file-details/dynamic-scan/expiry-old/index.ts deleted file mode 100644 index d47c002f2..000000000 --- a/app/components/file-details/dynamic-scan/expiry-old/index.ts +++ /dev/null @@ -1,158 +0,0 @@ -import Component from '@glimmer/component'; -import { action } from '@ember/object'; -import { tracked } from '@glimmer/tracking'; -import { inject as service } from '@ember/service'; -import { task, timeout } from 'ember-concurrency'; -import dayjs from 'dayjs'; -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 DynamicscanOldModel from 'irene/models/dynamicscan-old'; -import ENV from 'irene/config/environment'; -import parseError from 'irene/utils/parse-error'; - -export interface FileDetailsDynamicScanExpiryOldSignature { - Args: { - file: FileModel; - }; -} - -export default class FileDetailsDynamicScanExpiryOldComponent extends Component { - @service('notifications') declare notify: NotificationService; - @service declare store: Store; - @service declare datetime: DatetimeService; - - @tracked dynamicscan: DynamicscanOldModel | null = null; - @tracked durationRemaining: null | Duration = null; - @tracked extendBtnAnchorRef: HTMLElement | null = null; - - constructor( - owner: unknown, - args: FileDetailsDynamicScanExpiryOldSignature['Args'] - ) { - super(owner, args); - - this.fetchDynamicscan.perform(); - } - - get extendTimeOptions() { - return [5, 15, 30]; - } - - get canExtend() { - const duration = this.durationRemaining; - - if (!duration) { - return false; - } - - return duration.asMinutes() < 15; - } - - get timeRemaining() { - const duration = this.durationRemaining; - - if (!duration) { - return { - seconds: '00', - minutes: '00', - }; - } - - return { - seconds: ('0' + duration.seconds()).slice(-2), - minutes: ('0' + Math.floor(duration.asMinutes())).slice(-2), - }; - } - - @action - setScanDuration(expiresOn: Date | null) { - if (!expiresOn) { - this.durationRemaining = null; - - return; - } - - const mExpiresOn = dayjs(expiresOn); - const mNow = dayjs(Date.now()); - const duration = this.datetime.duration(mExpiresOn.diff(mNow)); - - this.durationRemaining = duration; - } - - @action - handleExtendTimeClick(event: MouseEvent) { - this.extendBtnAnchorRef = event.currentTarget as HTMLElement; - } - - @action - handleExtendTimeMenuClose() { - this.extendBtnAnchorRef = null; - } - - clock = task(async () => { - while (Number(this.durationRemaining?.asSeconds()) > -1) { - if (ENV.environment === 'test') { - break; - } - - const expiresOn = this.dynamicscan ? this.dynamicscan.expiresOn : null; - - this.setScanDuration(expiresOn); - - await timeout(1000); - } - }); - - extendtime = task(async (time: number) => { - const dynamicscan = this.dynamicscan; - - if (!dynamicscan) { - return; - } - - this.handleExtendTimeMenuClose(); - - try { - await dynamicscan.extendTime(time); - } catch (error) { - const err = error as AdapterError; - - if (err.errors && err.errors[0]?.detail) { - this.notify.error(err.errors[0].detail); - - return; - } - - throw err; - } - - await this.fetchDynamicscan.perform(); - }); - - 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; - - // Necessary to ensure correct time is updated in store cache before clock is started - // If not reloaded, timer starts with cached timer before store updates record with new details - await dynamicscan?.reload(); - - this.dynamicscan = dynamicscan; - - this.setScanDuration(expiresOn); - this.clock.perform(); - } catch (error) { - this.notify.error(parseError(error)); - } - }); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'FileDetails::DynamicScan::ExpiryOld': typeof FileDetailsDynamicScanExpiryOldComponent; - } -} diff --git a/app/components/file-details/scan-actions-old/manual-scan/index.scss b/app/components/file-details/scan-actions-old/manual-scan/index.scss deleted file mode 100644 index 6f9e591d4..000000000 --- a/app/components/file-details/scan-actions-old/manual-scan/index.scss +++ /dev/null @@ -1,16 +0,0 @@ -.textarea-input { - border: 1px solid - var( - --file-details-scan-actions-old-manual-scan-textarea-border-color - ); - border-radius: var( - --file-details-scan-actions-old-manual-scan-textarea-border-radius - ); - color: var(--file-details-scan-actions-old-manual-scan-textarea-color); - display: inline-flex; - justify-content: flex-start; - align-items: center; - padding: 0.75em; - max-width: 100%; - width: 100%; -} \ No newline at end of file diff --git a/app/components/project-preferences-old/device-preference/index.hbs b/app/components/project-preferences-old/device-preference/index.hbs deleted file mode 100644 index 1a74d33de..000000000 --- a/app/components/project-preferences-old/device-preference/index.hbs +++ /dev/null @@ -1,74 +0,0 @@ - - {{#if (has-block 'title')}} - {{yield to='title'}} - {{else}} - - {{t 'devicePreferences'}} - - {{/if}} - - - {{t 'otherTemplates.selectPreferredDevice'}} - - - - -
- - {{t (device-type aks.value)}} - -
- -
- - {{#if (eq version '0')}} - {{t 'anyVersion'}} - {{else}} - {{version}} - {{/if}} - -
-
- -{{#if this.isPreferredDeviceNotAvailable}} - - - - - {{#if this.minOsVersionUnsupported}} - {{t 'modalCard.dynamicScan.minOSVersionUnsupported'}} - {{else if this.isAllDevicesAllocated}} - {{t 'modalCard.dynamicScan.allDevicesAreAllocated'}} - {{else}} - {{t 'modalCard.dynamicScan.preferredDeviceNotAvailable'}} - {{/if}} - - -{{/if}} \ No newline at end of file diff --git a/app/components/project-preferences-old/device-preference/index.ts b/app/components/project-preferences-old/device-preference/index.ts deleted file mode 100644 index 59531dc82..000000000 --- a/app/components/project-preferences-old/device-preference/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import Component from '@glimmer/component'; - -import ENUMS from 'irene/enums'; -import type FileModel from 'irene/models/file'; -import type { DevicePreferenceContext } from '../provider'; - -export interface ProjectPreferencesOldDevicePreferenceSignature { - Args: { - file?: FileModel | null; - dpContext: DevicePreferenceContext; - }; - Blocks: { - title: []; - }; -} - -export default class ProjectPreferencesOldDevicePreferenceComponent extends Component { - // TODO: Remove when information is provided from the backend - maxSupportedIOSDeviceVersion = '17'; - maxSupportedAndroidDeviceVersion = '14'; - - get isPreferredDeviceNotAvailable() { - return this.args.dpContext.isPreferredDeviceAvailable === false; - } - - get noDevicePlatformVersions() { - return this.args.dpContext.devicePlatformVersions.length === 1; - } - - get minOsVersionUnsupported() { - const file = this.args.file; - const project = file?.get('project'); - - if (project) { - const platform = project.get('platform'); - - const maxSupportedDeviceVersion = - platform === ENUMS.PLATFORM.IOS - ? this.maxSupportedIOSDeviceVersion - : this.maxSupportedAndroidDeviceVersion; - - return ( - this.noDevicePlatformVersions && - this.args.dpContext.compareVersions( - maxSupportedDeviceVersion, - file?.get('minOsVersion') as string - ) <= 0 - ); - } - - return false; - } - - get isAllDevicesAllocated() { - return this.isPreferredDeviceNotAvailable && this.noDevicePlatformVersions; - } -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'ProjectPreferencesOld::DevicePreference': typeof ProjectPreferencesOldDevicePreferenceComponent; - 'project-preferences-old/device-preference': typeof ProjectPreferencesOldDevicePreferenceComponent; - } -} diff --git a/app/components/project-preferences-old/index.hbs b/app/components/project-preferences-old/index.hbs deleted file mode 100644 index 5dfda2f85..000000000 --- a/app/components/project-preferences-old/index.hbs +++ /dev/null @@ -1,16 +0,0 @@ - - {{yield - (hash - DevicePreferenceComponent=(component - 'project-preferences-old/device-preference' - file=this.projectLastFile - dpContext=dpContext - ) - ) - }} - \ No newline at end of file diff --git a/app/components/project-preferences-old/index.ts b/app/components/project-preferences-old/index.ts deleted file mode 100644 index 177e53103..000000000 --- a/app/components/project-preferences-old/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Component from '@glimmer/component'; -import { WithBoundArgs } from '@glint/template'; - -import ProjectModel from 'irene/models/project'; -import ProjectPreferencesDevicePreferenceComponent from './device-preference'; -import FileModel from 'irene/models/file'; - -export interface ProjectPreferencesOldSignature { - Args: { - file?: FileModel | null; - project?: ProjectModel | null; - profileId?: number | string; - platform?: number; - }; - Blocks: { - default: [ - { - DevicePreferenceComponent: WithBoundArgs< - typeof ProjectPreferencesDevicePreferenceComponent, - 'dpContext' - >; - }, - ]; - }; -} - -export default class ProjectPreferencesOldComponent extends Component { - get projectLastFile() { - return this.args.project?.get('lastFile'); - } -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - ProjectPreferencesOld: typeof ProjectPreferencesOldComponent; - } -} diff --git a/app/components/project-preferences-old/provider/index.hbs b/app/components/project-preferences-old/provider/index.hbs deleted file mode 100644 index 5fac49113..000000000 --- a/app/components/project-preferences-old/provider/index.hbs +++ /dev/null @@ -1,14 +0,0 @@ -{{yield - (hash - filteredDevices=this.filteredDevices - deviceTypes=this.filteredDeviceTypes - selectedDeviceType=this.selectedDeviceType - handleSelectDeviceType=this.handleSelectDeviceType - selectedVersion=this.selectedVersion - devicePlatformVersions=this.devicePlatformVersionOptions - handleSelectVersion=this.handleSelectVersion - isPreferredDeviceAvailable=this.isPreferredDeviceAvailable - updateDevicePref=this.updateDevicePref - compareVersions=this.compareVersions - ) -}} \ No newline at end of file diff --git a/app/components/project-preferences-old/provider/index.ts b/app/components/project-preferences-old/provider/index.ts deleted file mode 100644 index 37b069857..000000000 --- a/app/components/project-preferences-old/provider/index.ts +++ /dev/null @@ -1,352 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; -import IntlService from 'ember-intl/services/intl'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import Store from '@ember-data/store'; -import { task } from 'ember-concurrency'; - -// eslint-disable-next-line ember/use-ember-data-rfc-395-imports -import DS from 'ember-data'; - -import ENUMS from 'irene/enums'; -import ENV from 'irene/config/environment'; -import ProjectModel from 'irene/models/project'; -import DevicePreferenceModel from 'irene/models/device-preference'; -import ProjectAvailableDeviceModel from 'irene/models/project-available-device'; -import FileModel from 'irene/models/file'; -import type IreneAjaxService from 'irene/services/ajax'; - -export interface DevicePreferenceContext { - filteredDevices?: ProjectAvailableDeviceModel[]; - deviceTypes: DeviceType[]; - selectedDeviceType?: DeviceType; - handleSelectDeviceType: (deviceType: DeviceType) => void; - selectedVersion: string; - devicePlatformVersions: string[]; - handleSelectVersion: (version: string) => void; - isPreferredDeviceAvailable: boolean | null; - - updateDevicePref( - device_type: string | number | undefined, - platform_version: string, - silentNotifications?: boolean - ): void; - - compareVersions(v1: string, v2: string): number; -} - -export interface ProjectPreferencesOldProviderSignature { - Args: { - file?: FileModel | null; - project?: ProjectModel | null; - profileId?: number | string; - }; - Blocks: { - default: [DevicePreferenceContext]; - }; -} - -type EnumObject = { key: string; value: number | string }; -type DeviceType = EnumObject; - -export default class ProjectPreferencesOldProviderComponent extends Component { - @service declare intl: IntlService; - @service declare ajax: IreneAjaxService; - @service('notifications') declare notify: NotificationService; - @service declare store: Store; - - @tracked selectedVersion = '0'; - - @tracked selectedDeviceType?: DeviceType; - - @tracked deviceTypes = ENUMS.DEVICE_TYPE.CHOICES; - @tracked devicePreference?: DevicePreferenceModel; - - @tracked - devices: DS.AdapterPopulatedRecordArray | null = - null; - - constructor( - owner: unknown, - args: ProjectPreferencesOldProviderSignature['Args'] - ) { - super(owner, args); - - this.fetchDevicePreference.perform(); - this.fetchDevices.perform(); - } - - fetchDevicePreference = task(async () => { - try { - this.devicePreference = await this.store.queryRecord( - 'device-preference', - { - id: this.args.profileId, - } - ); - - this.selectedDeviceType = this.deviceTypes.find( - (it) => it.value === this.devicePreference?.deviceType - ); - - this.selectedVersion = this.devicePreference.platformVersion; - } catch (error) { - this.notify.error(this.intl.t('errorFetchingDevicePreferences')); - } - }); - - fetchDevices = task(async () => { - try { - this.devices = await this.store.query('project-available-device', { - projectId: this.args.project?.get('id'), - }); - } catch (error) { - this.notify.error(this.intl.t('errorFetchingDevices')); - } - }); - - get tAnyVersion() { - return this.intl.t('anyVersion'); - } - - get filteredDeviceTypes() { - const supportedTypes = - this.args.file?.supportedDeviceTypes || - this.args.project?.get('lastFile')?.get('supportedDeviceTypes'); - - const platform = this.args.project?.get('platform'); - - return this.deviceTypes.filter((type) => { - switch (type.value) { - // Always filter out unknown device type - case ENUMS.DEVICE_TYPE.UNKNOWN: - return false; - - // Always show "Any Device" option - case ENUMS.DEVICE_TYPE.NO_PREFERENCE: - return true; - - // For iOS, show tablet option only if iPad is supported - case ENUMS.DEVICE_TYPE.TABLET_REQUIRED: - return supportedTypes?.includes('iPad'); - - case ENUMS.DEVICE_TYPE.PHONE_REQUIRED: - // For Android, only show phone options - if (ENUMS.PLATFORM.ANDROID === platform) { - return true; - } - - // For iOS, show phone option only if iPhone is supported - return supportedTypes?.includes('iPhone'); - - default: - return true; - } - }); - } - - get availableDevices() { - return this.devices?.filter( - (d) => d.platform === this.args.project?.get('platform') - ); - } - - get filteredDevices() { - return this.availableDevices?.filter((device) => { - switch (this.selectedDeviceType?.value) { - case ENUMS.DEVICE_TYPE.NO_PREFERENCE: - return true; - - case ENUMS.DEVICE_TYPE.TABLET_REQUIRED: - return device.isTablet; - - case ENUMS.DEVICE_TYPE.PHONE_REQUIRED: - return !device.isTablet; - - default: - return true; - } - }); - } - - get uniqueDevices() { - const devices = this.filteredDevices?.uniqBy('platformVersion'); - - const minOsVersion = - this.args.file?.minOsVersion || - this.args.project?.get('lastFile')?.get('minOsVersion'); - - // Sort the unique devices versions in descending order - const sortedDevices = devices?.sort((a, b) => - this.compareVersions(b.platformVersion, a.platformVersion) - ); - - if (!minOsVersion && sortedDevices) { - return [...sortedDevices]; - } - - return sortedDevices?.filter((d) => { - return ( - this.compareVersions(d.platformVersion, minOsVersion as string) >= 0 - ); - }); - } - - get devicePlatformVersionOptions() { - return ['0', ...(this.uniqueDevices?.map((d) => d.platformVersion) || [])]; - } - - get isPreferredDeviceAvailable() { - // check whether preferences & devices are resolved - if (this.devicePreference && this.uniqueDevices) { - const deviceType = Number(this.devicePreference.deviceType); - const version = this.devicePreference.platformVersion; - - // if all devices are allocated - if (this.uniqueDevices.length === 0) { - return false; - } - - // if both device type and os is any then return true - if (deviceType === 0 && version === '0') { - return true; - } - - // if os is any then return true - if (version === '0') { - return true; - } - - // check if preferred device type & os exists - return this.uniqueDevices.some((d) => { - // if only device type is any then just check version - if (deviceType === 0) { - return d.platformVersion === version; - } - - return ( - d.platformVersion === version && - (d.isTablet - ? deviceType === ENUMS.DEVICE_TYPE.TABLET_REQUIRED - : deviceType === ENUMS.DEVICE_TYPE.PHONE_REQUIRED) - ); - }); - } - - return null; - } - - @action - parseVersion(version: string): number[] { - // Extract version numbers (e.g., "15.8.3 support" -> [15,8,3]) - const match = version.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/); - - if (!match) { - return [0]; - } - - // Convert matched groups to numbers, defaulting to 0 if not present - return [ - parseInt(match[1] || '0', 10), - parseInt(match[2] || '0', 10), - parseInt(match[3] || '0', 10), - ]; - } - - @action - compareVersions(v1: string, v2: string): number { - const v1Parts = this.parseVersion(v1); - const v2Parts = this.parseVersion(v2); - - // Compare each part of the version - for (let i = 0; i < 3; i++) { - const v1Part = v1Parts[i] as number; - const v2Part = v2Parts[i] as number; - - if (v1Part > v2Part) { - return 1; - } - - if (v1Part < v2Part) { - return -1; - } - } - - return 0; - } - - @action - updateDevicePref( - device_type: string | number | undefined, - platform_version: string, - silentNotifications?: boolean - ) { - this.versionSelected.perform( - device_type, - platform_version, - silentNotifications - ); - } - - @action - handleSelectDeviceType(deviceType: DeviceType) { - this.selectedDeviceType = deviceType; - this.selectedVersion = '0'; - - this.updateDevicePref(this.selectedDeviceType?.value, this.selectedVersion); - } - - @action - handleSelectVersion(version: string) { - this.selectedVersion = version; - - this.updateDevicePref(this.selectedDeviceType?.value, this.selectedVersion); - } - - versionSelected = task( - async ( - device_type: string | number | undefined, - platform_version: string, - silentNotifications = false - ) => { - try { - const profileId = this.args.profileId; - - const devicePreferences = [ - ENV.endpoints['profiles'], - profileId, - ENV.endpoints['devicePreferences'], - ].join('/'); - - const data = { - device_type, - platform_version, - }; - - await this.ajax.put(devicePreferences, { data }); - - if (!this.isDestroyed && this.devicePreference) { - this.devicePreference.deviceType = this.selectedDeviceType - ?.value as number; - - this.devicePreference.platformVersion = this.selectedVersion; - - if (!silentNotifications) { - this.notify.success(this.intl.t('savedPreferences')); - } - } - } catch (e) { - if (!silentNotifications) { - this.notify.error(this.intl.t('somethingWentWrong')); - } - } - } - ); -} - -declare module '@glint/environment-ember-loose/registry' { - export default interface Registry { - 'ProjectPreferencesOld::Provider': typeof ProjectPreferencesOldProviderComponent; - } -} diff --git a/app/enums.ts b/app/enums.ts index 0b85e4445..0b92eb953 100644 --- a/app/enums.ts +++ b/app/enums.ts @@ -40,21 +40,6 @@ const ENUMS = { ERROR: 5, }, - DYNAMIC_STATUS: { - ERROR: -1, - NONE: 0, - INQUEUE: 1, - BOOTING: 2, - DOWNLOADING: 3, - INSTALLING: 4, - LAUNCHING: 5, - HOOKING: 6, - READY: 7, - SHUTTING_DOWN: 8, - COMPLETED: 9, - RUNNING: 10, // TODO: check with backend after api is ready - }, - DYNAMIC_SCAN_STATUS: { NOT_STARTED: 0, PREPROCESSING: 1, @@ -151,12 +136,6 @@ const ENUMS = { YEARLY: 10, }, - DEVICE_TYPE: { - NO_PREFERENCE: 0, - PHONE_REQUIRED: 1, - TABLET_REQUIRED: 2, - }, - DS_MANUAL_DEVICE_SELECTION: { ANY_DEVICE: 0, SPECIFIC_DEVICE: 1, @@ -167,7 +146,7 @@ const ENUMS = { FILTER_CRITERIA: 1, }, - DS_AUTOMATED_DEVICE_TYPE: { + DS_DEVICE_TYPE: { NO_PREFERENCE: 0, PHONE_REQUIRED: 1, TABLET_REQUIRED: 2, diff --git a/app/helpers/device-type.ts b/app/helpers/device-type.ts index afd4c81ad..3b8a543ea 100644 --- a/app/helpers/device-type.ts +++ b/app/helpers/device-type.ts @@ -5,13 +5,13 @@ export function deviceType(params: [string | number]) { const currentDevice = params[0]; switch (currentDevice) { - case ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE: + case ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE: return 'anyDevice'; - case ENUMS.DS_AUTOMATED_DEVICE_TYPE.PHONE_REQUIRED: + case ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED: return 'phone'; - case ENUMS.DS_AUTOMATED_DEVICE_TYPE.TABLET_REQUIRED: + case ENUMS.DS_DEVICE_TYPE.TABLET_REQUIRED: return 'tablet'; default: diff --git a/app/models/device-preference.ts b/app/models/device-preference.ts deleted file mode 100644 index 61ed8ef5c..000000000 --- a/app/models/device-preference.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable ember/no-computed-properties-in-native-classes */ -import { inject as service } from '@ember/service'; -import { computed } from '@ember/object'; -import Model, { attr } from '@ember-data/model'; -import IntlService from 'ember-intl/services/intl'; - -export default class DevicePreferenceModel extends Model { - @service declare intl: IntlService; - - @attr('number') - declare deviceType: number; - - @attr('string') - declare platformVersion: string; - - get tAnyVersion() { - return this.intl.t('anyVersion'); - } - - @computed('platformVersion', 'tAnyVersion') - get versionText() { - if (this.platformVersion === '0') { - return this.tAnyVersion; - } else { - return this.platformVersion; - } - } - - @computed('platformVersion') - get isAnyVersion() { - return this.platformVersion !== '0'; - } -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'device-preference': DevicePreferenceModel; - } -} diff --git a/app/models/dynamicscan-mode.ts b/app/models/dynamicscan-mode.ts deleted file mode 100644 index 1cdf2d231..000000000 --- a/app/models/dynamicscan-mode.ts +++ /dev/null @@ -1,14 +0,0 @@ -import Model, { attr } from '@ember-data/model'; - -export type DynamicScanModeType = 'Manual' | 'Automated'; - -export default class DynamicscanModeModel extends Model { - @attr('string') - declare dynamicscanMode: DynamicScanModeType; -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'dynamicscan-mode': DynamicscanModeModel; - } -} diff --git a/app/models/dynamicscan-old.ts b/app/models/dynamicscan-old.ts deleted file mode 100644 index e6dcdf2d0..000000000 --- a/app/models/dynamicscan-old.ts +++ /dev/null @@ -1,48 +0,0 @@ -import Model, { attr } from '@ember-data/model'; - -export default class DynamicscanOldModel extends Model { - @attr('boolean') - declare apiScan: boolean; - - @attr() - declare apiUrls: unknown; - - @attr('date') - declare createdOn: Date; - - @attr('date') - declare updatedOn: Date; - - @attr('date') - declare expiresOn: Date; - - @attr('number') - declare deviceType: number; - - @attr('number') - declare dynamicStatus: number; - - @attr('number') - declare platform: number; - - @attr('string') - declare platformVersion: string; - - @attr('string') - declare proxyHost: string; - - @attr('string') - declare proxyPort: string; - - async extendTime(time: number) { - const adapter = this.store.adapterFor('dynamicscan-old'); - - return await adapter.extendTime(this, time); - } -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'dynamicscan-old': DynamicscanOldModel; - } -} diff --git a/app/models/file.ts b/app/models/file.ts index 697bf52b3..ba9384f1f 100644 --- a/app/models/file.ts +++ b/app/models/file.ts @@ -185,151 +185,6 @@ export default class FileModel extends ModelBaseMixin { return this.scanProgressClass(isStaticDone); } - get isNoneStatus() { - const status = this.dynamicStatus; - return status === ENUMS.DYNAMIC_STATUS.NONE; - } - - get isNotNoneStatus() { - return !this.isNoneStatus; - } - get isNotReady() { - return !this.isReady; - } - - get isReady() { - const status = this.dynamicStatus; - return status === ENUMS.DYNAMIC_STATUS.READY; - } - - get isDynamicStatusNone() { - const status = this.dynamicStatus; - return status === ENUMS.DYNAMIC_STATUS.NONE; - } - - get isDynamicStatusError() { - const status = this.dynamicStatus; - return status === ENUMS.DYNAMIC_STATUS.ERROR; - } - - get isDynamicStatusQueueAndHasAutomation() { - const status = this.dynamicStatus; - return ( - status === ENUMS.DYNAMIC_STATUS.INQUEUE && this.canRunAutomatedDynamicscan - ); - } - - get isDynamicStatusReady() { - const status = this.dynamicStatus; - return status === ENUMS.DYNAMIC_STATUS.READY; - } - - get isDynamicStatusNotReady() { - return !this.isDynamicStatusReady; - } - - get isDynamicStatusNotNone() { - return !this.isDynamicStatusNone; - } - - get isDynamicStatusNeitherNoneNorReadyNorError() { - const status = this.dynamicStatus; - return ![ - ENUMS.DYNAMIC_STATUS.READY, - ENUMS.DYNAMIC_STATUS.NONE, - ENUMS.DYNAMIC_STATUS.ERROR, - ].includes(status); - } - - get isDynamicStatusNoneOrError() { - const status = this.dynamicStatus; - return [ENUMS.DYNAMIC_STATUS.NONE, ENUMS.DYNAMIC_STATUS.ERROR].includes( - status - ); - } - - get isDynamicStatusNoneOrReady() { - const status = this.dynamicStatus; - return [ENUMS.DYNAMIC_STATUS.READY, ENUMS.DYNAMIC_STATUS.NONE].includes( - status - ); - } - - get isDynamicStatusStarting() { - const status = this.dynamicStatus; - return ![ - ENUMS.DYNAMIC_STATUS.READY, - ENUMS.DYNAMIC_STATUS.RUNNING, - ENUMS.DYNAMIC_STATUS.NONE, - ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN, - ].includes(status); - } - - get isDynamicStatusInProgress() { - const status = this.dynamicStatus; - return [ - ENUMS.DYNAMIC_STATUS.INQUEUE, - ENUMS.DYNAMIC_STATUS.BOOTING, - ENUMS.DYNAMIC_STATUS.DOWNLOADING, - ENUMS.DYNAMIC_STATUS.INSTALLING, - ENUMS.DYNAMIC_STATUS.LAUNCHING, - ENUMS.DYNAMIC_STATUS.HOOKING, - ENUMS.DYNAMIC_STATUS.READY, - ENUMS.DYNAMIC_STATUS.RUNNING, - ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN, - ].includes(status); - } - - get isNeitherNoneNorReady() { - const status = this.dynamicStatus; - return ![ENUMS.DYNAMIC_STATUS.READY, ENUMS.DYNAMIC_STATUS.NONE].includes( - status - ); - } - - get startingScanStatus() { - return this.isDynamicStatusStarting; - } - - get showScheduleAutomatedDynamicScan() { - const status = this.dynamicStatus; - return ( - status !== ENUMS.DYNAMIC_STATUS.INQUEUE && this.canRunAutomatedDynamicscan - ); - } - - get statusText() { - const tDeviceInQueue = this.intl.t('deviceInQueue'); - const tDeviceBooting = this.intl.t('deviceBooting'); - const tDeviceDownloading = this.intl.t('deviceDownloading'); - const tDeviceInstalling = this.intl.t('deviceInstalling'); - const tDeviceLaunching = this.intl.t('deviceLaunching'); - const tDeviceHooking = this.intl.t('deviceHooking'); - const tDeviceShuttingDown = this.intl.t('deviceShuttingDown'); - const tDeviceCompleted = this.intl.t('deviceCompleted'); - - switch (this.dynamicStatus) { - case ENUMS.DYNAMIC_STATUS.INQUEUE: - return tDeviceInQueue; - case ENUMS.DYNAMIC_STATUS.BOOTING: - return tDeviceBooting; - case ENUMS.DYNAMIC_STATUS.DOWNLOADING: - return tDeviceDownloading; - case ENUMS.DYNAMIC_STATUS.INSTALLING: - return tDeviceInstalling; - case ENUMS.DYNAMIC_STATUS.LAUNCHING: - return tDeviceLaunching; - case ENUMS.DYNAMIC_STATUS.HOOKING: - return tDeviceHooking; - case ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN: - return tDeviceShuttingDown; - case ENUMS.DYNAMIC_STATUS.COMPLETED: - return tDeviceCompleted; - default: - return 'Unknown Status'; - } - } - get comparableVersion() { const platform = this.project?.get('platform'); if (platform === ENUMS.PLATFORM.IOS) { @@ -338,42 +193,6 @@ export default class FileModel extends ModelBaseMixin { return this.versionCode; } - setDynamicStatus(status: number) { - this.store.push({ - data: { - id: this.id, - type: FileModel.modelName, - attributes: { - dynamicStatus: status, - }, - }, - }); - } - - setBootingStatus() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.BOOTING); - } - - setInQueueStatus() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.INQUEUE); - } - - setShuttingDown() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN); - } - - setNone() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.NONE); - } - - setDynamicStatusNone() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.NONE); - } - - setReady() { - this.setDynamicStatus(ENUMS.DYNAMIC_STATUS.READY); - } - @sort('analyses', 'analysesSorting') declare sortedAnalyses: ComputedProperty; diff --git a/app/models/project-available-device.ts b/app/models/project-available-device.ts deleted file mode 100644 index 33d658536..000000000 --- a/app/models/project-available-device.ts +++ /dev/null @@ -1,69 +0,0 @@ -import Model, { attr } from '@ember-data/model'; - -export default class ProjectAvailableDeviceModel extends Model { - @attr('string') - declare address: string; - - @attr('string') - declare deviceIdentifier: string; - - @attr('string') - declare cpuArchitecture: string; - - @attr('string') - declare model: string; - - @attr('string') - declare platformVersion: string; - - @attr('string') - declare simNetwork: string; - - @attr('string') - declare simPhoneNumber: string; - - @attr('string') - declare state: string; - - @attr('string') - declare vpnPackageName: string; - - @attr('boolean') - declare hasPinLock: boolean; - - @attr('boolean') - declare hasPersistentApps: boolean; - - @attr('boolean') - declare hasSim: boolean; - - @attr('boolean') - declare hasVnc: boolean; - - @attr('boolean') - declare hasVpn: boolean; - - @attr('boolean') - declare isTablet: boolean; - - @attr('boolean') - declare isActive: boolean; - - @attr('boolean') - declare isConnected: boolean; - - @attr('boolean') - declare isReserved: boolean; - - @attr('number') - declare platform: number; - - @attr - declare persistentApps: string[]; -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'project-available-device': ProjectAvailableDeviceModel; - } -} diff --git a/app/serializers/device-preference.js b/app/serializers/device-preference.js deleted file mode 100644 index b8dacffd1..000000000 --- a/app/serializers/device-preference.js +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable prettier/prettier */ -import DRFSerializer from './drf'; - -export default DRFSerializer.extend({ - normalizeResponse: function (store, primaryModelClass, payload) { - return { - data: { - id: payload.id, - type: 'device-preference', - attributes: { - platformVersion: payload.platform_version, - deviceType: payload.device_type - } - } - }; - } -}); diff --git a/app/styles/_component-variables.scss b/app/styles/_component-variables.scss index 4c9c6a866..316f4ac57 100644 --- a/app/styles/_component-variables.scss +++ b/app/styles/_component-variables.scss @@ -1279,18 +1279,6 @@ body { --vnc-viewer-info-border-color: var(--neutral-grey-300); --vnc-viewer-info-background: var(--neutral-grey-100); - // variables for file-details/dynamic-scan/drawer-old - --file-details-dynamic-scan-drawer-old-border-color: var(--border-color-1); - --file-details-dynamic-scan-drawer-old-border-radius: var(--border-radius); - --file-details-dynamic-scan-drawer-old-alert-background-color: var( - --warn-light - ); - --file-details-dynamic-scan-drawer-old-alert-text-color: var(--warn-dark); - --file-details-dynamic-scan-drawer-old-alert-border-color: var(--warn-dark); - --file-details-dynamic-scan-drawer-old-device-settings-warning-text-color: var( - --neutral-grey-500 - ); - // variables for file-list --file-list-selected-file-chip-color: var(--text-primary); --file-list-selected-file-chip-background: var(--primary-main-10); @@ -2059,11 +2047,6 @@ body { --page-not-found-card-box-shadow: var(--box-shadow-2); --page-not-found-border-color: var(--border-color-1); - // variables for file-details/dynamic-scan/drawer-old/proxy-settings-view - --file-details-dynamic-scan-drawer-old-proxy-settings-view-border-color: var( - --border-color-1 - ); - // variables for file-details/static-scan --file-details-static-scan-border-color: var(--border-color-1); --file-details-static-scan-background-color: var(--background-light); diff --git a/config/environment.js b/config/environment.js index 9a2aac407..09f49851a 100644 --- a/config/environment.js +++ b/config/environment.js @@ -250,10 +250,8 @@ module.exports = function (environment) { invoice: 'invoice', logout: 'logout', devices: 'devices', - devicePreferences: 'device_preference', dynamic: 'dynamicscan', dynamicscans: 'dynamicscans', - dynamicShutdown: 'dynamic_shutdown', storeUrl: 'store_url', deleteProject: 'projects/delete', recover: 'v2/forgot_password', @@ -299,7 +297,6 @@ module.exports = function (environment) { rescan: 'rescan', personaltokens: 'personaltokens', unknownAnalysisStatus: 'unknown_analysis_status', - dynamicscanMode: 'dynamicscan_mode', uploadAutomationScript: 'upload_automation_script', uploadAutomationScriptSignedUrl: 'upload_automation_script/signed_url', scheduleDynamicscanAutomation: 'schedule_automation', diff --git a/mirage/config.js b/mirage/config.js index d33aed8e1..d53d3ec1f 100644 --- a/mirage/config.js +++ b/mirage/config.js @@ -358,14 +358,6 @@ function routes() { return {}; }); - this.get('/dynamic/:id', () => { - return {}; - }); - - this.get('/manual/:id', () => { - return {}; - }); - this.get('/jira_projects', () => { return {}; }); @@ -441,11 +433,11 @@ function routes() { return {}; }); - this.put('/dynamicscan/:id', () => { + this.delete('/v2/dynamicscans/:id', () => { return {}; }); - this.delete('/dynamicscan/:id', () => { + this.put('/v2/dynamicscans/:id/extend', () => { return {}; }); @@ -477,12 +469,6 @@ function routes() { return {}; }); - this.put('/profiles/:id/device_preference', () => { - return { - id: '1', - }; - }); - this.post('/namespace_add', () => { return {}; }); @@ -523,10 +509,6 @@ function routes() { return {}; }); - this.get('/dynamic_shutdown//:id', () => { - return {}; - }); - this.delete('/delete_jira_project/:id', () => { return {}; }); diff --git a/mirage/factories/device-preference.ts b/mirage/factories/device-preference.ts deleted file mode 100644 index 1097a3838..000000000 --- a/mirage/factories/device-preference.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Factory } from 'miragejs'; - -import { faker } from '@faker-js/faker'; -import ENUMS from 'irene/enums'; - -export default Factory.extend({ - device_type: faker.helpers.arrayElement(ENUMS.DEVICE_TYPE.BASE_VALUES), - platform_version: () => faker.system.semver(), -}); diff --git a/mirage/factories/ds-automated-device-preference.ts b/mirage/factories/ds-automated-device-preference.ts index a40c60416..f4cf0b18e 100644 --- a/mirage/factories/ds-automated-device-preference.ts +++ b/mirage/factories/ds-automated-device-preference.ts @@ -9,8 +9,8 @@ export default Factory.extend({ ds_automated_device_selection_display: faker.lorem.sentence(), - ds_automated_device_type: () => - faker.helpers.arrayElement(ENUMS.DS_AUTOMATED_DEVICE_TYPE.BASE_VALUES), + DS_DEVICE_TYPE: () => + faker.helpers.arrayElement(ENUMS.DS_DEVICE_TYPE.BASE_VALUES), ds_automated_platform_version_min: '', ds_automated_platform_version_max: '', diff --git a/mirage/factories/file.ts b/mirage/factories/file.ts index 79e4b0d6e..8e5fe1fed 100644 --- a/mirage/factories/file.ts +++ b/mirage/factories/file.ts @@ -1,5 +1,4 @@ import { faker } from '@faker-js/faker'; -import ENUMS from 'irene/enums'; import { RISK_COLOR_CODE } from 'irene/utils/constants'; import Base from './base'; @@ -49,10 +48,6 @@ export const FILE_FACTORY_DEF = { return faker.datatype.boolean(); }, - dynamic_status() { - return faker.helpers.arrayElement(ENUMS.DYNAMIC_STATUS.VALUES); - }, - name() { return faker.company.name(); }, diff --git a/mirage/factories/project.ts b/mirage/factories/project.ts index f8f49f53e..f2c19cd89 100644 --- a/mirage/factories/project.ts +++ b/mirage/factories/project.ts @@ -42,7 +42,7 @@ export const PROJECT_FACTORY_DEF = { }, device_type() { - return faker.helpers.arrayElement(ENUMS.DEVICE_TYPE.VALUES); + return faker.helpers.arrayElement(ENUMS.DS_DEVICE_TYPE.VALUES); }, platformIconClass() { diff --git a/tests/acceptance/file-compare-test.js b/tests/acceptance/file-compare-test.js index 3049cbbba..046ed96f0 100644 --- a/tests/acceptance/file-compare-test.js +++ b/tests/acceptance/file-compare-test.js @@ -179,12 +179,6 @@ module('Acceptance | file compare', function (hooks) { return schema.devicePreferences.find(`${req.params.id}`)?.toJSON(); }); - this.server.get('/projects/:id/available-devices', (schema) => { - const results = schema.projectAvailableDevices.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - this.server.get('/profiles/:id/api_scan_options', (_, req) => { return { ds_api_capture_filters: [], id: req.params.id }; }); diff --git a/tests/acceptance/file-details-test.js b/tests/acceptance/file-details-test.js index 258e4aa4d..d77700ef5 100644 --- a/tests/acceptance/file-details-test.js +++ b/tests/acceptance/file-details-test.js @@ -7,7 +7,6 @@ import { t } from 'ember-intl/test-support'; import Service from '@ember/service'; import { serializer } from 'irene/tests/test-utils'; -import ENUMS from 'irene/enums'; class IntegrationStub extends Service { async configure(user) { @@ -69,7 +68,6 @@ module('Acceptance | file details', function (hooks) { const file = this.server.create('file', { is_static_done: true, - dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, project: project.id, analyses, }); @@ -130,12 +128,6 @@ module('Acceptance | file details', function (hooks) { return schema.devicePreferences.find(`${req.params.id}`)?.toJSON(); }); - this.server.get('/projects/:id/available-devices', (schema) => { - const results = schema.projectAvailableDevices.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - this.server.get('/manualscans/:id', (schema, req) => { return { id: req.params.id }; }); @@ -158,9 +150,7 @@ module('Acceptance | file details', function (hooks) { this.server.create('file-report', { id: '1', progress: 100 }); // Creates a new file with id of 2 - const latestFile = this.server.create('file', { - dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, - }); + const latestFile = this.server.create('file'); // project that has a latest file of id 2 this.project.update({ last_file_id: latestFile.id }); diff --git a/tests/acceptance/file-details/api-scan-test.js b/tests/acceptance/file-details/api-scan-test.js index 22c4a80c4..4ffadf473 100644 --- a/tests/acceptance/file-details/api-scan-test.js +++ b/tests/acceptance/file-details/api-scan-test.js @@ -81,7 +81,6 @@ module('Acceptance | file-details/api-scan', function (hooks) { is_dynamic_done: true, is_api_done: false, is_active: true, - dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, project: project.id, profile: profile.id, analyses, diff --git a/tests/acceptance/file-details/manual-scan-test.js b/tests/acceptance/file-details/manual-scan-test.js index c0d0baee9..b44ad96e3 100644 --- a/tests/acceptance/file-details/manual-scan-test.js +++ b/tests/acceptance/file-details/manual-scan-test.js @@ -94,7 +94,6 @@ module('Acceptance | file-details/manual-scan', function (hooks) { is_manual_done: false, manual: ENUMS.MANUAL.NONE, is_active: true, - dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, project: project.id, profile: profile.id, analyses, diff --git a/tests/integration/components/file-details/dynamic-scan/automated-test.js b/tests/integration/components/file-details/dynamic-scan/automated-test.js index ab3a955f4..935f81757 100644 --- a/tests/integration/components/file-details/dynamic-scan/automated-test.js +++ b/tests/integration/components/file-details/dynamic-scan/automated-test.js @@ -265,7 +265,7 @@ module( ds_automated_device_selection: anyDeviceSelected ? ENUMS.DS_AUTOMATED_DEVICE_SELECTION.ANY_DEVICE : ENUMS.DS_AUTOMATED_DEVICE_SELECTION.FILTER_CRITERIA, - ds_automated_device_type: 0, + DS_DEVICE_TYPE: 0, ds_automated_platform_version_min: '10.0', }); @@ -405,7 +405,7 @@ module( value: t( deviceType([ this.automatedDastDevicePreferences?.dsAutomatedDeviceType ?? - ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE, + ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE, ]) ), hidden: anyDeviceSelected, diff --git a/tests/integration/components/file-details/dynamic-scan/manual-test.js b/tests/integration/components/file-details/dynamic-scan/manual-test.js index 31d2527e0..b07323377 100644 --- a/tests/integration/components/file-details/dynamic-scan/manual-test.js +++ b/tests/integration/components/file-details/dynamic-scan/manual-test.js @@ -49,6 +49,7 @@ module( hooks.beforeEach(async function () { const store = this.owner.lookup('service:store'); + const dsService = this.owner.lookup('service:dynamic-scan'); const profile = this.server.create('profile', { id: '100' }); @@ -104,6 +105,7 @@ module( devicePreference, availableDevices, store, + dsService, }); // set up services @@ -446,8 +448,8 @@ module( const deviceTypeLabel = deviceType([ device.is_tablet - ? ENUMS.DEVICE_TYPE.TABLET_REQUIRED - : ENUMS.DEVICE_TYPE.PHONE_REQUIRED, + ? ENUMS.DS_DEVICE_TYPE.TABLET_REQUIRED + : ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED, ]); // Verify device basic info diff --git a/tests/integration/components/file-details/scan-actions/api-scan-test.js b/tests/integration/components/file-details/scan-actions/api-scan-test.js index 1e6d61476..7f5dc1eae 100644 --- a/tests/integration/components/file-details/scan-actions/api-scan-test.js +++ b/tests/integration/components/file-details/scan-actions/api-scan-test.js @@ -45,7 +45,6 @@ module( return { id: req.params.id }; }); - this.file.dynamicStatus = ENUMS.DYNAMIC_STATUS.NONE; this.file.isDynamicDone = true; this.file.isApiDone = false; diff --git a/tests/integration/components/project-settings/dast-automation/automation-settings/device-preferences-test.js b/tests/integration/components/project-settings/dast-automation/automation-settings/device-preferences-test.js index c43807d06..e6e929d70 100644 --- a/tests/integration/components/project-settings/dast-automation/automation-settings/device-preferences-test.js +++ b/tests/integration/components/project-settings/dast-automation/automation-settings/device-preferences-test.js @@ -153,9 +153,9 @@ module( assert .dom( - `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${this.devicePreference.ds_automated_device_type}"]` + `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${this.devicePreference.DS_DEVICE_TYPE}"]` ) - .hasValue(`${this.devicePreference.ds_automated_device_type}`) + .hasValue(`${this.devicePreference.DS_DEVICE_TYPE}`) .isChecked(); assert @@ -278,7 +278,7 @@ module( test('it selects device type & min version', async function (assert) { this.devicePreference.update({ - ds_automated_device_type: ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE, + DS_DEVICE_TYPE: ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE, ds_automated_platform_version_min: '', ds_automated_device_selection: ENUMS.DS_AUTOMATED_DEVICE_SELECTION.FILTER_CRITERIA, @@ -322,28 +322,28 @@ module( assert .dom( - `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE}"]` + `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE}"]` ) - .hasValue(`${ENUMS.DS_AUTOMATED_DEVICE_TYPE.NO_PREFERENCE}`) + .hasValue(`${ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE}`) .isChecked(); assert.dom(minOSVersionTrigger).hasText(t('anyVersion')); // select device type await click( - `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_AUTOMATED_DEVICE_TYPE.PHONE_REQUIRED}"]` + `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED}"]` ); assert .dom( - `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_AUTOMATED_DEVICE_TYPE.PHONE_REQUIRED}"]` + `[data-test-projectSettings-dastAutomationSettings-devicePreference-automatedPreferenceCriteria-deviceTypeRadioGroup] input[value="${ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED}"]` ) - .hasValue(`${ENUMS.DS_AUTOMATED_DEVICE_TYPE.PHONE_REQUIRED}`) + .hasValue(`${ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED}`) .isChecked(); assert.strictEqual( - this.requestBody.ds_automated_device_type, - ENUMS.DS_AUTOMATED_DEVICE_TYPE.PHONE_REQUIRED + this.requestBody.DS_DEVICE_TYPE, + ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED ); // select min version diff --git a/tests/unit/adapters/dynamicscan-mode-test.js b/tests/unit/adapters/dynamicscan-mode-test.js deleted file mode 100644 index eafd87d0f..000000000 --- a/tests/unit/adapters/dynamicscan-mode-test.js +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable prettier/prettier */ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Adapter | dynamicscan mode', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let adapter = this.owner.lookup('adapter:dynamicscan-mode'); - assert.ok(adapter); - }); -}); diff --git a/tests/unit/helpers/device-type-test.js b/tests/unit/helpers/device-type-test.js index 5a456d1a2..31199ee4d 100644 --- a/tests/unit/helpers/device-type-test.js +++ b/tests/unit/helpers/device-type-test.js @@ -8,19 +8,19 @@ module('Unit | Helper | device type', function () { assert.equal(deviceType([42]), 'anyDevice', 'No Preference'); assert.equal( - deviceType([ENUMS.DEVICE_TYPE.NO_PREFERENCE]), + deviceType([ENUMS.DS_DEVICE_TYPE.NO_PREFERENCE]), 'anyDevice', 'No Preference' ); assert.equal( - deviceType([ENUMS.DEVICE_TYPE.PHONE_REQUIRED]), + deviceType([ENUMS.DS_DEVICE_TYPE.PHONE_REQUIRED]), 'phone', 'Phone' ); assert.equal( - deviceType([ENUMS.DEVICE_TYPE.TABLET_REQUIRED]), + deviceType([ENUMS.DS_DEVICE_TYPE.TABLET_REQUIRED]), 'tablet', 'Tablet' ); diff --git a/tests/unit/models/device-preference-test.js b/tests/unit/models/device-preference-test.js deleted file mode 100644 index a168a4ade..000000000 --- a/tests/unit/models/device-preference-test.js +++ /dev/null @@ -1,30 +0,0 @@ -/* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Model | device preference', function (hooks) { - setupTest(hooks); - - hooks.beforeEach(function () { - // set the locale and the config - this.owner.lookup('service:intl').setLocale('en'); - }); - - test('it exists', function (assert) { - const devicePreference = this.owner - .lookup('service:store') - .createRecord('device-preference'); - - devicePreference.set('platformVersion', '1'); - - assert.equal(devicePreference.get('versionText'), '1', 'Version Text'); - - devicePreference.set('platformVersion', '0'); - - assert.equal( - devicePreference.get('versionText'), - 'Any Version', - 'Version Text' - ); - }); -}); diff --git a/tests/unit/models/dynamicscan-mode-test.js b/tests/unit/models/dynamicscan-mode-test.js deleted file mode 100644 index 5f06dfced..000000000 --- a/tests/unit/models/dynamicscan-mode-test.js +++ /dev/null @@ -1,14 +0,0 @@ -/* eslint-disable prettier/prettier */ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Model | dynamicscan mode', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let store = this.owner.lookup('service:store'); - let model = store.createRecord('dynamicscan-mode', {}); - assert.ok(model); - }); -}); diff --git a/tests/unit/models/file-test.js b/tests/unit/models/file-test.js index dec4b9f3a..e465db45e 100644 --- a/tests/unit/models/file-test.js +++ b/tests/unit/models/file-test.js @@ -1,5 +1,4 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal, qunit/no-assert-equal-boolean */ -import ENUMS from 'irene/enums'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; @@ -29,49 +28,5 @@ module('Unit | Model | file', function (hooks) { assert.equal(file.scanProgressClass(true), true, 'Scan Progress Class'); assert.equal(file.get('isStaticCompleted'), false, 'Static Scan'); - - assert.equal(file.get('isNoneStatus'), false, 'None Status'); - - assert.equal(file.get('isReady'), false, 'Is Ready'); - - assert.equal( - file.get('isNeitherNoneNorReady'), - true, - 'Is Not None Nor Ready' - ); - - assert.equal(file.get('statusText'), 'Unknown Status', 'Unknown Status'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.BOOTING); - - assert.equal(file.get('statusText'), 'Booting', 'Booting'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.DOWNLOADING); - - assert.equal(file.get('statusText'), 'Downloading', 'Downloading'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.INSTALLING); - - assert.equal(file.get('statusText'), 'Installing', 'Installing'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.LAUNCHING); - - assert.equal(file.get('statusText'), 'Launching', 'Launching'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.HOOKING); - - assert.equal(file.get('statusText'), 'Starting', 'Hooking'); - - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN); - - assert.equal(file.get('statusText'), 'Stopping', 'Shutting Down'); - - assert.equal(file.setBootingStatus(), undefined, 'Set Booting Status'); - - assert.equal(file.setShuttingDown(), undefined, 'Set Booting Status'); - - assert.equal(file.setNone(), undefined, 'Set Booting Status'); - - assert.equal(file.setReady(), undefined, 'Set Booting Status'); }); });