#446: updated UI, logic

This commit is contained in:
Vokhmin Alexey V 2015-01-14 02:17:23 +03:00
parent fe8d24eb99
commit 8cd175c840
9 changed files with 115 additions and 50 deletions

View File

@ -89,4 +89,5 @@ $(document).ready(function() {
$(this).button('loading'); $(this).button('loading');
}); });
$('[data-toggle="tooltip"]').tooltip();
}); });

View File

@ -48,6 +48,9 @@ class Projects::ProjectsController < Projects::BaseController
end end
def edit def edit
@project_aliases = Project.where.not(id: @project.id).
where('alias_from_id IN (:ids) OR id IN (:ids)', { ids: [@project.alias_from_id, @project.id] }).
paginate(page: current_page)
end end
def create def create

View File

@ -134,6 +134,14 @@ module Git
protected protected
def aliases_path
File.join(APP_CONFIG['git_path'], 'git_projects', '.aliases')
end
def alias_path
File.join(aliases_path, "#{alias_from_id}.git")
end
def build_path(dir) def build_path(dir)
File.join(APP_CONFIG['git_path'], 'git_projects', "#{dir}.git") File.join(APP_CONFIG['git_path'], 'git_projects', "#{dir}.git")
end end
@ -158,9 +166,7 @@ module Git
# Do nothing if GIT repo already exist # Do nothing if GIT repo already exist
unless dummy unless dummy
if alias_from_id if alias_from_id
aliases_path = File.join(APP_CONFIG['git_path'], 'git_projects', '.aliases')
FileUtils.mkdir_p(aliases_path) FileUtils.mkdir_p(aliases_path)
alias_path = File.join(aliases_path, "#{alias_from_id}.git")
if !Dir.exists?(alias_path) && alias_from if !Dir.exists?(alias_path) && alias_from
# Move GIT repo into aliases # Move GIT repo into aliases
FileUtils.mv(alias_from.path, alias_path, force: true) FileUtils.mv(alias_from.path, alias_path, force: true)
@ -178,6 +184,10 @@ module Git
def destroy_git_repo def destroy_git_repo
FileUtils.rm_rf path FileUtils.rm_rf path
return unless alias_from_id
unless Project.where.not(id: id).where(alias_from_id: alias_from_id).exists?
FileUtils.rm_rf alias_path
end
end end
def write_hook def write_hook

View File

@ -1,44 +0,0 @@
- content_for :submenu do
- act = action_name.to_sym; contr = controller_name.to_sym; treeish = @project.default_head(params[:treeish])
%nav.navbar.navbar-default{ role: 'navigation' }
.container-fluid
/ Brand and toggle get grouped for better mobile display
.navbar-header
%button.navbar-toggle{ 'data-target' => '#submenu-navbar-collapse', 'data-toggle' => 'collapse', type: 'button' }
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
.navbar-brand
= fa_visibility_icon @project
= link_to @project.owner.uname, @project.owner
\/
= link_to @project.name, project_path(@project)
/ Collect the nav links, forms, and other content for toggling
#submenu-navbar-collapse.collapse.navbar-collapse
%ul.nav.navbar-nav.left-border
- if @project.parent
%li
= link_to project_path(@project.parent), class: 'small' do
= fa_icon 'code-fork'
= @project.parent.name_with_owner
%li{ class: ('active' if act.in?([:show, :edit, :branches, :tags]) && contr.in?([:trees, :blobs]) || contr == :commits) }
= link_to t('project_menu.code'), tree_path(@project, treeish)
- if @project.is_package and can?(:read, @project => BuildList)
%li{ class: ('active' if contr == :build_lists) }
= link_to t('project_menu.builds'), project_build_lists_path(@project)
- if @project.has_issues
%li{ class: ('active' if contr == :issues && act == :index) }
= link_to t('project_menu.tracker', count: @opened_issues_count), project_issues_path(@project)
%li{ class: ('active' if contr == :issues && act == :pull_requests) }
=link_to t('project_menu.pull_requests', count: @opened_pull_requests_count), project_pull_requests_path(@project)
- if @project.has_wiki
%li{ class: ('active' if contr == :wiki) }
= link_to t('project_menu.wiki'), project_wiki_index_path(@project)
%li=# link_to t('project_menu.readme'), '#' #pending
- if can? :update, @project
%li{ class: ('active' if act.in?(%i[edit update sections]) && contr == :projects) }
= link_to t('project_menu.settings'), edit_project_path(@project)
/ /.navbar-collapse
/ /.container-fluid

