This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repositories: migrated to vue and exposed on menu
The default pagination limit was also changed to `10`.
- Loading branch information
1 parent
9f8150f
commit 1103a1a
Showing
14 changed files
with
273 additions
and
18 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/assets/javascripts/modules/repositories/components/table-row.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import moment from 'moment'; | ||
|
||
export default { | ||
template: '#js-repository-table-row-tmpl', | ||
|
||
props: ['repository', 'repositoriesPath', 'namespacesPath'], | ||
|
||
computed: { | ||
scopeClass() { | ||
return `repository_${this.repository.id}`; | ||
}, | ||
|
||
repositoryPath() { | ||
return `${this.repositoriesPath}/${this.repository.id}`; | ||
}, | ||
|
||
namespacePath() { | ||
return `${this.namespacesPath}/${this.repository.namespace.id}`; | ||
}, | ||
|
||
updatedAt() { | ||
return moment(this.repository.updated_at).format('MMMM DD, YYYY HH:mm'); | ||
}, | ||
}, | ||
}; |
57 changes: 57 additions & 0 deletions
57
app/assets/javascripts/modules/repositories/components/table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import getProperty from 'lodash/get'; | ||
|
||
import Comparator from '~/utils/comparator'; | ||
|
||
import TableSortableMixin from '~/shared/mixins/table-sortable'; | ||
import TablePaginatedMixin from '~/shared/mixins/table-paginated'; | ||
|
||
import RepositoryTableRow from './table-row'; | ||
|
||
export default { | ||
template: '#js-repositories-table-tmpl', | ||
|
||
props: { | ||
repositories: { | ||
type: Array, | ||
}, | ||
repositoriesPath: { | ||
type: String, | ||
}, | ||
namespacesPath: { | ||
type: String, | ||
}, | ||
prefix: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
|
||
mixins: [TableSortableMixin, TablePaginatedMixin], | ||
|
||
components: { | ||
RepositoryTableRow, | ||
}, | ||
|
||
computed: { | ||
filteredRepositories() { | ||
const order = this.sorting.asc ? 1 : -1; | ||
const sortedRepositories = [...this.repositories]; | ||
const sample = sortedRepositories[0]; | ||
const value = getProperty(sample, this.sorting.by); | ||
const comparator = Comparator.of(value); | ||
|
||
// sorting | ||
sortedRepositories.sort((a, b) => { | ||
const aValue = getProperty(a, this.sorting.by); | ||
const bValue = getProperty(b, this.sorting.by); | ||
|
||
return order * comparator(aValue, bValue); | ||
}); | ||
|
||
// pagination | ||
const slicedTeams = sortedRepositories.slice(this.offset, this.limit * this.currentPage); | ||
|
||
return slicedTeams; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import './pages/index'; | ||
import './pages/show'; |
24 changes: 24 additions & 0 deletions
24
app/assets/javascripts/modules/repositories/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Vue from 'vue'; | ||
|
||
import RepositoriesTable from '../components/table'; | ||
|
||
$(() => { | ||
if (!$('body[data-route="repositories/index"]').length) { | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line no-new | ||
new Vue({ | ||
el: 'body[data-route="repositories/index"] .vue-root', | ||
|
||
components: { | ||
RepositoriesTable, | ||
}, | ||
|
||
data() { | ||
return { | ||
repositories: window.repositories, | ||
}; | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ export default { | |
props: { | ||
limit: { | ||
type: Number, | ||
default: 3, | ||
default: 10, | ||
}, | ||
}, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.table-responsive | ||
table.table.table-striped.table-hover :class=="{'table-sortable': sortable}" | ||
thead | ||
tr | ||
th @click=="sort('name')" | ||
i.fa.fa-fw.fa-sort{ | ||
:class=="{ | ||
'fa-sort-amount-asc': sorting.by === 'name' && sorting.asc, | ||
'fa-sort-amount-desc': sorting.by === 'name' && !sorting.asc, | ||
}" | ||
} | ||
| Repository | ||
|
||
th @click=="sort('namespace.name')" | ||
i.fa.fa-fw.fa-sort{ | ||
:class=="{ | ||
'fa-sort-amount-asc': sorting.by === 'namespace.name' && sorting.asc, | ||
'fa-sort-amount-desc': sorting.by === 'namespace.name' && !sorting.asc, | ||
}" | ||
} | ||
| Namespace | ||
th @click=="sort('tags_count')" | ||
i.fa.fa-fw.fa-sort{ | ||
:class=="{ | ||
'fa-sort-amount-asc': sorting.by === 'tags_count' && sorting.asc, | ||
'fa-sort-amount-desc': sorting.by === 'tags_count' && !sorting.asc, | ||
}" | ||
} | ||
| # Tags | ||
th @click=="sort('updated_at')" | ||
i.fa.fa-fw.fa-sort{ | ||
:class=="{ | ||
'fa-sort-amount-asc': sorting.by === 'updated_at' && sorting.asc, | ||
'fa-sort-amount-desc': sorting.by === 'updated_at' && !sorting.asc, | ||
}" | ||
} | ||
| Updated at | ||
tbody | ||
<repository-table-row v-for="repository in filteredRepositories" :key="repository.id" :repository="repository" :repositories-path="repositoriesPath" :namespaces-path="namespacesPath"></repository-table-row> | ||
|
||
<table-pagination :total.sync="repositories.length" :current-page="currentPage" :itens-per-page.sync="limit" @update="updateCurrentPage"></table-pagination> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tr :class="scopeClass" | ||
td | ||
a :href="repositoryPath" | ||
| {{ repository.name }} | ||
td | ||
a :href="namespacePath" | ||
| {{ repository.namespace.name }} | ||
td | ||
| {{ repository.tags_count }} | ||
td | ||
| {{ updatedAt }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
.panel.panel-default | ||
.panel.panel-default.repositories-panel | ||
.panel-heading | ||
| Repositories | ||
h5 Repositories | ||
.panel-body | ||
.table-responsive | ||
table.table.table-striped.table-hover | ||
thead | ||
tr | ||
th Namespace | ||
th Repository | ||
tbody | ||
- @repositories.each do |repository| | ||
tr | ||
td= link_to repository.namespace.clean_name, repository.namespace | ||
td= link_to repository.name, repository | ||
<repositories-table :repositories="repositories" repositories-path="#{repositories_path}" namespaces-path="#{namespaces_path}" :sortable="true" sort-by="name"></repositories-table> | ||
|
||
- content_for :js_body do | ||
script#js-repositories-table-tmpl type="text/x-template" | ||
= render "repositories/components/table" | ||
|
||
script#js-repository-table-row-tmpl type="text/x-template" | ||
= render "repositories/components/table_row" | ||
|
||
- content_for :js_header do | ||
javascript: | ||
window.repositories = #{raw @repositories_serialized}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters