Commit aa52dc14 authored by Thomas Randolph's avatar Thomas Randolph

Display a symlink icon for repository file symlinks

parent 9e1df20a
<script> <script>
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import getIconForFile from './file_icon/file_icon_map'; import getIconForFile from './file_icon/file_icon_map';
import { FILE_SYMLINK_MODE } from '../constants';
/* This is a re-usable vue component for rendering a svg sprite /* This is a re-usable vue component for rendering a svg sprite
icon icon
...@@ -25,9 +26,9 @@ export default { ...@@ -25,9 +26,9 @@ export default {
required: true, required: true,
}, },
fileMode: { fileMode: {
type: Number, type: String,
required: false, required: false,
default: -1 default: '',
}, },
folder: { folder: {
...@@ -65,8 +66,12 @@ export default { ...@@ -65,8 +66,12 @@ export default {
}, },
}, },
computed: { computed: {
isSymlink() {
return this.fileMode === FILE_SYMLINK_MODE;
},
spriteHref() { spriteHref() {
const iconName = this.submodule ? 'folder-git' : getIconForFile(this.fileName) || 'file'; const iconName = this.submodule ? 'folder-git' : getIconForFile(this.fileName) || 'file';
return `${gon.sprite_file_icons}#${iconName}`; return `${gon.sprite_file_icons}#${iconName}`;
}, },
folderIconName() { folderIconName() {
...@@ -80,13 +85,11 @@ export default { ...@@ -80,13 +85,11 @@ export default {
</script> </script>
<template> <template>
<span> <span>
<svg v-if="!loading && !folder" :class="[iconSizeClass, cssClasses]"> <gl-loading-icon v-if="loading" :inline="true" />
<use v-bind="{ 'xlink:href': spriteHref }" /></svg <gl-icon v-else-if="isSymlink" name="symlink" :size="size" />
><gl-icon <svg v-else-if="!folder" :class="[iconSizeClass, cssClasses]">
v-if="!loading && folder" <use v-bind="{ 'xlink:href': spriteHref }" />
:name="folderIconName" </svg>
:size="size" <gl-icon v-else :name="folderIconName" :size="size" class="folder-icon" />
class="folder-icon"
/><gl-loading-icon v-if="loading" :inline="true" />
</span> </span>
</template> </template>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment