From e25e2fdd77d971fd6872baa7c2cfa67a961d694c Mon Sep 17 00:00:00 2001 From: starlee Date: Wed, 17 Nov 2021 21:48:59 +0800 Subject: [PATCH 01/19] add the claim mechanism --- app/controllers/claims_controller.rb | 138 ++++++++++++++++++ app/models/claim.rb | 21 +++ app/models/issue.rb | 1 + app/views/claims/_claim_item.json.jbuilder | 7 + app/views/claims/list.json.jbuilder | 7 + config/routes.rb | 11 ++ db/migrate/20211115014133_create_claims.rb | 11 ++ .../20211119135526_add_note_to_claim.rb | 5 + 8 files changed, 201 insertions(+) create mode 100644 app/controllers/claims_controller.rb create mode 100644 app/models/claim.rb create mode 100644 app/views/claims/_claim_item.json.jbuilder create mode 100644 app/views/claims/list.json.jbuilder create mode 100644 db/migrate/20211115014133_create_claims.rb create mode 100644 db/migrate/20211119135526_add_note_to_claim.rb diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb new file mode 100644 index 000000000..d9959bafd --- /dev/null +++ b/app/controllers/claims_controller.rb @@ -0,0 +1,138 @@ +#coding=utf-8 +class ClaimsController < ApplicationController + # skip_before_action :verify_authenticity_token + protect_from_forgery with: :null_session + before_action :require_login, except: [:index] + before_action :set_issue + + def index + @user_claimed = 0 + @claims = @issue.claims.claim_includes.order("created_at desc") + + @claims.each do |claim| + if claim.user_id == current_user.id + @user_claimed = 1 + break + end + end + render file: 'app/views/claims/list.json.jbuilder' + end + + def create + @claim = Claim.find_by_sql(["select id from claims where issue_id=? and user_id=?",params[:issue_id], current_user.id]) + if @claim.present? + return normal_status(-1,"您已经声明过该易修") + end + + ActiveRecord::Base.transaction do + @claim = Claim.new(parse_issue_params(params)) + if @claim.save + @claims = @issue.claims.claim_includes.order("created_at desc") + @user_claimed = 1 + + journal_params = { + journalized_id: params[:issue_id], + journalized_type: "Issue", + user_id: current_user.id , + notes: "新建声明: #{params[:claim_note]}", + } + + journal = Journal.new(journal_params) + if journal.save + render file: 'app/views/claims/list.json.jbuilder' + else + normal_status(-1,"新建声明关联评论操作失败") + end + + else + normal_status(-1,"新建声明操作失败") + end + end + end + + def update + @claim = Claim.find_by_id(params[:claim_id]) + if @claim.blank? + return normal_status(-1,"易修不存在") + end + + if @claim.user_id != current_user.id + return normal_status(-1,"你不能更新别人的声明") + end + + ActiveRecord::Base.transaction do + if @claim.update_attribute(:note,params[:claim_note]) + @claims = @issue.claims.claim_includes.order("created_at desc") + @user_claimed = 1 + + journal_params = { + journalized_id: params[:issue_id], + journalized_type: "Issue", + user_id: current_user.id , + notes: "更新声明: #{params[:claim_note]}", + } + + journal = Journal.new(journal_params) + if journal.save + render file: 'app/views/claims/list.json.jbuilder' + else + normal_status(-1,"新建声明关联评论操作失败") + end + + else + normal_status(-1,"声明更新操作失败") + end + end + end + + def destroy + @claim = Claim.find_by_sql(["select id from claims where issue_id=? and user_id=?",params[:issue_id], current_user.id]) + if @claim.blank? + normal_status(-1,"您未曾声明过该易修") + else + @claim = @claim[0] + # 判断current user是否是claimer + ActiveRecord::Base.transaction do + if @claim.destroy + + @claims = @issue.claims.claim_includes.order("created_at desc") + @user_claimed = 0 + + journal_params = { + journalized_id: params[:issue_id], + journalized_type: "Issue", + user_id: current_user.id , + notes: "取消声明", + } + + journal = Journal.new(journal_params) + if journal.save + render file: 'app/views/claims/list.json.jbuilder' + else + normal_status(-1,"新建声明关联评论操作失败") + end + + else + normal_status(-1,"取消声明操作失败") + end + end + end + end + + private + def parse_issue_params(params) + { + issue_id: params[:issue_id], + user_id: current_user.id, + note: params[:claim_note], + } + end + + def set_issue + @issue = Issue.find_by_id(params[:issue_id]) + unless @issue.present? + normal_status(-1, "易修不存在") + end + end + +end \ No newline at end of file diff --git a/app/models/claim.rb b/app/models/claim.rb new file mode 100644 index 000000000..963b5f55a --- /dev/null +++ b/app/models/claim.rb @@ -0,0 +1,21 @@ +# == Schema Information +# +# Table name: claims +# +# id :integer not null, primary key +# issue_id :integer +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# note :text(65535) +# +# Indexes +# +# index_claims_on_issue_id (issue_id) +# index_claims_on_user_id (user_id) +# + +class Claim < ApplicationRecord + belongs_to :user, foreign_key: :user_id + scope :claim_includes, ->{includes(:user)} +end diff --git a/app/models/issue.rb b/app/models/issue.rb index c642e642b..26b598f04 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -64,6 +64,7 @@ class Issue < ApplicationRecord # has_many :memos has_many :journals, :as => :journalized, :dependent => :destroy has_many :journal_details, through: :journals + has_many :claims, :dependent => :destroy has_many :issue_tags_relates, dependent: :destroy has_many :issue_tags, through: :issue_tags_relates has_many :issue_times, dependent: :destroy diff --git a/app/views/claims/_claim_item.json.jbuilder b/app/views/claims/_claim_item.json.jbuilder new file mode 100644 index 000000000..67a8e4729 --- /dev/null +++ b/app/views/claims/_claim_item.json.jbuilder @@ -0,0 +1,7 @@ +json.user_name claimer.user.try(:show_real_name) +json.user_login claimer.user.try(:login) +json.user_picture url_to_avatar(claimer.user) +json.created_at time_from_now(claimer.created_at) +json.note_body claimer.note +json.claim_id claimer.id +json.visible false \ No newline at end of file diff --git a/app/views/claims/list.json.jbuilder b/app/views/claims/list.json.jbuilder new file mode 100644 index 000000000..b5fef6129 --- /dev/null +++ b/app/views/claims/list.json.jbuilder @@ -0,0 +1,7 @@ +json.partial! "commons/success" +json.currentUserclaimed @user_claimed +json.claimers do + json.array! @claims do |claimer| + json.partial! "claims/claim_item", claimer: claimer + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d4e1ba1c5..78912d1ec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ Rails.application.routes.draw do # Serve websocket cable requests in-process mount ActionCable.server => '/cable' + get 'attachments/entries/get_file', to: 'attachments#get_file' get 'attachments/download/:id', to: 'attachments#show' get 'attachments/download/:id/:filename', to: 'attachments#show' @@ -145,6 +146,16 @@ Rails.application.routes.draw do get :get_children_journals end end + + resources :claims, only: [:index] do + collection do + post :create + delete :destroy + get :index + put :update + end + end + resources :issue_times, only: [:create] do collection do post :end_work diff --git a/db/migrate/20211115014133_create_claims.rb b/db/migrate/20211115014133_create_claims.rb new file mode 100644 index 000000000..a35f5608b --- /dev/null +++ b/db/migrate/20211115014133_create_claims.rb @@ -0,0 +1,11 @@ +ails db:migrateclass CreateClaims < ActiveRecord::Migration[5.2] + def change + create_table :claims do |t| + t.integer :issue_id + t.integer :user_id + t.timestamps + t.index :issue_id + t.index :user_id + end + end +end diff --git a/db/migrate/20211119135526_add_note_to_claim.rb b/db/migrate/20211119135526_add_note_to_claim.rb new file mode 100644 index 000000000..9a1a8e969 --- /dev/null +++ b/db/migrate/20211119135526_add_note_to_claim.rb @@ -0,0 +1,5 @@ +class AddNoteToClaim < ActiveRecord::Migration[5.2] + def change + add_column :claims, :note, :text + end +end From c4586fbb366abbab8709357bad8e43a39c57ec3a Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 14:11:37 +0800 Subject: [PATCH 02/19] fix: remove detail language and contributors --- app/services/repositories/detail_service.rb | 20 +------------------ .../repositories/contributors.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/app/services/repositories/detail_service.rb b/app/services/repositories/detail_service.rb index b2e7a69e6..b39b408ce 100644 --- a/app/services/repositories/detail_service.rb +++ b/app/services/repositories/detail_service.rb @@ -10,20 +10,12 @@ class Repositories::DetailService < ApplicationService def call return { repo: repo_suitable, - contributor: contributor_suitable, - language: language_suitable, branch_tag_total_count: branch_tag_total_count } rescue return { repo: {}, - release: [], - branch: [], - branch_type: [], - tag: [], - contributor: [], - language: {}, - readme: {} + branch_tag_total_count: {} } end @@ -35,14 +27,4 @@ class Repositories::DetailService < ApplicationService def repo_suitable Gitea::Repository::GetService.call(@owner, @repo.identifier) end - - def contributor_suitable - contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repo.identifier) - contributors.is_a?(Hash) && contributors.key?(:status) ? [] : contributors - end - - def language_suitable - result = Gitea::Repository::Languages::ListService.call(@owner.login, @repo.identifier, @user&.gitea_token) - result[:status] === :success ? hash_transform_precentagable(result[:body]) : nil - end end diff --git a/app/views/repositories/contributors.json.jbuilder b/app/views/repositories/contributors.json.jbuilder index fa52475a5..2fb6abae8 100644 --- a/app/views/repositories/contributors.json.jbuilder +++ b/app/views/repositories/contributors.json.jbuilder @@ -1,5 +1,5 @@ total_count = @contributors.size -json.contributors @contributors.each do |contributor| +json.list @contributors.each do |contributor| json.partial! 'contributor', locals: { contributor: contributor } end json.total_count total_count From 0358229b959b9affdcb31b9c40c1cb8d794e6050 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 14:47:15 +0800 Subject: [PATCH 03/19] fix: educoder api delay --- app/controllers/repositories_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d0b4020c4..3f797a13a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -132,7 +132,7 @@ class RepositoriesController < ApplicationController end def contributors - if params[:filepath].present? + if params[:filepath].present? || @project.educoder? @contributors = [] else @contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier) @@ -213,7 +213,11 @@ class RepositoriesController < ApplicationController end def languages - render json: languages_precentagable + if @project.educoder? + render json: {} + else + render json: languages_precentagable + end end def archive From 422549f9e798e0a360e094fe48e011deb09e2e39 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 15:01:33 +0800 Subject: [PATCH 04/19] fix --- app/views/repositories/detail.json.jbuilder | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/repositories/detail.json.jbuilder b/app/views/repositories/detail.json.jbuilder index b741e01f9..14db8b092 100644 --- a/app/views/repositories/detail.json.jbuilder +++ b/app/views/repositories/detail.json.jbuilder @@ -53,13 +53,13 @@ end json.license_name @project.license_name json.branches_count @result[:branch_tag_total_count].present? ? (@result[:branch_tag_total_count]['branch_count'] || 0) : 0 json.tags_count @result[:branch_tag_total_count].present? ? (@result[:branch_tag_total_count]['tag_count'] || 0) : 0 -json.contributors do - total_count = @result[:contributor].size - json.list @result[:contributor].each do |contributor| - json.partial! 'contributor', locals: { contributor: contributor } - end - json.total_count total_count -end -json.languages @result[:language].blank? ? nil : @result[:language] +# json.contributors do +# total_count = @result[:contributor].size +# json.list @result[:contributor].each do |contributor| +# json.partial! 'contributor', locals: { contributor: contributor } +# end +# json.total_count total_count +# end +# json.languages @result[:language].blank? ? nil : @result[:language] json.partial! 'author', locals: { user: @project.owner } From ba9e74f3738e0d1f58b0dcfe2aa2ab16792440dd Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Wed, 8 Dec 2021 15:32:28 +0800 Subject: [PATCH 05/19] fixed db:migrate --- db/migrate/20211115014133_create_claims.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20211115014133_create_claims.rb b/db/migrate/20211115014133_create_claims.rb index a35f5608b..f79102433 100644 --- a/db/migrate/20211115014133_create_claims.rb +++ b/db/migrate/20211115014133_create_claims.rb @@ -1,4 +1,4 @@ -ails db:migrateclass CreateClaims < ActiveRecord::Migration[5.2] +class CreateClaims < ActiveRecord::Migration[5.2] def change create_table :claims do |t| t.integer :issue_id From e0c47c2abdd707a315b0c2842c2ce2fc19ede353 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 16:18:13 +0800 Subject: [PATCH 06/19] fix: educoder clone url --- app/controllers/repositories_controller.rb | 2 +- app/views/repositories/commits.json.jbuilder | 24 ++++++++++++++++++-- app/views/repositories/detail.json.jbuilder | 2 +- app/views/repositories/entries.json.jbuilder | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3f797a13a..0292dc1d1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -96,7 +96,7 @@ class RepositoriesController < ApplicationController def commits if @project.educoder? - @hash_commit = nil + @commits = Educoder::Repository::Commits::ListService.call(@project&.project_educoder&.repo_name) else if params[:filepath].present? file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 33406e6a5..11644f832 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -1,6 +1,26 @@ -if @hash_commit.blank? #如果有状态值,则表示报错了 +if @hash_commit.blank? || @project.educoder? #如果有状态值,则表示报错了 json.total_count 0 - json.commits [] + json.commits do + json.array! @commits do |commit| + json.sha commit['id'] + json.message commit['title'] + json.time_from_now commit['time'] + json.author do + json.id nil + json.login commit['author']['username'] + json.name commit['author']['username'] + json.type nil + json.image_url commit['author']['image_url'] + end + json.commiter do + json.id nil + json.login commit['author']['username'] + json.name commit['author']['username'] + json.type nil + json.image_url commit['author']['image_url'] + end + end + end else json.total_count @hash_commit[:total_count] json.commits do diff --git a/app/views/repositories/detail.json.jbuilder b/app/views/repositories/detail.json.jbuilder index 14db8b092..9381c4737 100644 --- a/app/views/repositories/detail.json.jbuilder +++ b/app/views/repositories/detail.json.jbuilder @@ -44,7 +44,7 @@ end if @result[:repo] json.size replace_bytes_to_b(number_to_human_size(@result[:repo]['size'].to_i*1024)) json.ssh_url @result[:repo]['ssh_url'] - json.clone_url @result[:repo]['clone_url'] + json.clone_url @project.educoder? ? "#{Rails.application.config_for(:configuration)['educoder']['git_site']}/#{@project&.project_educoder&.repo_name}.git" : @result[:repo]['clone_url'] json.default_branch @project.educoder? ? "master" : @result[:repo]['default_branch'] json.empty @result[:repo]['empty'] json.full_name @result[:repo]['full_name'] diff --git a/app/views/repositories/entries.json.jbuilder b/app/views/repositories/entries.json.jbuilder index 8d1e67beb..6dea93b32 100644 --- a/app/views/repositories/entries.json.jbuilder +++ b/app/views/repositories/entries.json.jbuilder @@ -7,7 +7,7 @@ if @project.educoder? end end json.commits_count @entries['commit_count'] - json.zip_url @entries['git_url'] + json.zip_url '' json.tar_url '' json.entries do json.array! @entries['trees'] do |entry| From 1c19c05fd8a9d0ea5365f58714dcd6dd9cc474e1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 16:26:06 +0800 Subject: [PATCH 07/19] fix --- app/controllers/repositories_controller.rb | 371 --------------------- 1 file changed, 371 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 97aef561b..0292dc1d1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,373 +1,3 @@ -<<<<<<< HEAD -class RepositoriesController < ApplicationController - include RepositoriesHelper - include ApplicationHelper - include OperateProjectAbilityAble - include Repository::LanguagesPercentagable - - before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror] - before_action :require_profile_completed, only: [:create_file] - before_action :load_repository - before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive] - before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror] - before_action :get_ref, only: %i[entries sub_entries top_counts file archive] - before_action :get_latest_commit, only: %i[entries sub_entries top_counts] - before_action :get_statistics, only: %i[top_counts] - - def files - result = @project.educoder? ? nil : Gitea::Repository::Files::GetService.call(@owner, @project.identifier, @ref, params[:search], @owner.gitea_token) - render json: result - end - - # 新版项目详情 - def detail - @user = current_user - @result = Repositories::DetailService.call(@owner, @repository, @user) - @project_fork_id = @project.try(:forked_from_project_id) - if @project_fork_id.present? - @fork_project = Project.find_by(id: @project_fork_id) - @fork_project_user = @fork_project.owner - end - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - end - - def show - @user = current_user - @repo = @project.repository - @result = @project.forge? ? Gitea::Repository::GetService.new(@owner, @project.identifier).call : nil - @project_fork_id = @project.try(:forked_from_project_id) - if @project_fork_id.present? - @fork_project = Project.find_by(id: @project_fork_id) - @fork_project_user = @fork_project.owner - end - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - end - - def entries - @project.increment!(:visits) - CacheAsyncSetJob.perform_later("project_common_service", {visits: 1}, @project.id) - if @project.educoder? - @entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder.repo_name) - else - @entries = Gitea::Repository::Entries::ListService.new(@owner, @project.identifier, ref: @ref).call - @entries = @entries.present? ? @entries.sort_by{ |hash| hash['type'] } : [] - @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" - end - end - - def top_counts - @result = @project.educoder? ? nil : Gitea::Repository::GetService.new(@project.owner, @project.identifier).call - end - - def sub_entries - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) - - if @project.educoder? - if params[:type] === 'file' - @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) - logger.info "######### sub_entries: #{@sub_entries}" - return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 - - tmp_entries = [{ - "content" => @sub_entries['data']['content'], - "type" => "blob" - }] - @sub_entries = { - "trees"=>tmp_entries, - "commits" => [{}] - } - else - @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) - end - else - @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" - interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: @ref) - if interactor.success? - result = interactor.result - @sub_entries = result.is_a?(Array) ? result.sort_by{ |hash| hash['type'] } : result - else - render_error(interactor.error) - end - end - end - - def commits - if @project.educoder? - @hash_commit = nil - else - if params[:filepath].present? - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) - @hash_commit = Gitea::Repository::Commits::FileListService.new(@owner.login, @project.identifier, file_path_uri, - sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call - else - @hash_commit = Gitea::Repository::Commits::ListService.new(@owner.login, @project.identifier, - sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call - end - end - end - - def commits_slice - @hash_commit = Gitea::Repository::Commits::ListSliceService.call(@owner&.login, @project.identifier, - sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token) - end - - def commit - @sha = params[:sha] - if @project.educoder? - @commit = {} - @commit_diff ={} - else - @commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token) - @commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true}) - end - end - - def tags - result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]}) - - @tags = result.is_a?(Hash) && result.key?(:status) ? [] : result - end - - def contributors - if params[:filepath].present? - @contributors = [] - else - @contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier) - end - end - - def edit - return render_forbidden if !@project.manager?(current_user) && !current_user.admin? - end - - def create_file - interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params) - if interactor.success? - @file = interactor.result - # create_new_pr(params) - #如果是更新流水线文件 - if params[:pipeline_id] - update_pipeline(params[:pipeline_id]) - end - else - render_error(interactor.error) - end - end - - def update_pipeline(pipeline_id) - pipeline = Ci::Pipeline.find(pipeline_id) - if pipeline - pipeline.update!(sync: 1) - end - end - - def update_file - interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier)) - if interactor.success? - @file = interactor.result - # TODO: 是否创建pr - # create_new_pr(params) - render_result(1, "更新成功") - else - render_error(interactor.error) - end - end - - def delete_file - interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier)) - if interactor.success? - @file = interactor.result - render_result(1, "文件删除成功") - else - render_error(interactor.error) - end - end - - def repo_hook - - end - - def sync_mirror - return render_error("正在镜像中..") if @repository.mirror.waiting? - - @repository.sync_mirror! - SyncMirroredRepositoryJob.perform_later(@repository.id, current_user.id) - render_ok - end - - def readme - if params[:filepath].present? - result = Gitea::Repository::Readme::DirService.call(@owner.login, @repository.identifier, params[:filepath], params[:ref], current_user&.gitea_token) - else - result = Gitea::Repository::Readme::GetService.call(@owner.login, @repository.identifier, params[:ref], current_user&.gitea_token) - end - @path = Gitea.gitea_config[:domain]+"/#{@owner.login}/#{@repository.identifier}/raw/branch/#{params[:ref]}/" - @readme = result[:status] === :success ? result[:body] : nil - @readme['content'] = decode64_content(@readme, @owner, @repository, params[:ref], @path) - render json: @readme.slice("type", "encoding", "size", "name", "path", "content", "sha") - rescue - render json: nil - end - - def languages - render json: languages_precentagable - end - - def archive - domain = Gitea.gitea_config[:domain] - api_url = Gitea.gitea_config[:base_url] - archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{params[:archive]}" - - file_path = [domain, api_url, archive_url].join - file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("?") if @repository.hidden? - - return render_not_found if !request.format.zip? && !request.format.gzip? - - redirect_to file_path - end - - def raw - domain = Gitea.gitea_config[:domain] - api_url = Gitea.gitea_config[:base_url] - - url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{params[:filepath]}?ref=#{params[:ref]}" - file_path = [domain, api_url, url].join - file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("&") if @repository.hidden? - - redirect_to URI.escape(file_path) - end - - private - - def find_project - @project = Project.find params[:id] - render_not_found("未找到相关的仓库") unless @project - end - - def find_project_with_includes - @project = Project.includes(:repository, :owner, :watchers, :praise_treads).find params[:id] - end - - def authorizate! - return if current_user && current_user.admin? - if @project.repository.hidden? && !@project.member?(current_user) - render_forbidden - end - end - - # TODO 获取最新commit信息 - def project_commits - if params[:filepath].present? - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) - Gitea::Repository::Commits::FileListService.new(@project.owner.login, @project.identifier, file_path_uri, - sha: get_ref, page: 1, limit: 1, token: current_user&.gitea_token).call - else - Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier, - sha: get_ref, page: 1, limit: 1, token: current_user&.gitea_token).call - end - end - - def get_statistics - @branches_count = @project.educoder? ? 0 : Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call&.size - @tags_count = @project.educoder? ? 0 : Gitea::Repository::Tags::ListService.new(current_user&.gitea_token, @project.owner.login, @project.identifier).call&.size - end - - def get_ref - @ref = params[:ref] || @project&.default_branch - end - - def get_latest_commit - latest_commit = @project.educoder? ? nil : project_commits - @latest_commit = latest_commit.present? ? latest_commit[:body][0] : nil - @commits_count = latest_commit.present? ? latest_commit[:total_count] : 0 - end - - def content_params - { - filepath: params[:filepath], - branch: params[:branch], - new_branch: params[:new_branch], - content: params[:content], - message: params[:message], - committer: { - email: current_user.mail, - name: current_user.login - }, - identifier: @project.identifier - } - end - - def hook_params(hook_type, params) - # if hook_type == "push" - # # TODO hook返回的记录中,暂时没有文件代码数量的增减,暂时根据 commits数量来计算 - # uploadPushInfo = { - # "sha": params["commits"].present? ? params["commits"].last : "", - # "branch": params["ref"].to_s.split("/").last, - # "modification_lines": params["commits"].length - # } - # elsif hook_type == "pull_request" && params["action"].to_s == "closed" #合并请求合并后才会有上链操作 - # uploadPushInfo = { - # "branch": params["base"]["ref"].to_s.split("/").last, - # "sha": params["pull_request"]["merge_base"], - # "modification_lines": 1 #pull_request中没有commits数量 - # } - # else - # uploadPushInfo = {} - # end - - # uploadPushInfo - end - - def create_new_pr(params) - if params[:new_branch].present? && params[:new_branch] != params[:branch] - local_params = { - title: params[:message], #标题 - body: params[:content], #内容 - head: params[:new_branch], #源分支 - base: params[:branch], #目标分支 - milestone: 0 #里程碑,未与本地的里程碑关联 - - } - requests_params = local_params.merge({ - assignee: current_user.try(:login), - assignees: [], - labels: [], - due_date: Time.now - }) - - issue_params = { - author_id: current_user.id, - project_id: @project.id, - subject: params[:message], - description: params[:content], - assigned_to_id: nil, - fixed_version_id: nil, - issue_tags_value: nil, - issue_classify: "pull_request", - issue_type: "1", - tracker_id: 2, - status_id: 1, - priority_id: params[:priority_id] || "2" - } - @pull_issue = Issue.new(issue_params) - if @pull_issue.save! - local_requests = PullRequest.new(local_params.merge(user_id: current_user.try(:id), project_id: @project.id, issue_id: @pull_issue.id)) - if local_requests.save - gitea_request = Gitea::PullRequest::CreateService.new(current_user.try(:gitea_token), @owner.login, @project.try(:identifier), requests_params).call - if gitea_request[:status] == :success && local_requests.update_attributes(gitea_number: gitea_request["body"]["number"], gpid: gitea_request["body"]["number"]) - local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create") - end - end - end - end - end - -end -======= class RepositoriesController < ApplicationController include RepositoriesHelper include ApplicationHelper @@ -740,4 +370,3 @@ class RepositoriesController < ApplicationController end end ->>>>>>> develop From 33e17e84392c2dbd2a6fde08d69b53f85edb675a Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 18:18:19 +0800 Subject: [PATCH 08/19] fix: educoder sub_entries and commit author --- app/controllers/repositories_controller.rb | 12 ++++++++++++ app/views/repositories/_commit.json.jbuilder | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0292dc1d1..f3fffd6e1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -81,6 +81,18 @@ class RepositoriesController < ApplicationController } else @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) + if @sub_entries.blank? + @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) + return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 + tmp_entries = [{ + "content" => @sub_entries['data']['content'], + "type" => "blob" + }] + @sub_entries = { + "trees"=>tmp_entries, + "commits" => [{}] + } + end end else @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index 9c29116e9..e860b01fa 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -7,11 +7,20 @@ if @project.educoder? json.timestamp 0 json.time_from_now commit[0]['time'] end - json.author do - {} - # json.partial! '/projects/author', user: render_commit_author(commit['author']) + json.author do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] + end + json.commiter do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] end - json.committer {} end if @project.forge? From 30eb1958c14122ab911793ecf9c4bdf51b3e1add Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 18:23:29 +0800 Subject: [PATCH 09/19] fix --- app/views/repositories/commits.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 11644f832..14b9f1b9e 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -12,7 +12,7 @@ if @hash_commit.blank? || @project.educoder? #如果有状态值,则表示 json.type nil json.image_url commit['author']['image_url'] end - json.commiter do + json.committer do json.id nil json.login commit['author']['username'] json.name commit['author']['username'] From beccac652ff010a2b4620c159d54178b88dd199c Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 18:25:31 +0800 Subject: [PATCH 10/19] fix --- app/views/repositories/_commit.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index e860b01fa..a1ed80d60 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -14,7 +14,7 @@ if @project.educoder? json.type nil json.image_url commit[0]['author']['image_url'] end - json.commiter do + json.committer do json.id nil json.login commit[0]['author']['username'] json.name commit[0]['author']['username'] From 0d64768e4b1e4f9b145a2157354de1559d2fd60a Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 09:37:28 +0800 Subject: [PATCH 11/19] fix: educoder file visit delay --- app/controllers/repositories_controller.rb | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f3fffd6e1..94ee26a29 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -80,18 +80,22 @@ class RepositoriesController < ApplicationController "commits" => [{}] } else - @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) - if @sub_entries.blank? - @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) - return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 - tmp_entries = [{ - "content" => @sub_entries['data']['content'], - "type" => "blob" - }] - @sub_entries = { - "trees"=>tmp_entries, - "commits" => [{}] - } + begin + @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) + if @sub_entries.blank? + @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) + return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 + tmp_entries = [{ + "content" => @sub_entries['data']['content'], + "type" => "blob" + }] + @sub_entries = { + "trees"=>tmp_entries, + "commits" => [{}] + } + end + rescue + return render_error('该文件暂未开放,敬请期待.') end end else @@ -129,8 +133,7 @@ class RepositoriesController < ApplicationController def commit @sha = params[:sha] if @project.educoder? - @commit = {} - @commit_diff ={} + return render_error('暂未开放,敬请期待.') else @commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token) @commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true}) From 102858bc8cbadeac44fd4b49cf89a42379ffb345 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 11:06:49 +0800 Subject: [PATCH 12/19] fix: educoder entries file use hash --- app/controllers/repositories_controller.rb | 6 ++-- app/views/repositories/_commit.json.jbuilder | 30 ++++++++++--------- .../repositories/sub_entries.json.jbuilder | 4 +-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 94ee26a29..9012792c6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -71,7 +71,7 @@ class RepositoriesController < ApplicationController logger.info "######### sub_entries: #{@sub_entries}" return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 - tmp_entries = [{ + tmp_entries = { "content" => @sub_entries['data']['content'], "type" => "blob" }] @@ -82,13 +82,13 @@ class RepositoriesController < ApplicationController else begin @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) - if @sub_entries.blank? + if @sub_entries.blank? || @sub_entries['status'].to_i === -1 @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 tmp_entries = [{ "content" => @sub_entries['data']['content'], "type" => "blob" - }] + } @sub_entries = { "trees"=>tmp_entries, "commits" => [{}] diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index a1ed80d60..892353ea7 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -7,20 +7,22 @@ if @project.educoder? json.timestamp 0 json.time_from_now commit[0]['time'] end - json.author do - json.id nil - json.login commit[0]['author']['username'] - json.name commit[0]['author']['username'] - json.type nil - json.image_url commit[0]['author']['image_url'] - end - json.committer do - json.id nil - json.login commit[0]['author']['username'] - json.name commit[0]['author']['username'] - json.type nil - json.image_url commit[0]['author']['image_url'] - end + if commit[0]['author'].present? + json.author do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] + end + json.committer do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] + end + end end if @project.forge? diff --git a/app/views/repositories/sub_entries.json.jbuilder b/app/views/repositories/sub_entries.json.jbuilder index 3276ed0dd..4e6932210 100644 --- a/app/views/repositories/sub_entries.json.jbuilder +++ b/app/views/repositories/sub_entries.json.jbuilder @@ -24,8 +24,6 @@ if @project.educoder? end end json.entries do - json.array! @sub_entries['trees'] do |entry| - json.partial! 'repositories/simple_entry', locals: { entry: entry } - end + json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries['trees']} end end From 16418675acae0f3c87d876fd3b01effb2ef0d38c Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 11:08:10 +0800 Subject: [PATCH 13/19] fix --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9012792c6..4d234c9c9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -85,7 +85,7 @@ class RepositoriesController < ApplicationController if @sub_entries.blank? || @sub_entries['status'].to_i === -1 @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 - tmp_entries = [{ + tmp_entries = { "content" => @sub_entries['data']['content'], "type" => "blob" } From 38d6519381e2bda5e20a4c7e4dda5ef36ec427c4 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 11:08:54 +0800 Subject: [PATCH 14/19] fix --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 4d234c9c9..07c209730 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -74,7 +74,7 @@ class RepositoriesController < ApplicationController tmp_entries = { "content" => @sub_entries['data']['content'], "type" => "blob" - }] + } @sub_entries = { "trees"=>tmp_entries, "commits" => [{}] From 81e6691632ee432679d7728c6df2f2aeee4707d6 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 11:33:43 +0800 Subject: [PATCH 15/19] fix: educoder entries image file type --- app/views/repositories/_simple_entry.json.jbuilder | 4 +++- app/views/repositories/sub_entries.json.jbuilder | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 6f33ac35e..80a54d477 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -32,6 +32,8 @@ end if @project.educoder? file_path = params[:filepath].present? ? [params[:filepath], entry['name']].join('/') : entry['name'] + file_type = File.extname(entry['name'].to_s)[1..-1] + image_type = image_type?(file_type) json.name entry['name'] json.sha nil @@ -42,7 +44,7 @@ if @project.educoder? json.target nil json.download_url nil json.direct_download false - json.image_type false + json.image_type image_type json.is_readme_file false json.commit do json.message entry['title'] diff --git a/app/views/repositories/sub_entries.json.jbuilder b/app/views/repositories/sub_entries.json.jbuilder index 4e6932210..296e307f4 100644 --- a/app/views/repositories/sub_entries.json.jbuilder +++ b/app/views/repositories/sub_entries.json.jbuilder @@ -24,6 +24,12 @@ if @project.educoder? end end json.entries do - json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries['trees']} + if @sub_entries['trees'].is_a?(Array) + json.array! @sub_entries['trees'] do |entry| + json.partial! 'repositories/simple_entry', locals: { entry: entry } + end + elsif @sub_entries['trees'].is_a?(Hash) + json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries['trees'] } + end end end From f79beef3f903309f192f0eae6b685471e43eda72 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 14:33:46 +0800 Subject: [PATCH 16/19] fix: issues branch educoder use master --- app/helpers/tag_chosen_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/tag_chosen_helper.rb b/app/helpers/tag_chosen_helper.rb index 593e412d9..4ded66e1a 100644 --- a/app/helpers/tag_chosen_helper.rb +++ b/app/helpers/tag_chosen_helper.rb @@ -26,8 +26,12 @@ module TagChosenHelper end def render_branches(project) - branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier) - branches.collect{|i| i["name"] if i.is_a?(Hash)} + if project.educoder? + return ['master'] + else + branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier) + branches.collect{|i| i["name"] if i.is_a?(Hash)} + end end def render_cache_trackers From 66d1246a6c7a592119ecec43a8ff5dc21d8772f8 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Dec 2021 15:54:21 +0800 Subject: [PATCH 17/19] fix: educoder project menu return --- app/controllers/projects_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1864c6964..3bb04e873 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -16,13 +16,13 @@ class ProjectsController < ApplicationController menu.append(menu_hash_by_name("home")) menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code") menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues") - menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") - menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") - menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") + menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") && @project.forge? + menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") && @project.forge? + menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") && @project.forge? menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions") - menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") + menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") && @project.forge? menu.append(menu_hash_by_name("activity")) - menu.append(menu_hash_by_name("settings")) if current_user.admin? || @project.manager?(current_user) + menu.append(menu_hash_by_name("settings")) if (current_user.admin? || @project.manager?(current_user)) && @project.forge? render json: menu end From f8a6f62342a18cd0e1f0b293e6cbdf70df8c688e Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 10 Dec 2021 09:35:03 +0800 Subject: [PATCH 18/19] fix: project rank include educoder --- app/views/project_rank/_detail.json.jbuilder | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/app/views/project_rank/_detail.json.jbuilder b/app/views/project_rank/_detail.json.jbuilder index b23403966..5e45f518e 100644 --- a/app/views/project_rank/_detail.json.jbuilder +++ b/app/views/project_rank/_detail.json.jbuilder @@ -3,15 +3,26 @@ owner_common = $redis_cache.hgetall("v2-owner-common:#{project_common["owner_id" json.id item[0] json.score item[1] json.name project_common["name"] -json.identifier project_common["identifier"] -json.description project_common["description"] -json.owner do - json.id project_common["owner_id"] - json.type owner_common["type"] - json.name owner_common["name"] - json.login owner_common["login"] - json.avatar_url owner_common["avatar_url"] +if project_common['identifier'].include?("/") + json.identifier project_common["identifier"].split('/')[1] + json.owner do + json.id nil + json.type 'User' + json.name project_common["identifier"].split('/')[0] + json.login project_common["identifier"].split('/')[0] + json.avatar_url User::Avatar.get_letter_avatar_url(project_common["identifier"].split('/')[0]) + end +else + json.identifier project_common["identifier"] + json.owner do + json.id project_common["owner_id"] + json.type owner_common["type"] + json.name owner_common["name"] + json.login owner_common["login"] + json.avatar_url owner_common["avatar_url"] + end end +json.description project_common["description"] json.visits project_common["visits"] json.forks project_common["forks"] json.watchers project_common["watchers"] From 1faaf1d7d13b7ee14ca00bc33bed5cf8803d108e Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 13 Dec 2021 11:45:58 +0800 Subject: [PATCH 19/19] fix: project menu list wiki location --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3bb04e873..77b818cad 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -17,9 +17,9 @@ class ProjectsController < ApplicationController menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code") menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues") menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") && @project.forge? - menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") && @project.forge? menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") && @project.forge? menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions") + menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") && @project.forge? menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") && @project.forge? menu.append(menu_hash_by_name("activity")) menu.append(menu_hash_by_name("settings")) if (current_user.admin? || @project.manager?(current_user)) && @project.forge?