Skip to content

Commit

Permalink
Added support to disable the project size feature
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda committed Apr 26, 2024
1 parent 1a35d7e commit 327d1d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions apps/dashboard/app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# helper for project pages.
module ProjectsHelper

def project_size_enabled
project_timeout = Configuration.project_size_timeout.to_s
!project_timeout.blank? && project_timeout != '0'
end
end
5 changes: 4 additions & 1 deletion apps/dashboard/app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
<div class="row my-2">
<a id="new-dir-btn" class="btn btn-outline-dark" href="<%= files_path(fs: 'fs', filepath: @project.directory ) %>">
<i class="fas fa-folder-open" aria-hidden="true"></i>
<%= t('dashboard.project') %> <%= t('dashboard.directory') %> <span data-toggle="project" data-url="<%= project_path(@project.id) %>"></span>
<%= t('dashboard.project') %> <%= t('dashboard.directory') %>
<%- if project_size_enabled -%>
<span data-toggle="project" data-url="<%= project_path(@project.id) %>"></span>
<%- end -%>
</a>
</div>

Expand Down
22 changes: 22 additions & 0 deletions apps/dashboard/test/helpers/projects_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'test_helper'

class ProjectsHelperTest < ActionView::TestCase
include ProjectsHelper

test 'project_size_enabled should be true when Configuration.project_size_timeout is different than 0' do
Configuration.stubs(:project_size_timeout).returns('10')
assert_equal true, project_size_enabled
end

test 'project_size_enabled should be false when Configuration.project_size_timeout is 0' do
Configuration.stubs(:project_size_timeout).returns('0')
assert_equal false, project_size_enabled
end

test 'project_size_enabled should handle nil' do
Configuration.stubs(:project_size_timeout).returns(nil)
assert_equal false, project_size_enabled
end
end

0 comments on commit 327d1d7

Please sign in to comment.