Commit 84c4834f authored by Filipa Lacerda's avatar Filipa Lacerda

Changes after review

parent b1874267
...@@ -30,44 +30,14 @@ ...@@ -30,44 +30,14 @@
...mapActions([ ...mapActions([
'setMainEndpoint', 'setMainEndpoint',
'fetchRepos', 'fetchRepos',
'fetchList',
'deleteRepo',
'deleteRegistry',
'toggleLoading',
]), ]),
fetchRegistryList(repo) {
this.fetchList({ repo })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
},
deleteRegistry(repo, registry) {
this.deleteRegistry(registry)
.then(() => this.fetchRegistry(repo))
.catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY));
},
deleteRepository(repo) {
this.deleteRepo(repo)
.then(() => this.fetchRepos())
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
},
showError(message) {
Flash(this.__(errorMessages[message]));
},
onPageChange(repo, page) {
this.fetchList({ repo, page })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
},
}, },
created() { created() {
this.setMainEndpoint(this.endpoint); this.setMainEndpoint(this.endpoint);
}, },
mounted() { mounted() {
this.fetchRepos() this.fetchRepos()
.catch(() => this.showError(errorMessagesTypes.FETCH_REPOS)); .catch(() => Flash(errorMessagesTypes.FETCH_REPOS));
}, },
}; };
</script> </script>
...@@ -83,10 +53,6 @@ ...@@ -83,10 +53,6 @@
v-for="(item, index) in repos" v-for="(item, index) in repos"
:key="index" :key="index"
:repo="item" :repo="item"
@fetchRegistryList="fetchRegistryList"
@deleteRepository="deleteRepository"
@deleteRegistry="deleteRegistry"
@pageChange="onPageChange"
/> />
<p v-else-if="!isLoading && !repos.length"> <p v-else-if="!isLoading && !repos.length">
......
<script> <script>
import { mapActions } from 'vuex';
import { n__, s__ } from '../../locale';
import clipboardButton from '../../vue_shared/components/clipboard_button.vue'; import clipboardButton from '../../vue_shared/components/clipboard_button.vue';
import loadingIcon from '../../vue_shared/components/loading_icon.vue'; import loadingIcon from '../../vue_shared/components/loading_icon.vue';
import tablePagination from '../../vue_shared/components/table_pagination.vue'; import tablePagination from '../../vue_shared/components/table_pagination.vue';
import tooltip from '../../vue_shared/directives/tooltip'; import tooltip from '../../vue_shared/directives/tooltip';
import timeagoMixin from '../../vue_shared/mixins/timeago'; import timeagoMixin from '../../vue_shared/mixins/timeago';
import { errorMessages, errorMessagesTypes } from '../constants';
export default { export default {
name: 'collapsibeContainerRegisty', name: 'collapsibeContainerRegisty',
...@@ -35,28 +38,49 @@ ...@@ -35,28 +38,49 @@
}, },
}, },
methods: { methods: {
...mapActions([
'fetchList',
'deleteRepo',
'deleteRegistry',
'toggleLoading',
]),
layers(item) { layers(item) {
const pluralize = gl.text.pluralize('layer', item.layers); const pluralize = n__('layer', 'layers', item.layers);
return `${item.layers} ${pluralize}`; return `${item.layers} ${pluralize}`;
}, },
toggleRepo() { toggleRepo() {
if (this.isOpen === false) { if (this.isOpen === false) {
this.$emit('fetchRegistryList', this.repo); this.fetchList({ repo: this.repo })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
} }
this.isOpen = !this.isOpen; this.isOpen = !this.isOpen;
}, },
handleDeleteRepository() { handleDeleteRepository() {
this.$emit('deleteRepository', this.repo); this.deleteRepo(this.repo)
.then(() => this.fetchRepos())
.catch(() => this.showError(errorMessagesTypes.DELETE_REPO));
}, },
handleDeleteRegistry(registry) { handleDeleteRegistry(registry) {
this.$emit('deleteRegistry', this.repo, registry); this.deleteRegistry(registry)
.then(() => this.fetchRegistry(this.repo))
.catch(() => this.showError(errorMessagesTypes.DELETE_REGISTRY));
}, },
onPageChange(pageNumber) { onPageChange(pageNumber) {
this.$emit('pageChange', this.repo, pageNumber); this.fetchList({ repo: this.repo, page })
.catch(() => this.showError(errorMessagesTypes.FETCH_REGISTRY));
},
clipboardText(text) {
return `docker pull ${text}`;
},
showError(message) {
Flash((errorMessages[message]));
}, },
}, },
}; };
...@@ -66,10 +90,10 @@ ...@@ -66,10 +90,10 @@
<div class="container-image"> <div class="container-image">
<div <div
class="container-image-head"> class="container-image-head">
<a <button
role="button" type="button"
@click="toggleRepo" @click="toggleRepo"
class="js-toggle-repo"> class="js-toggle-repo btn-link">
<i <i
class="fa" class="fa"
:class="{ :class="{
...@@ -79,11 +103,11 @@ ...@@ -79,11 +103,11 @@
aria-hidden="true"> aria-hidden="true">
</i> </i>
{{repo.name}} {{repo.name}}
</a> </button>
<clipboard-button <clipboard-button
v-if="repo.location" v-if="repo.location"
:text="__(`docker pull ${repo.location}`)" :text="clipboardText(repo.location)"
:title="repo.location" :title="repo.location"
/> />
...@@ -91,8 +115,9 @@ ...@@ -91,8 +115,9 @@
<button <button
v-if="repo.canDelete" v-if="repo.canDelete"
type="button" type="button"
class="js-remove-repo btn btn-remove" class="js-remove-repo btn btn-danger"
:title="__('Remove repository')" :title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
v-tooltip v-tooltip
@click="handleDeleteRepository"> @click="handleDeleteRepository">
<i <i
...@@ -116,10 +141,10 @@ ...@@ -116,10 +141,10 @@
<table class="table tags"> <table class="table tags">
<thead> <thead>
<tr> <tr>
<th>{{__("Tag")}}</th> <th>{{s__('ContainerRegistry|Tag')}}</th>
<th>{{__("Tag ID")}}</th> <th>{{s__('ContainerRegistry|Tag ID')}}</th>
<th>{{__("Size")}}</th> <th>{{s__("ContainerRegistry|Size")}}</th>
<th>{{__("Created")}}</th> <th>{{s__("ContainerRegistry|Created")}}</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
...@@ -134,7 +159,7 @@ ...@@ -134,7 +159,7 @@
<clipboard-button <clipboard-button
v-if="item.location" v-if="item.location"
:title="item.location" :title="item.location"
:text="__(`docker pull ${item.location}`)" :text="clipboardText(item.location)"
/> />
</td> </td>
<td> <td>
...@@ -173,8 +198,9 @@ ...@@ -173,8 +198,9 @@
<button <button
v-if="item.canDelete" v-if="item.canDelete"
type="button" type="button"
class="js-delete-registry btn btn-remove hidden-xs pull-right" class="js-delete-registry btn btn-danger hidden-xs pull-right"
:title="__('Remove tag')" :title="s__('ContainerRegistry|Remove tag')"
:aria-label="s__('ContainerRegistry|Remove tag')"
data-container="body" data-container="body"
v-tooltip v-tooltip
@click="handleDeleteRegistry(item)"> @click="handleDeleteRegistry(item)">
...@@ -197,7 +223,7 @@ ...@@ -197,7 +223,7 @@
<div <div
v-else v-else
class="nothing-here-block"> class="nothing-here-block">
{{__("No tags in Container Registry for this container image.")}} {{s__("ContainerRegistry|No tags in Container Registry for this container image.")}}
</div> </div>
</div> </div>
</div> </div>
......
import { __ } from '../locale';
export const errorMessagesTypes = { export const errorMessagesTypes = {
FETCH_REGISTRY: 'FETCH_REGISTRY', FETCH_REGISTRY: 'FETCH_REGISTRY',
FETCH_REPOS: 'FETCH_REPOS', FETCH_REPOS: 'FETCH_REPOS',
...@@ -6,8 +8,8 @@ export const errorMessagesTypes = { ...@@ -6,8 +8,8 @@ export const errorMessagesTypes = {
}; };
export const errorMessages = { export const errorMessages = {
[errorMessagesTypes.FETCH_REGISTRY]: 'Something went wrong while fetching the registry list.', [errorMessagesTypes.FETCH_REGISTRY]: __('Something went wrong while fetching the registry list.'),
[errorMessagesTypes.FETCH_REPOS]: 'Something went wrong while fetching the repositories.', [errorMessagesTypes.FETCH_REPOS]: __('Something went wrong while fetching the repositories.'),
[errorMessagesTypes.DELETE_REPO]: 'Something went wrong while deleting the repository.', [errorMessagesTypes.DELETE_REPO]: __('Something went wrong while deleting the repository.'),
[errorMessagesTypes.DELETE_REGISTRY]: 'Something went wrong while deleting registry.', [errorMessagesTypes.DELETE_REGISTRY]: __('Something went wrong while deleting registry.'),
}; };
...@@ -9,6 +9,14 @@ ...@@ -9,6 +9,14 @@
.container-image-head { .container-image-head {
padding: 0 16px; padding: 0 16px;
line-height: 4em; line-height: 4em;
.btn-link {
padding: 0;
&:focus {
outline: none;
}
}
} }
.table.tags { .table.tags {
......
...@@ -15,4 +15,4 @@ ...@@ -15,4 +15,4 @@
.registry-placeholder { .registry-placeholder {
min-height: 60px; min-height: 60px;
} }
\ No newline at end of file
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
%h4 %h4
= page_title = page_title
%p %p
= _('With the Docker Container Registry integrated into GitLab, every project can have its own space to store its Docker images.') = s_('ContainerRegistry|With the Docker Container Registry integrated into GitLab, every project can have its own space to store its Docker images.')
%p.append-bottom-0 %p.append-bottom-0
= succeed '.' do = succeed '.' do
= _('Learn more about') = s_('ContainerRegistry|Learn more about')
= link_to _('Container Registry'), help_page_path('user/project/container_registry'), target: '_blank' = link_to _('Container Registry'), help_page_path('user/project/container_registry'), target: '_blank'
.row.registry-placeholder.prepend-bottom-10 .row.registry-placeholder.prepend-bottom-10
.col-lg-12 .col-lg-12
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
%h4.panel-title %h4.panel-title
= _('How to use the Container Registry') = s_('ContainerRegistry|How to use the Container Registry')
.panel-body .panel-body
%p %p
= _('First log in to GitLab&rsquo;s Container Registry using your GitLab username and password. If you have').html_safe = _('First log in to GitLab&rsquo;s Container Registry using your GitLab username and password. If you have').html_safe
......
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