mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-18 22:58:53 +08:00
hound fix
This commit is contained in:
parent
379ef7a9cc
commit
5cd32d5cfa
3 changed files with 113 additions and 116 deletions
|
|
@ -139,10 +139,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#repositoriesList_wrapper {
|
#repositoriesList_wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.dataTables_scroll {
|
.dataTables_scroll {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
|
|
@ -1,115 +1,111 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Toolbars
|
module Toolbars
|
||||||
class RepositoriesService
|
class RepositoriesService
|
||||||
attr_reader :current_user
|
attr_reader :current_user
|
||||||
|
|
||||||
include Canaid::Helpers::PermissionsHelper
|
include Canaid::Helpers::PermissionsHelper
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
def initialize(current_user, current_team, repository_ids: [])
|
def initialize(current_user, current_team, repository_ids: [])
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
@current_team = current_team
|
@current_team = current_team
|
||||||
@repositories = Repository.readable_by_user(current_user)
|
@repositories = Repository.readable_by_user(current_user)
|
||||||
.where(id: repository_ids)
|
.where(id: repository_ids)
|
||||||
@repository = @repositories.length == 1 ? @repositories.first : nil
|
@repository = @repositories.length == 1 ? @repositories.first : nil
|
||||||
@archived_state = @repositories.all.any?(&:archived?)
|
@archived_state = @repositories.all.any?(&:archived?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def actions
|
def actions
|
||||||
return [] if @repositories.none?
|
return [] if @repositories.none?
|
||||||
|
|
||||||
if @archived_state
|
if @archived_state
|
||||||
[restore_action, delete_action]
|
[restore_action, delete_action]
|
||||||
else
|
else
|
||||||
[rename_action, duplicate_action, archive_action, share_action]
|
[rename_action, duplicate_action, archive_action, share_action]
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def rename_action
|
def rename_action
|
||||||
return unless @repository
|
return unless @repository
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'rename',
|
name: 'rename',
|
||||||
label: I18n.t('libraries.index.buttons.edit'),
|
label: I18n.t('libraries.index.buttons.edit'),
|
||||||
button_id: 'renameRepoBtn',
|
button_id: 'renameRepoBtn',
|
||||||
icon: 'fas fa-pencil-alt',
|
icon: 'fas fa-pencil-alt',
|
||||||
path: team_repository_rename_modal_path(@current_team, repository_id: @repository),
|
path: team_repository_rename_modal_path(@current_team, repository_id: @repository),
|
||||||
type: 'remote-modal'
|
type: 'remote-modal'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def duplicate_action
|
def duplicate_action
|
||||||
return unless @repository
|
return unless @repository && can_create_repositories?(@current_team)
|
||||||
|
|
||||||
return unless can_create_repositories?(@current_team)
|
{
|
||||||
|
name: 'duplicate',
|
||||||
|
label: I18n.t('libraries.index.buttons.duplicate'),
|
||||||
|
button_id: 'copyRepoBtn',
|
||||||
|
icon: 'fas fa-copy',
|
||||||
|
path: team_repository_copy_modal_path(@current_team, repository_id: @repository),
|
||||||
|
type: 'remote-modal'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
{
|
def archive_action
|
||||||
name: 'duplicate',
|
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
||||||
label: I18n.t('libraries.index.buttons.duplicate'),
|
|
||||||
button_id: 'copyRepoBtn',
|
|
||||||
icon: 'fas fa-copy',
|
|
||||||
path: team_repository_copy_modal_path(@current_team, repository_id: @repository),
|
|
||||||
type: 'remote-modal'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def archive_action
|
{
|
||||||
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
name: 'archive',
|
||||||
|
label: I18n.t('libraries.index.buttons.archive'),
|
||||||
|
button_id: 'archiveRepoBtn',
|
||||||
|
icon: 'fas fa-archive',
|
||||||
|
path: archive_team_repositories_path(@current_team),
|
||||||
|
type: :request,
|
||||||
|
request_method: :post
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
{
|
def share_action
|
||||||
name: 'archive',
|
return unless @repository && can_share_repository?(@repository)
|
||||||
label: I18n.t('libraries.index.buttons.archive'),
|
|
||||||
button_id: 'archiveRepoBtn',
|
|
||||||
icon: 'fas fa-archive',
|
|
||||||
path: archive_team_repositories_path(@current_team),
|
|
||||||
type: :request,
|
|
||||||
request_method: :post
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def share_action
|
{
|
||||||
return unless @repository
|
name: 'share',
|
||||||
|
label: I18n.t('repositories.index.share_inventory'),
|
||||||
|
icon: 'fas fa-user-plus',
|
||||||
|
button_class: 'share-repository-button',
|
||||||
|
path: team_repository_share_modal_path(@current_team, repository_id: @repository),
|
||||||
|
type: 'remote-modal'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
return unless can_share_repository?(@repository)
|
def restore_action
|
||||||
|
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'share',
|
name: 'restore',
|
||||||
label: I18n.t('repositories.index.share_inventory'),
|
label: I18n.t('libraries.index.buttons.restore'),
|
||||||
icon: 'fas fa-user-plus',
|
icon: 'fas fa-undo',
|
||||||
button_class: 'share-repository-button',
|
button_id: 'restoreRepoBtn',
|
||||||
path: team_repository_share_modal_path(@current_team, repository_id: @repository),
|
path: restore_team_repositories_path(@current_team),
|
||||||
type: 'remote-modal'
|
type: :request,
|
||||||
}
|
request_method: :post
|
||||||
end
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def restore_action
|
def delete_action
|
||||||
return unless @repositories.all? { |repository| can_archive_repository?(repository) }
|
return unless @repository
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'restore',
|
name: 'delete',
|
||||||
label: I18n.t('libraries.index.buttons.restore'),
|
label: I18n.t('libraries.index.buttons.delete'),
|
||||||
icon: 'fas fa-undo',
|
icon: 'fas fa-trash',
|
||||||
button_id: 'restoreRepoBtn',
|
button_id: 'deleteRepoBtn',
|
||||||
path: restore_team_repositories_path(@current_team),
|
path: team_repository_destroy_modal_path(@current_team, repository_id: @repository),
|
||||||
type: :request,
|
type: 'remote-modal'
|
||||||
request_method: :post
|
}
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete_action
|
|
||||||
return unless @repository
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'delete',
|
|
||||||
label: I18n.t('libraries.index.buttons.delete'),
|
|
||||||
icon: 'fas fa-trash',
|
|
||||||
button_id: 'deleteRepoBtn',
|
|
||||||
path: team_repository_destroy_modal_path(@current_team, repository_id: @repository),
|
|
||||||
type: 'remote-modal'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue