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

index.js « blob_viewers « components « repository « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8f6f2d15215a900b7f463e6782e917e416d53c7e (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
37
38
39
40
41
42
43
44
45
46
47
48
export const loadViewer = (type) => {
  switch (type) {
    case 'empty':
      return () => import(/* webpackChunkName: 'blob_empty_viewer' */ './empty_viewer.vue');
    case 'text':
      return gon.features.highlightJs
        ? () =>
            import(
              /* webpackChunkName: 'blob_text_viewer' */ '~/vue_shared/components/source_viewer.vue'
            )
        : null;
    case 'download':
      return () => import(/* webpackChunkName: 'blob_download_viewer' */ './download_viewer.vue');
    case 'image':
      return () => import(/* webpackChunkName: 'blob_image_viewer' */ './image_viewer.vue');
    case 'video':
      return () => import(/* webpackChunkName: 'blob_video_viewer' */ './video_viewer.vue');
    case 'pdf':
      return () => import(/* webpackChunkName: 'blob_pdf_viewer' */ './pdf_viewer.vue');
    default:
      return null;
  }
};

export const viewerProps = (type, blob) => {
  return {
    text: {
      content: blob.rawTextBlob,
      autoDetect: true, // We'll eventually disable autoDetect and pass the language explicitly to reduce the footprint (https://gitlab.com/gitlab-org/gitlab/-/issues/348145)
    },
    download: {
      fileName: blob.name,
      filePath: blob.rawPath,
      fileSize: blob.rawSize,
    },
    image: {
      url: blob.rawPath,
      alt: blob.name,
    },
    video: {
      url: blob.rawPath,
    },
    pdf: {
      url: blob.rawPath,
      fileSize: blob.rawSize,
    },
  }[type];
};