Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

repositories: splitted repositories into different panels #1785

Merged
merged 1 commit into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/assets/javascripts/modules/repositories/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,24 @@ $(() => {
data() {
return {
repositories: window.repositories,
teamRepositoriesNames: window.teamRepositoriesNames,
};
},

computed: {
teamRepositories() {
// eslint-disable-next-line
return this.repositories.filter((r) => {
return this.teamRepositoriesNames.indexOf(r.full_name) !== -1;
});
},

otherRepositories() {
// eslint-disable-next-line
return this.repositories.filter((r) => {
return this.teamRepositoriesNames.indexOf(r.full_name) === -1;
});
},
},
});
});
7 changes: 5 additions & 2 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ class RepositoriesController < ApplicationController
# GET /repositories
# GET /repositories.json
def index
@repositories = policy_scope(Repository).all
@repositories = policy_scope(Repository)
@repositories_serialized = API::Entities::Repositories.represent(
@repositories,
current_user: current_user,
type: :internal
).to_json
respond_with(@repositories)
@team_repositories = Repository
.joins(namespace: { team: :users })
.where("users.id = :user_id", user_id: current_user.id)
.map(&:full_name)
end

# GET /repositories/1
Expand Down
12 changes: 10 additions & 2 deletions app/views/repositories/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
.panel.panel-default.repositories-panel
.panel-heading
h5 Repositories
h5 Repositories via team membership
.panel-body
<repositories-table :repositories="repositories" repositories-path="#{repositories_path}" namespaces-path="#{namespaces_path}" :sortable="true" sort-by="name"></repositories-table>
<repositories-table :repositories="teamRepositories" repositories-path="#{repositories_path}" namespaces-path="#{namespaces_path}" :sortable="true" sort-by="name"></repositories-table>

- if (@repositories.count - @team_repositories.count) > 0
.panel.panel-default.repositories-panel
.panel-heading
h5 Other repositories
.panel-body
<repositories-table :repositories="otherRepositories" 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"
Expand All @@ -14,3 +21,4 @@
- content_for :js_header do
javascript:
window.repositories = #{raw @repositories_serialized};
window.teamRepositoriesNames = #{raw @team_repositories};
7 changes: 7 additions & 0 deletions spec/features/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def find_tag_checkbox(name)
expect(page).to have_css(selector)
expect(page).to have_current_path(repositories_path(page: 1))
end

it "doesn't show 'other repositories' panel when empty" do
visit repositories_path

expect(page).to have_content(repository.name)
expect(page).not_to have_content("Other repositories")
end
end

describe "repository#show" do
Expand Down