diff --git a/app/assets/javascripts/ml/model_registry/apps/show_ml_model.vue b/app/assets/javascripts/ml/model_registry/apps/show_ml_model.vue index 27346956a838af2f188bc843c6cc1433ffa94b45..4f77d9c481768ccca4d216f12d737300ab08c5d9 100644 --- a/app/assets/javascripts/ml/model_registry/apps/show_ml_model.vue +++ b/app/assets/javascripts/ml/model_registry/apps/show_ml_model.vue @@ -1,7 +1,7 @@ <script> import { GlAvatar, GlBadge, GlButton, GlTab, GlTabs, GlSprintf, GlIcon, GlLink } from '@gitlab/ui'; import VueRouter from 'vue-router'; -import { n__, s__, sprintf } from '~/locale'; +import { __, n__, s__, sprintf } from '~/locale'; import TitleArea from '~/vue_shared/components/registry/title_area.vue'; import { MODEL_ENTITIES } from '~/ml/model_registry/constants'; import ModelVersionList from '~/ml/model_registry/components/model_version_list.vue'; @@ -219,6 +219,7 @@ export default { versionCountTitle: s__('MlModelRegistry|Total versions'), latestVersionTitle: s__('MlModelRegistry|Latest version'), authorTitle: s__('MlModelRegistry|Publisher'), + noneText: __('None'), }, modelVersionEntity: MODEL_ENTITIES.modelVersion, ROUTE_DETAILS, @@ -312,8 +313,9 @@ export default { <div class="gl-pt-6 md:gl-col-span-1"> <div> <div class="gl-text-lg gl-font-bold">{{ $options.i18n.authorTitle }}</div> - <div v-if="showModelAuthor" class="gl-pt-2 gl-text-subtle"> + <div class="gl-pt-2 gl-text-subtle" data-testid="sidebar-author"> <gl-link + v-if="showModelAuthor" data-testid="sidebar-author-link" class="js-user-link gl-font-bold !gl-text-subtle" :href="model.author.webUrl" @@ -321,25 +323,29 @@ export default { <gl-avatar :label="model.author.name" :src="model.author.avatarUrl" :size="24" /> {{ model.author.name }} </gl-link> + <span v-else>{{ $options.i18n.noneText }}</span> </div> </div> - <div v-if="showModelLatestVersion" class="gl-mt-5" data-testid="latest-version-label"> + <div class="gl-mt-5"> <div class="gl-text-lg gl-font-bold">{{ $options.i18n.latestVersionTitle }}</div> - <div class="gl-pt-2 gl-text-subtle"> + <div class="gl-pt-2 gl-text-subtle" data-testid="sidebar-latest-version"> <gl-link + v-if="showModelLatestVersion" data-testid="sidebar-latest-version-link" :href="model.latestVersion._links.showPath" > {{ model.latestVersion.version }} </gl-link> + <span v-else>{{ $options.i18n.noneText }}</span> </div> </div> <div class="gl-mt-5"> <div class="gl-text-lg gl-font-bold">{{ $options.i18n.versionCountTitle }}</div> - <div v-if="showCreatedDetail" class="gl-pt-2 gl-text-subtle"> - <span data-testid="sidebar-version-count"> + <div class="gl-pt-2 gl-text-subtle" data-testid="sidebar-version-count"> + <span v-if="versionCount"> {{ versionCount }} </span> + <span v-else>{{ $options.i18n.noneText }}</span> </div> </div> </div> diff --git a/app/assets/javascripts/ml/model_registry/apps/show_ml_model_version.vue b/app/assets/javascripts/ml/model_registry/apps/show_ml_model_version.vue index 3e8a3baafee11c72ee762eeb999a574ed2313e1b..d7c72780c7fb70dcd05a8cc0f227f27f0006e851 100644 --- a/app/assets/javascripts/ml/model_registry/apps/show_ml_model_version.vue +++ b/app/assets/javascripts/ml/model_registry/apps/show_ml_model_version.vue @@ -239,6 +239,7 @@ export default { artifacts: s__('MlModelRegistry|Artifacts'), performance: s__('MlModelRegistry|Performance'), }, + noneText: __('None'), }, ROUTE_DETAILS, ROUTE_ARTIFACTS, @@ -321,8 +322,9 @@ export default { <div class="gl-pt-6 md:gl-col-span-1"> <div class="gl-text-lg gl-font-bold">{{ $options.i18n.authorTitle }}</div> - <div v-if="showAuthor" class="gl-mt-3 gl-text-subtle"> + <div class="gl-mt-3 gl-text-subtle" data-testid="sidebar-author"> <gl-link + v-if="showAuthor" data-testid="sidebar-author-link" class="js-user-link gl-font-bold !gl-text-subtle" :href="author.webUrl" @@ -330,6 +332,7 @@ export default { <gl-avatar :label="author.name" :src="author.avatarUrl" :size="24" /> {{ author.name }} </gl-link> + <span v-else>{{ $options.i18n.noneText }}</span> </div> </div> </div> diff --git a/spec/frontend/ml/model_registry/apps/show_ml_model_spec.js b/spec/frontend/ml/model_registry/apps/show_ml_model_spec.js index 522a3733d2cfc2da9cf677d52c057bb1d732632f..d9374c03d042b952d00b3435912e937209a66678 100644 --- a/spec/frontend/ml/model_registry/apps/show_ml_model_spec.js +++ b/spec/frontend/ml/model_registry/apps/show_ml_model_spec.js @@ -380,7 +380,7 @@ describe('ml/model_registry/apps/show_ml_model', () => { it('does not display sidebar latest version link when model does not have a latest version', () => { createWrapper({ latestVersion: null }); expect(findLatestVersionLink().exists()).toBe(false); - expect(wrapper.findByTestId('latest-version-label').exists()).toBe(false); + expect(wrapper.findByTestId('sidebar-latest-version').text()).toBe('None'); }); }); @@ -401,7 +401,7 @@ describe('ml/model_registry/apps/show_ml_model', () => { }); it('does not display sidebar version count', () => { - expect(findVersionCount().exists()).toBe(false); + expect(findVersionCount().text()).toBe('None'); }); }); }); diff --git a/spec/frontend/ml/model_registry/apps/show_ml_model_version_spec.js b/spec/frontend/ml/model_registry/apps/show_ml_model_version_spec.js index 2f606e106160c78c716b649a72bb5dea342a8728..1bacd469687da0e7bc6cacc30452965282ee7d98 100644 --- a/spec/frontend/ml/model_registry/apps/show_ml_model_version_spec.js +++ b/spec/frontend/ml/model_registry/apps/show_ml_model_version_spec.js @@ -176,6 +176,7 @@ describe('ml/model_registry/apps/show_model_version.vue', () => { createWrapper({ resolver: jest.fn().mockRejectedValue(new Error('Failure!')) }); await waitForPromises(); expect(findSidebarAuthorLink().exists()).toBe(false); + expect(wrapper.findByTestId('sidebar-author').text()).toBe('None'); }); }); });