diff --git a/app/assets/stylesheets/components/Board.scss b/app/assets/stylesheets/components/Board.scss index 28d1af9d..7382dc5e 100644 --- a/app/assets/stylesheets/components/Board.scss +++ b/app/assets/stylesheets/components/Board.scss @@ -85,7 +85,7 @@ .mb-3, .p-3; - height: 140px; + min-height: 140px; color: var(--astuto-black); @include media-breakpoint-down(sm) { @@ -104,14 +104,16 @@ .postTitle { @extend - .font-weight-bold; + .font-weight-bold, + .mb-2; } .postDetails { @extend .d-flex, .justify-content-start, - .text-uppercase; + .text-uppercase, + .mt-2; .badge { @extend .mr-2; diff --git a/app/controllers/o_auths_controller.rb b/app/controllers/o_auths_controller.rb index 843cc376..f5837ee6 100644 --- a/app/controllers/o_auths_controller.rb +++ b/app/controllers/o_auths_controller.rb @@ -40,14 +40,14 @@ class OAuthsController < ApplicationController Current.tenant = Tenant.find_by(subdomain: tenant_domain) end - user_profile = OAuthExchangeAuthCodeForProfile.new( + user_profile = OAuthExchangeAuthCodeForProfileWorkflow.new( authorization_code: params[:code], o_auth: @o_auth ).run if reason == 'login' - user = OAuthSignInUser.new( + user = OAuthSignInUserWorkflow.new( user_profile: user_profile, o_auth: @o_auth ).run diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index fce64686..c1344a90 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -45,6 +45,8 @@ class TenantsController < ApplicationController @user.save! + CreateWelcomeEntitiesWorkflow.new().run + render json: @tenant, status: :created rescue ActiveRecord::RecordInvalid => exception diff --git a/app/javascript/components/Board/NewPostForm.tsx b/app/javascript/components/Board/NewPostForm.tsx index 1427e10a..05e2a6b4 100644 --- a/app/javascript/components/Board/NewPostForm.tsx +++ b/app/javascript/components/Board/NewPostForm.tsx @@ -26,6 +26,7 @@ const NewPostForm = ({ type="text" value={title} onChange={e => handleTitleChange(e.target.value)} + maxLength={128} id="postTitle" className="form-control" diff --git a/app/models/post.rb b/app/models/post.rb index 2593f5f6..1a8abd05 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -11,7 +11,7 @@ class Post < ApplicationRecord has_many :comments, dependent: :destroy has_many :post_status_changes, dependent: :destroy - validates :title, presence: true, length: { in: 4..64 } + validates :title, presence: true, length: { in: 4..128 } paginates_per Rails.application.posts_per_page diff --git a/app/workflows/create_welcome_entities_workflow.rb b/app/workflows/create_welcome_entities_workflow.rb new file mode 100644 index 00000000..305c3f24 --- /dev/null +++ b/app/workflows/create_welcome_entities_workflow.rb @@ -0,0 +1,71 @@ +class CreateWelcomeEntitiesWorkflow + def run + tenant = Current.tenant_or_raise! # check that Current Tenant is set + owner = tenant.users.first + + # Create some Boards + feature_board = Board.create!( + name: 'Feature Requests', + description: 'This is a **board**! You can create as many as you want from **site settings** and their description can be *Markdown formatted*.', + order: 0 + ) + bug_board = Board.create!( + name: 'Bug Reports', + description: 'Tell us everything about problems you encountered in our services!', + order: 1 + ) + + # Create some Post Statuses + planned_post_status = PostStatus.create!( + name: 'Planned', + color: '#0096ff', + order: 0, + show_in_roadmap: true + ) + in_progress_post_status = PostStatus.create!( + name: 'In Progress', + color: '#9437ff', + order: 1, + show_in_roadmap: true + ) + completed_post_status = PostStatus.create!( + name: 'Completed', + color: '#6ac47c', + order: 2, + show_in_roadmap: true + ) + rejected_post_status = PostStatus.create!( + name: 'Rejected', + color: '#ff2600', + order: 3, + show_in_roadmap: false + ) + + # Create some Posts + post1 = Post.create!( + title: "Welcome #{owner.full_name}! This is an example feedback post, click to learn more!", + description: 'Users can submit feedback by publishing posts like this. You can assign a **status** to each post: this one, for example, is marked as "Planned". Remember that you can customise post statuses from Site settings > Statuses', + board_id: feature_board.id, + user_id: owner.id, + post_status_id: planned_post_status.id + ) + PostStatusChange.create!( + post_id: post1.id, + user_id: owner.id, + post_status_id: planned_post_status.id + ) + + post2 = Post.create!( + title: 'There are multiple boards', + description: 'For now you have Feature Requests and Bug Reports, but you can add or remove as many as you want! Just go to Site settings > Boards!', + board_id: bug_board.id, + user_id: owner.id + ) + + # Create some comments + post1.comments.create!( + body: 'Users can comment to express their opinions! As with posts and board descriptions, comments can be *Markdown* **formatted**', + user_id: owner.id + ) + end +end \ No newline at end of file diff --git a/app/workflows/EnsureCoherentOrderingWorkflow.rb b/app/workflows/ensure_coherent_ordering_workflow.rb similarity index 100% rename from app/workflows/EnsureCoherentOrderingWorkflow.rb rename to app/workflows/ensure_coherent_ordering_workflow.rb diff --git a/app/workflows/OAuthExchangeAuthCodeForProfile.rb b/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb similarity index 97% rename from app/workflows/OAuthExchangeAuthCodeForProfile.rb rename to app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb index 12ae8107..b25957c2 100644 --- a/app/workflows/OAuthExchangeAuthCodeForProfile.rb +++ b/app/workflows/o_auth_exchange_auth_code_for_profile_workflow.rb @@ -1,4 +1,4 @@ -class OAuthExchangeAuthCodeForProfile +class OAuthExchangeAuthCodeForProfileWorkflow include HTTParty attr_accessor :authorization_code, :o_auth diff --git a/app/workflows/OAuthSignInUser.rb b/app/workflows/o_auth_sign_in_user_workflow.rb similarity index 96% rename from app/workflows/OAuthSignInUser.rb rename to app/workflows/o_auth_sign_in_user_workflow.rb index bcbe2e66..4a907692 100644 --- a/app/workflows/OAuthSignInUser.rb +++ b/app/workflows/o_auth_sign_in_user_workflow.rb @@ -1,11 +1,11 @@ -class OAuthSignInUser +class OAuthSignInUserWorkflow include OAuthsHelper attr_accessor :user_profile, :o_auth # Given: # user_profile: ruby Hash containing information about the user - # Could've been returned from OAuthExchangeAuthCodeForProfile + # Could've been returned from OAuthExchangeAuthCodeForProfileWorkflow # o_auth: ActiveRecord model with information about the OAuth provider # # The workfow creates a new user if it doesn't exist, or select the existing one diff --git a/app/workflows/ReorderWorkflow.rb b/app/workflows/reorder_workflow.rb similarity index 100% rename from app/workflows/ReorderWorkflow.rb rename to app/workflows/reorder_workflow.rb diff --git a/app/workflows/SendNotificationForCommentWorkflow.rb b/app/workflows/send_notification_for_comment_workflow.rb similarity index 100% rename from app/workflows/SendNotificationForCommentWorkflow.rb rename to app/workflows/send_notification_for_comment_workflow.rb diff --git a/db/seeds.rb b/db/seeds.rb index 1e34e1e5..d94cf16a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,6 +1,6 @@ # Create tenant tenant = Tenant.create( - site_name: 'Default site name', + site_name: 'Default Site Name', subdomain: 'default', status: 'active' ) @@ -15,70 +15,7 @@ owner = User.create( confirmed_at: Time.zone.now ) -# Create some boards -feature_board = Board.create( - name: 'Feature Requests', - description: 'This is a **board**! You can create as many as you want from **site settings** and their description can be *Markdown formatted*.', - order: 0 -) -bug_board = Board.create( - name: 'Bug Reports', - description: 'Tell us everything about problems you encountered in our services!', - order: 1 -) - -# Create some post statuses -planned_post_status = PostStatus.create( - name: 'Planned', - color: '#0096ff', - order: 0, - show_in_roadmap: true -) -in_progress_post_status = PostStatus.create( - name: 'In Progress', - color: '#9437ff', - order: 1, - show_in_roadmap: true -) -completed_post_status = PostStatus.create( - name: 'Completed', - color: '#6ac47c', - order: 2, - show_in_roadmap: true -) -rejected_post_status = PostStatus.create( - name: 'Rejected', - color: '#ff2600', - order: 3, - show_in_roadmap: false -) - -# Create some posts -post1 = Post.create( - title: 'Users can submit feedback by publishing posts!', - description: 'You can assign a **status** to each post: this one, for example, is marked as "Planned". Remember that you can customise post statuses from Site settings > Statuses', - board_id: feature_board.id, - user_id: owner.id, - post_status_id: planned_post_status.id -) -PostStatusChange.create( - post_id: post1.id, - user_id: owner.id, - post_status_id: planned_post_status.id -) - -post2 = Post.create( - title: 'There are multiple boards', - description: 'For now you have Feature Requests and Bug Reports, but you can add or remove as many as you want! Just go to Site settings > Boards!', - board_id: bug_board.id, - user_id: owner.id -) - -# # Create some comments -post1.comments.create( - body: 'Users can comment to express their opinions! As with posts and board descriptions, comments can be *Markdown* **formatted**', - user_id: owner.id -) +CreateWelcomeEntitiesWorkflow.new().run # Let the user know how to log in with admin account puts "A default tenant has been created with name #{tenant.site_name}" diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 09c9a20b..c1d40dd8 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -15,11 +15,11 @@ RSpec.describe Post, type: :model do expect(empty_post).to be_invalid end - it 'has a title between 4 and 64 characters' do + it 'has a title between 4 and 128 characters' do too_short_post = FactoryBot.build(:post, title: 'a' * 3) short_post = FactoryBot.build(:post, title: 'a' * 4) - long_post = FactoryBot.build(:post, title: 'a' * 64) - too_long_post = FactoryBot.build(:post, title: 'a' * 65) + long_post = FactoryBot.build(:post, title: 'a' * 128) + too_long_post = FactoryBot.build(:post, title: 'a' * 129) expect(too_short_post).to be_invalid expect(short_post).to be_valid