Skip to content

Commit

Permalink
Remove ember-ajax and use ember-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
SmitGala committed Dec 18, 2024
1 parent 454094c commit 037bf3a
Show file tree
Hide file tree
Showing 43 changed files with 356 additions and 392 deletions.
3 changes: 2 additions & 1 deletion app/authenticators/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RouterService from '@ember/routing/router-service';
import ENV from 'irene/config/environment';
import OidcService from 'irene/services/oidc';
import FreshdeskService from 'irene/services/freshdesk';
import type IreneAjaxService from 'irene/services/ajax';

export interface LoginSuccessDataProps {
token: string;
Expand Down Expand Up @@ -35,7 +36,7 @@ export const processData = (data: LoginSuccessDataProps) => {
};

export default class BaseAuthenticator extends Base {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare session: any;
@service declare router: RouterService;
@service('notifications') declare notify: NotificationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import IntlService from 'ember-intl/services/intl';
import ENV from 'irene/config/environment';

import PersonaltokenModel from 'irene/models/personaltoken';
import type IreneAjaxService from 'irene/services/ajax';

export interface AccountSettingsDeveloperSettingsPersonaltokenListDeleteTokenSignature {
Args: {
Expand All @@ -17,7 +18,7 @@ export interface AccountSettingsDeveloperSettingsPersonaltokenListDeleteTokenSig

export default class AccountSettingsDeveloperSettingsPersonaltokenListDeleteTokenComponent extends Component<AccountSettingsDeveloperSettingsPersonaltokenListDeleteTokenSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('notifications') declare notify: NotificationService;

@tracked showRevokePersonalTokenConfirmBox = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { task } from 'ember-concurrency';
import { query } from 'ember-data-resources';

import PersonaltokenModel from 'irene/models/personaltoken';
import type IreneAjaxService from 'irene/services/ajax';

export default class AccountSettingsDeveloperSettingsPersonaltokenListComponent extends Component {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare store: Store;
@service('notifications') declare notify: NotificationService;

Expand Down Expand Up @@ -78,7 +79,7 @@ export default class AccountSettingsDeveloperSettingsPersonaltokenListComponent
name: this.tokenName,
};

await this.ajax.post(ENV.endpoints['personaltokens'], {
await this.ajax.post(ENV.endpoints['personaltokens'] ?? '', {
data,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type Store from '@ember-data/store';
import ENV from 'irene/config/environment';
import parseError from 'irene/utils/parse-error';
import type DatetimeService from 'irene/services/datetime';
import type IreneAjaxService from 'irene/services/ajax';

const localeStrings = {
en: 'English',
Expand All @@ -19,7 +20,7 @@ type LocaleKeys = keyof typeof localeStrings;

export default class AccountSettingsGeneralSelectLanguageComponent extends Component {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare datetime: DatetimeService;
@service declare session: any;
@service declare store: Store;
Expand Down Expand Up @@ -65,7 +66,7 @@ export default class AccountSettingsGeneralSelectLanguageComponent extends Compo
};

try {
await this.ajax.post(ENV.endpoints['lang'], { data });
await this.ajax.post(ENV.endpoints['lang'] ?? '', { data });

if (!this.isDestroyed) {
window.location.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Changeset } from 'ember-changeset';

import ENV from 'irene/config/environment';
import triggerAnalytics from 'irene/utils/trigger-analytics';
import type IreneAjaxService from 'irene/services/ajax';

type ChangesetBufferProps = BufferedChangeset & {
old_password: string;
Expand All @@ -29,7 +30,7 @@ const ChangeValidator = {

export default class AccountSettingsSecurityPasswordChangeComponent extends Component {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('rollbar') declare logger: any;
@service declare router: RouterService;
@service('notifications') declare notify: NotificationService;
Expand Down Expand Up @@ -63,7 +64,7 @@ export default class AccountSettingsSecurityPasswordChangeComponent extends Comp
};

try {
await this.ajax.post(this.changePasswordURL, {
await this.ajax.post(this.changePasswordURL ?? '', {
data,
});

Expand Down
3 changes: 2 additions & 1 deletion app/components/api-filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import triggerAnalytics from 'irene/utils/trigger-analytics';
import ApiScanOptionsModel from 'irene/models/api-scan-options';
import { task } from 'ember-concurrency';
import { action } from '@ember/object';
import type IreneAjaxService from 'irene/services/ajax';

const isRegexFailed = function (url: string) {
const reg =
Expand All @@ -29,7 +30,7 @@ export interface ApiFilterSignature {

export default class ApiFilterComponent extends Component<ApiFilterSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare store: Store;
@service('notifications') declare notify: NotificationService;

Expand Down
3 changes: 2 additions & 1 deletion app/components/app-monitoring/version-table/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import parseError from 'irene/utils/parse-error';
import SubmissionModel from 'irene/models/submission';
import RealtimeService from 'irene/services/realtime';
import ENUMS from 'irene/enums';
import type IreneAjaxService from 'irene/services/ajax';

dayjs.extend(advancedFormat);

Expand All @@ -27,7 +28,7 @@ interface AppMonitoringVersionTableActionsSignature {
}

export default class AppMonitoringVersionTableActionsComponent extends Component<AppMonitoringVersionTableActionsSignature> {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('notifications') declare notify: NotificationService;
@service declare store: Store;
@service declare intl: IntlService;
Expand Down
11 changes: 9 additions & 2 deletions app/components/attachment-detail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@ import { inject as service } from '@ember/service';
import ENV from 'irene/config/environment';
import AttachmentModel from 'irene/models/attachment';
import { task } from 'ember-concurrency';
import type IreneAjaxService from 'irene/services/ajax';

export interface AttachmentDetailSignature {
Args: {
attachment: AttachmentModel;
};
}

interface DownloadResponse {
data: {
url: string;
};
}

export default class AttachmentDetailComponent extends Component<AttachmentDetailSignature> {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('notifications') declare notify: NotificationService;
@service('browser/window') declare window: Window;

downloadAttachment = task({ drop: true }, async () => {
const url = ENV.host + this.args.attachment.downloadUrl;

try {
const result = await this.ajax.request(url);
const result = await this.ajax.request<DownloadResponse>(url);

this.window.open(result.data.url);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { inject as service } from '@ember/service';
import type IntlService from 'ember-intl/services/intl';

import parseError from 'irene/utils/parse-error';
import type IreneAjaxService from 'irene/services/ajax';

export default class DyanmicscanAutomationUpsellingFeatureComponent extends Component {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare intl: IntlService;
@service('notifications') declare notify: NotificationService;
@service('browser/window') declare window: Window;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ENV from 'irene/config/environment';
import triggerAnalytics from 'irene/utils/trigger-analytics';
import parseError from 'irene/utils/parse-error';
import type FileModel from 'irene/models/file';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsApiScanCapturedApisFooterSignature {
Args: {
Expand All @@ -18,7 +19,7 @@ export interface FileDetailsApiScanCapturedApisFooterSignature {
}

export default class FileDetailsApiScanCapturedApisFooterComponent extends Component<FileDetailsApiScanCapturedApisFooterSignature> {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare intl: IntlService;
@service('notifications') declare notify: NotificationService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type IntlService from 'ember-intl/services/intl';
import type Store from '@ember-data/store';

import styles from './index.scss';
import type IreneAjaxService from 'irene/services/ajax';

enum AvailableManualDeviceModelKeyMap {
ALL_AVAILABLE_DEVICES = 'all',
Expand All @@ -35,7 +36,7 @@ export interface FileDetailsDynamicScanDrawerDevicePrefTableSignature {
export default class FileDetailsDynamicScanDrawerDevicePrefTableComponent extends Component<FileDetailsDynamicScanDrawerDevicePrefTableSignature> {
@service declare store: Store;
@service('notifications') declare notify: NotificationService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare intl: IntlService;

@tracked limit = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type Store from '@ember-data/store';
import type FileModel from 'irene/models/file';
import { type DevicePreferenceContext } from 'irene/components/project-preferences/provider';
import type ProjectAvailableDeviceModel from 'irene/models/project-available-device';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsDynamicScanActionDrawerSignature {
Args: {
Expand All @@ -30,7 +31,7 @@ export interface FileDetailsDynamicScanActionDrawerSignature {

export default class FileDetailsDynamicScanActionDrawerComponent extends Component<FileDetailsDynamicScanActionDrawerSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare store: Store;
@service('notifications') declare notify: NotificationService;

Expand Down
3 changes: 2 additions & 1 deletion app/components/file-details/dynamic-scan/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import triggerAnalytics from 'irene/utils/trigger-analytics';
import type FileModel from 'irene/models/file';
import type PollService from 'irene/services/poll';
import type DynamicscanModel from 'irene/models/dynamicscan';
import type IreneAjaxService from 'irene/services/ajax';

export interface DynamicScanActionSignature {
Args: {
Expand All @@ -22,7 +23,7 @@ export interface DynamicScanActionSignature {
}

export default class DynamicScanActionComponent extends Component<DynamicScanActionSignature> {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('notifications') declare notify: NotificationService;
@service declare poll: PollService;

Expand Down
3 changes: 2 additions & 1 deletion app/components/file-details/dynamic-scan/drawer-old/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IntlService from 'ember-intl/services/intl';
import Store from '@ember-data/store';
import { tracked } from '@glimmer/tracking';
import FileModel from 'irene/models/file';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsDynamicScanDrawerOldSignature {
Args: {
Expand All @@ -19,7 +20,7 @@ export interface FileDetailsDynamicScanDrawerOldSignature {

export default class FileDetailsDynamicScanDrawerOldComponent extends Component<FileDetailsDynamicScanDrawerOldSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare store: Store;
@service('notifications') declare notify: NotificationService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ENV from 'irene/config/environment';
import parseError from 'irene/utils/parse-error';
import type FileModel from 'irene/models/file';
import type OrganizationService from 'irene/services/organization';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsManualScanRequestAccessSignature {
Args: {
Expand All @@ -16,7 +17,7 @@ export interface FileDetailsManualScanRequestAccessSignature {

export default class FileDetailsManualScanRequestAccessComponent extends Component<FileDetailsManualScanRequestAccessSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare organization: OrganizationService;
@service('notifications') declare notify: NotificationService;

Expand Down
3 changes: 2 additions & 1 deletion app/components/file-details/static-scan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { EmberTableSort } from 'ember-table';
import ENUMS from 'irene/enums';
import ENV from 'irene/config/environment';
import type FileModel from 'irene/models/file';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsStaticScanSignature {
Args: {
Expand All @@ -19,7 +20,7 @@ export interface FileDetailsStaticScanSignature {
export default class FileDetailsStaticScan extends Component<FileDetailsStaticScanSignature> {
@service declare intl: IntlService;
@service('notifications') declare notify: NotificationService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;

@tracked showRescanModal = false;

Expand Down
3 changes: 2 additions & 1 deletion app/components/file-details/summary/file-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import styles from './index.scss';
import FileModel from 'irene/models/file';
import ENV from 'irene/config/environment';
import TagModel from 'irene/models/tag';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsSummaryFileTagsSignature {
Args: {
Expand All @@ -18,7 +19,7 @@ export interface FileDetailsSummaryFileTagsSignature {

export default class FileDetailsSummaryFileTagsComponent extends Component<FileDetailsSummaryFileTagsSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service('notifications') declare notify: NotificationService;

@tracked showAddTagForm = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ENV from 'irene/config/environment';
import ENUMS from 'irene/enums';
import MeService from 'irene/services/me';
import AnalysisModel from 'irene/models/analysis';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsVulnerabilityAnalysisDetailsEditAnalysisButtonSignature {
Args: {
Expand All @@ -19,7 +20,7 @@ export interface FileDetailsVulnerabilityAnalysisDetailsEditAnalysisButtonSignat
export default class FileDetailsVulnerabilityAnalysisDetailsEditAnalysisButtonComponent extends Component<FileDetailsVulnerabilityAnalysisDetailsEditAnalysisButtonSignature> {
@service declare me: MeService;
@service declare intl: IntlService;
@service declare ajax: any;
@service declare ajax: IreneAjaxService;

@tracked showEditAnalysisDrawer = false;
@tracked showResetAnalysisConfirmBox = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { inject as service } from '@ember/service';
import ENUMS from 'irene/enums';
import styles from './index.scss';
import type FileModel from 'irene/models/file';
import type IreneAjaxService from 'irene/services/ajax';

export interface FileDetailsVulnerabilityAnalysisHeaderSignature {
Args: {
Expand All @@ -16,7 +17,7 @@ export interface FileDetailsVulnerabilityAnalysisHeaderSignature {
}

export default class FileDetailsVulnerabilityAnalysisHeaderComponent extends Component<FileDetailsVulnerabilityAnalysisHeaderSignature> {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;

@tracked isSecurityEnabled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import { task } from 'ember-concurrency';
import Store from '@ember-data/store';
import { waitForPromise } from '@ember/test-waiters';

import NetworkService from 'irene/services/network';
import SbomReportModel, { SbomReportType } from 'irene/models/sbom-report';
import parseError from 'irene/utils/parse-error';
import type IreneAjaxService from 'irene/services/ajax';

type SbomScanReportQueryResponse =
DS.AdapterPopulatedRecordArray<SbomReportModel> & {
meta: { count: number };
};

export default class FileReportDrawerSbomReportsSampleComponent extends Component {
@service declare ajax: any;
@service declare network: NetworkService;
@service declare ajax: IreneAjaxService;
@service declare store: Store;
@service declare intl: IntlService;
@service('notifications') declare notify: NotificationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CalendarOnSelectFunc,
RangeDateObject,
} from 'irene/components/ak-date-picker';
import type IreneAjaxService from 'irene/services/ajax';

export interface IAppScanResult {
created_on_date: string;
Expand Down Expand Up @@ -43,7 +44,7 @@ interface AppScanDataItemGroup {
}

export default class OrganizationAnalyticsAppScanChartComponent extends Component {
@service declare ajax: any;
@service declare ajax: IreneAjaxService;
@service declare organization: OrganizationService;
@service('notifications') declare notify: NotificationService;

Expand Down
Loading

0 comments on commit 037bf3a

Please sign in to comment.