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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.2 KiB
Vue
Raw Normal View History

2021-09-30 23:02:18 +05:30
<script>
import { GlAvatar } from '@gitlab/ui';
2022-08-27 11:52:29 +05:30
import { getIdFromGraphQLId, isGid } from '~/graphql_shared/utils';
2022-06-21 17:19:12 +05:30
import { AVATAR_SHAPE_OPTION_RECT } from '~/vue_shared/constants';
2021-09-30 23:02:18 +05:30
export default {
components: {
GlAvatar,
},
props: {
2022-08-27 11:52:29 +05:30
projectId: {
type: [Number, String],
default: 0,
required: false,
validator(value) {
return typeof value === 'string' ? isGid(value) : true;
},
},
2021-09-30 23:02:18 +05:30
projectName: {
type: String,
required: true,
},
projectAvatarUrl: {
type: String,
required: false,
default: '',
},
size: {
type: Number,
default: 32,
required: false,
},
alt: {
type: String,
required: false,
default: undefined,
},
},
computed: {
avatarAlt() {
return this.alt ?? this.projectName;
},
2022-08-27 11:52:29 +05:30
entityId() {
return isGid(this.projectId) ? getIdFromGraphQLId(this.projectId) : this.projectId;
},
2021-09-30 23:02:18 +05:30
},
2022-06-21 17:19:12 +05:30
AVATAR_SHAPE_OPTION_RECT,
2021-09-30 23:02:18 +05:30
};
</script>
<template>
<gl-avatar
2022-06-21 17:19:12 +05:30
:shape="$options.AVATAR_SHAPE_OPTION_RECT"
2022-08-27 11:52:29 +05:30
:entity-id="entityId"
2021-09-30 23:02:18 +05:30
:entity-name="projectName"
:src="projectAvatarUrl"
:alt="avatarAlt"
:size="size"
/>
</template>