Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « explorer « container_registry « packages_and_registries « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7ed4ff52b06e38644bb1931a16bd4b3213e4debf (plain)
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
36
import { approximateDuration, calculateRemainingMilliseconds } from '~/lib/utils/datetime_utility';
import { GRAPHQL_PAGE_SIZE } from './constants/index';

export const getImageName = (image = {}) => {
  return image.name || image.project?.path;
};

export const timeTilRun = (time) => {
  if (!time) return '';

  const difference = calculateRemainingMilliseconds(time);
  return approximateDuration(difference / 1000);
};

export const getNextPageParams = (cursor) => ({
  after: cursor,
  first: GRAPHQL_PAGE_SIZE,
});

export const getPreviousPageParams = (cursor) => ({
  first: null,
  before: cursor,
  last: GRAPHQL_PAGE_SIZE,
});

export const getPageParams = (pageInfo = {}) => {
  if (pageInfo.before) {
    return getPreviousPageParams(pageInfo.before);
  }

  if (pageInfo.after) {
    return getNextPageParams(pageInfo.after);
  }

  return {};
};