import { __, s__ } from '~/locale';
import {
  stateFilter,
  severityFilter,
  activityFilter,
  simpleScannerFilterNoClusterImage,
  vendorScannerFilterNoClusterImage,
  getProjectFilter,
} from 'ee/security_dashboard/helpers';
import { REPORT_TYPES_NO_CLUSTER_IMAGE } from 'ee/security_dashboard/store/constants';
import { REPORT_TYPE_CLUSTER_IMAGE_SCANNING } from '~/vue_shared/security_reports/constants';

export const REPORT_TAB = {
  DEVELOPMENT: 'DEVELOPMENT',
  OPERATIONAL: 'OPERATIONAL',
  DEVELOPMENT_PROJECT: 'DEVELOPMENT_PROJECT',
};

export const FIELDS = {
  CHECKBOX: {
    key: 'checkbox',
    class: 'checkbox',
  },
  DETECTED: {
    key: 'detected',
    label: s__('Vulnerability|Detected'),
    class: 'detected',
    sortable: true,
  },
  STATUS: {
    key: 'state',
    label: s__('Vulnerability|Status'),
    class: 'status',
    sortable: true,
  },
  SEVERITY: {
    key: 'severity',
    label: s__('Vulnerability|Severity'),
    class: 'severity',
    sortable: true,
  },
  DESCRIPTION: {
    key: 'title',
    label: __('Description'),
    class: 'description gl-word-break-all',
    sortable: true,
  },
  IDENTIFIER: {
    key: 'identifier',
    label: s__('Vulnerability|Identifier'),
    class: 'identifier gl-word-break-all',
  },
  TOOL: {
    key: 'reportType',
    label: s__('Reports|Tool'),
    class: 'scanner',
    sortable: true,
  },
  ACTIVITY: {
    key: 'activity',
    label: s__('Vulnerability|Activity'),
    thClass: 'gl-text-right ',
    class: 'activity',
  },
};

export const FILTERS = {
  STATUS: stateFilter,
  SEVERITY: severityFilter,
  ACTIVITY: activityFilter,
  TOOL_SIMPLE: simpleScannerFilterNoClusterImage,
  TOOL_VENDOR: vendorScannerFilterNoClusterImage,
  PROJECT: getProjectFilter(),
};

export const FIELD_PRESETS = {
  DEVELOPMENT: [
    FIELDS.DETECTED,
    FIELDS.STATUS,
    FIELDS.SEVERITY,
    FIELDS.DESCRIPTION,
    FIELDS.IDENTIFIER,
    FIELDS.TOOL,
    FIELDS.ACTIVITY,
  ],
  OPERATIONAL: [
    FIELDS.DETECTED,
    FIELDS.STATUS,
    FIELDS.SEVERITY,
    FIELDS.DESCRIPTION,
    FIELDS.CLUSTER,
    FIELDS.ACTIVITY,
  ],
};

export const FILTER_PRESETS = {
  DEVELOPMENT_PROJECT: [FILTERS.STATUS, FILTERS.SEVERITY, FILTERS.TOOL_VENDOR, FILTERS.ACTIVITY],
  DEVELOPMENT: [FILTERS.STATUS, FILTERS.SEVERITY, FILTERS.TOOL_SIMPLE, FILTERS.ACTIVITY],
  OPERATIONAL: [FILTERS.STATUS, FILTERS.SEVERITY, FILTERS.ACTIVITY],
};

export const REPORT_TYPE_PRESETS = {
  DEVELOPMENT: Object.keys(REPORT_TYPES_NO_CLUSTER_IMAGE).map((type) => type.toUpperCase()),
  OPERATIONAL: [REPORT_TYPE_CLUSTER_IMAGE_SCANNING.toUpperCase()],
};
