debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/changed_file_icon.vue

105 lines
2.2 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlTooltipDirective, GlIcon } from '@gitlab/ui';
2020-06-23 00:09:42 +05:30
import getCommitIconMap from '~/ide/commit_icon';
2020-04-08 14:13:33 +05:30
import { __ } from '~/locale';
2018-05-09 12:01:36 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2018-10-15 14:42:47 +05:30
},
directives: {
2019-02-15 15:39:39 +05:30
GlTooltip: GlTooltipDirective,
2018-05-09 12:01:36 +05:30
},
props: {
file: {
type: Object,
required: true,
},
2018-10-15 14:42:47 +05:30
showTooltip: {
type: Boolean,
required: false,
default: false,
},
showStagedIcon: {
type: Boolean,
required: false,
2019-12-04 20:38:33 +05:30
default: true,
2018-10-15 14:42:47 +05:30
},
2018-12-05 23:21:45 +05:30
size: {
type: Number,
required: false,
default: 12,
},
2019-07-07 11:18:12 +05:30
isCentered: {
type: Boolean,
required: false,
default: true,
},
2018-05-09 12:01:36 +05:30
},
computed: {
changedIcon() {
2019-10-12 21:52:04 +05:30
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
2020-04-22 19:07:51 +05:30
// eslint-disable-next-line @gitlab/require-i18n-strings
2020-03-13 15:44:24 +05:30
const suffix = this.file.staged && this.showStagedIcon ? '-solid' : '';
2018-11-18 11:00:15 +05:30
return `${getCommitIconMap(this.file).icon}${suffix}`;
2018-05-09 12:01:36 +05:30
},
changedIconClass() {
2018-12-05 23:21:45 +05:30
return `${this.changedIcon} float-left d-block`;
2018-10-15 14:42:47 +05:30
},
tooltipTitle() {
2020-04-08 14:13:33 +05:30
if (!this.showTooltip) {
return undefined;
} else if (this.file.deleted) {
return __('Deleted');
} else if (this.file.tempFile) {
return __('Added');
} else if (this.file.changed) {
return __('Modified');
2018-10-15 14:42:47 +05:30
}
2020-04-08 14:13:33 +05:30
return undefined;
2018-05-09 12:01:36 +05:30
},
2018-11-18 11:00:15 +05:30
showIcon() {
2019-12-21 20:55:43 +05:30
return (
this.file.changed ||
this.file.tempFile ||
this.file.staged ||
this.file.deleted ||
this.file.prevPath
);
2018-11-18 11:00:15 +05:30
},
2018-05-09 12:01:36 +05:30
},
};
</script>
<template>
2019-07-07 11:18:12 +05:30
<span
v-gl-tooltip.right
:title="tooltipTitle"
:class="{ 'ml-auto': isCentered }"
2019-10-12 21:52:04 +05:30
class="file-changed-icon d-inline-block"
2021-03-08 18:12:59 +05:30
data-qa-selector="changed_file_icon_content"
:data-qa-title="tooltipTitle"
2019-07-07 11:18:12 +05:30
>
2021-09-30 23:02:18 +05:30
<gl-icon v-if="showIcon" :name="changedIcon" :size="size" :class="changedIconClass" />
2018-10-15 14:42:47 +05:30
</span>
2018-05-09 12:01:36 +05:30
</template>
2018-12-05 23:21:45 +05:30
<style>
.file-addition,
.file-addition-solid {
color: #1aaa55;
}
.file-modified,
.file-modified-solid {
color: #fc9403;
}
.file-deletion,
.file-deletion-solid {
color: #db3b21;
}
</style>