summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/utils.js
blob: d895eca7af0d41718cfacb5c07c8250089c2fc24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { commitItemIconMap } from './constants';

export const getCommitIconMap = file => {
  if (file.deleted) {
    return commitItemIconMap.deleted;
  } else if (file.tempFile) {
    return commitItemIconMap.addition;
  }

  return commitItemIconMap.modified;
};

export const createPathWithExt = p => {
  const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : '';

  return `${p.substring(1, p.lastIndexOf('.') + 1 || p.length)}${ext || '.js'}`;
};