All files / modules/70-pipeline/components/InputSetSelector utils.ts

100% Statements 20/20
75% Branches 3/4
100% Functions 5/5
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35    38x               38x 362x     38x 2x 2x     38x 2x     38x 2x     38x 2x 2x   2x 2x    
import type { IconName, SelectOption } from '@harness/uicore'
import type { EntityGitDetails, InputSetSummaryResponse } from 'services/pipeline-ng'
import css from './InputSetSelector.module.scss'
 
type InputSetLocal = InputSetSummaryResponse & SelectOption
export interface InputSetValue extends InputSetLocal {
  type: InputSetSummaryResponse['inputSetType']
  gitDetails?: EntityGitDetails
}
 
export const getIconByType = (type: InputSetSummaryResponse['inputSetType']): IconName => {
  return type === 'OVERLAY_INPUT_SET' ? 'step-group' : 'yaml-builder-input-sets'
}
 
export const onDragStart = (event: React.DragEvent<HTMLLIElement>, row: InputSetValue): void => {
  event.dataTransfer.setData('data', JSON.stringify(row))
  event.currentTarget.classList.add(css.dragging)
}
 
export const onDragEnd = (event: React.DragEvent<HTMLLIElement>): void => {
  event.currentTarget.classList.remove(css.dragging)
}
 
export const onDragLeave = (event: React.DragEvent<HTMLLIElement>): void => {
  event.currentTarget.classList.remove(css.dragOver)
}
 
export const onDragOver = (event: React.DragEvent<HTMLLIElement>): void => {
  Eif (event.preventDefault) {
    event.preventDefault()
  }
  event.currentTarget.classList.add(css.dragOver)
  event.dataTransfer.dropEffect = 'move'
}