View File

@ -0,0 +1,50 @@
- content_for :submenu do
- act = action_name.to_sym; contr = controller_name.to_sym; treeish = @project.default_head(params[:treeish])
nav.navbar.navbar-default role='navigation'
.container-fluid
/ Brand and toggle get grouped for better mobile display
.navbar-header
button.navbar-toggle data-target='#submenu-navbar-collapse' data-toggle='collapse' type='button'
span.sr-only Toggle navigation
span.icon-bar
span.icon-bar
span.icon-bar
.navbar-brand
= fa_visibility_icon @project
= link_to @project.owner.uname, @project.owner
| /
= link_to @project.name, project_path(@project)
/ Collect the nav links, forms, and other content for toggling
#submenu-navbar-collapse.collapse.navbar-collapse
ul.nav.navbar-nav.left-border
- if @project.parent
- is_alias = @project.alias_from_id.present?
- tooltip_title = t(".tooltips.#{is_alias ? 'alias' : 'fork' }", name: @project.parent.name_with_owner)
li data-toggle='tooltip' data-placement='bottom' title=tooltip_title
= link_to project_path(@project.parent), class: 'small' do
- if is_alias
= fa_icon 'share-alt'
- else
= fa_icon 'code-fork'
=< @project.parent.name_with_owner
li class=('active' if act.in?([:show, :edit, :branches, :tags]) && contr.in?([:trees, :blobs]) || contr == :commits)
= link_to t('project_menu.code'), tree_path(@project, treeish)
- if @project.is_package and can?(:read, @project => BuildList)
li class=('active' if contr == :build_lists)
= link_to t('project_menu.builds'), project_build_lists_path(@project)
- if @project.has_issues
li class=('active' if contr == :issues && act == :index)
= link_to t('project_menu.tracker', count: @opened_issues_count), project_issues_path(@project)
li class=('active' if contr == :issues && act == :pull_requests)
= link_to t('project_menu.pull_requests', count: @opened_pull_requests_count), project_pull_requests_path(@project)
- if @project.has_wiki
li class=('active' if contr == :wiki)
= link_to t('project_menu.wiki'), project_wiki_index_path(@project)
li
/ = link_to t('project_menu.readme'), '#' #pending
- if can? :update, @project
li class=('active' if act.in?(%i[edit update sections]) && contr == :projects)
= link_to t('project_menu.settings'), edit_project_path(@project)
/ /.navbar-collapse
/ /.container-fluid

View File

@ -0,0 +1,15 @@
.col-sm-9.col-sm-offset-3
h3= t('.header')
table.table.table-condensed.offset20
thead
tr
th= t('.name')
tbody
- @project_aliases.each do |project|
tr
td
= fa_visibility_icon @project
= link_to project.name_with_owner, project_path(project)
= will_paginate @project_aliases

View File

@ -1,16 +1,19 @@
-set_meta_tags title: [title_object(@project), t('layout.projects.edit')] -set_meta_tags title: [title_object(@project), t('layout.projects.edit')]
= render 'submenu' == render 'submenu'
.container.col-md-offset-2.col-md-8 .container.col-md-offset-2.col-md-8
.row .row
= render 'settings_menu' == render 'settings_menu'
= simple_form_for @project, html: { class: 'form-horizontal' }, = simple_form_for @project, html: { class: 'form-horizontal' },
wrapper: :horizontal_form, wrapper: :horizontal_form,
wrapper_mappings: { boolean: :horizontal_boolean } do |f| wrapper_mappings: { boolean: :horizontal_boolean } do |f|
= render "form", f: f == render "form", f: f
= render 'build_schedule' == render 'build_schedule'
- if true #@project_aliases.present?
hr.col-sm-12
== render 'aliases'
hr.col-sm-12 hr.col-sm-12
.col-sm-9.col-sm-offset-3 .col-sm-9.col-sm-offset-3

View File

@ -1,4 +1,17 @@
en: en:
projects:
projects:
aliases:
header: "Aliases"
name: "Project name"
base:
submenu:
tooltips:
alias: "Alias of %{name}"
fork: "Fork of %{name}"
layout: layout:
projects: projects:
placeholder: placeholder:

View File

@ -1,4 +1,18 @@
ru: ru:
projects:
projects:
aliases:
header: "Ссылкы"
name: "Название проекта"
base:
submenu:
tooltips:
alias: "Ссылка %{name}"
fork: "Клонирование %{name}"
layout: layout:
projects: projects:
placeholder: placeholder: