Skip to content

Commit

Permalink
Merge pull request #7802 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2024-06-04 14:22:37 +0000
  • Loading branch information
komagata authored Jun 6, 2024
2 parents 96d3ca3 + 9f0434a commit 05326cb
Show file tree
Hide file tree
Showing 76 changed files with 763 additions and 394 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Metrics/ModuleLength:
Exclude:
- app/decorators/user_decorator.rb

Lint/MissingSuper:
Exclude:
- 'app/components/**/*'

AllCops:
Exclude:
- '**/templates/**/*'
Expand Down
1 change: 1 addition & 0 deletions .traceroute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ ignore_unreachable_actions:
- any_login\/.*
- .*#recaptcha_enabled?
- .*#valid_recaptcha?
- .*#system_test_entrypoint
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gem 'stringio', '3.1.0'
gem 'stripe'
gem 'stripe-i18n', git: 'https://github.com/komagata/stripe-i18n', branch: 'update-depencency'
gem 'tzinfo', '~> 2.0', '>= 2.0.6'
gem 'view_component'

group :development, :test do
gem 'byebug', platforms: %i[mri mingw x64_mingw]
Expand Down
15 changes: 11 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ GEM
netrc (0.11.0)
newspaper (0.2.0)
nio4r (2.7.0)
nokogiri (1.16.2-arm64-darwin)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
oauth-tty (~> 1.0, >= 1.0.1)
Expand Down Expand Up @@ -446,7 +446,8 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rollbar (3.5.2)
rss (0.3.0)
rexml
Expand Down Expand Up @@ -535,6 +536,7 @@ GEM
unicode_utils (~> 1.4)
strings-ansi (0.2.0)
stripe (10.1.0)
strscan (3.1.0)
syntax_suggest (1.1.0)
temple (0.10.3)
thor (1.3.0)
Expand All @@ -561,6 +563,10 @@ GEM
uniform_notifier (1.16.0)
vcr (6.2.0)
version_gem (1.1.3)
view_component (3.11.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
view_source_map (0.3.0)
rails (>= 5)
web-console (4.2.1)
Expand Down Expand Up @@ -682,6 +688,7 @@ DEPENDENCIES
traceroute
tzinfo (~> 2.0, >= 2.0.6)
vcr
view_component
view_source_map
web-console (>= 4.1.0)
webmock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
.thumbnail-card__inner
.thumbnail-card__row
= link_to work, class: 'thumbnail-card__image-link' do
- if work.thumbnail.attached?
= image_tag work.thumbnail_url, class: 'thumbnail-card__image'
- else
= image_tag('work-blank.svg', class: 'thumbnail-card__image')
= thumbnail
.thumbnail-card__row
h2.thumbnail-card__title
= link_to work, class: 'thumbnail-card__title-link' do
Expand All @@ -18,7 +15,7 @@
.thumbnail-card__icon
= link_to user_path(work.user) do
span class="a-user-role is-#{work.user.primary_role}"
= image_tag work.user.avatar_url, title: work.user.icon_title, class: 'a-user-icons__item-icon a-user-icon'
= creator_avatar
.thumbnail-card__user
= link_to work.user.name, user_path(work.user), class: 'a-user-name'
.thumbnail-card__metas
Expand Down
23 changes: 23 additions & 0 deletions app/components/works/work_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class Works::WorkComponent < ViewComponent::Base
def initialize(work:)
@work = work
end

def thumbnail
if work.thumbnail.attached?
image_tag work.thumbnail_url, class: 'thumbnail-card__image'
else
image_tag('work-blank.svg', class: 'thumbnail-card__image')
end
end

def creator_avatar
image_tag work.user.avatar_url, title: work.user.icon_title, class: 'a-user-icons__item-icon a-user-icon'
end

private

attr_reader :work
end
12 changes: 12 additions & 0 deletions app/controllers/admin/invitation_url_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class Admin::InvitationUrlController < AdminController
def index
@invitation_url_template = new_user_url(
company_id: 'dummy_company_id',
role: 'dummy_role',
course_id: 'dummy_course_id',
token: ENV['TOKEN'] || 'token'
)
end
end
2 changes: 2 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def index
else
user_scope.where(retired_on: nil)
end
@job = params[:job]
user_scope = user_scope.users_job(@job) if @job.present?
@users = user_scope.with_attached_avatar
.preload(:company, :course)
.order_by_counts(params[:order_by] || 'id', @direction)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def search_for_users(target, target_users, search_word)
end

def target_allowlist
target_allowlist = %w[student_and_trainee followings mentor graduate adviser trainee year_end_party]
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party]
target_allowlist.push('job_seeking') if current_user.adviser?
target_allowlist.push('all') if @company
target_allowlist.concat(%w[job_seeking hibernated retired inactive all]) if current_user.mentor? || current_user.admin?
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/reports/unchecked_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

class Reports::UncheckedController < ApplicationController
PAGER_NUMBER = 25

before_action :require_staff_login
def index; end
def index
@reports = Report.unchecked.not_wip.list.page(params[:page]).per(PAGER_NUMBER)
end
end
9 changes: 8 additions & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class ReportsController < ApplicationController
PAGER_NUMBER = 25

include Rails.application.routes.url_helpers
before_action :set_report, only: %i[show]
before_action :set_my_report, only: %i[destroy]
Expand All @@ -11,7 +13,10 @@ class ReportsController < ApplicationController
before_action :set_categories, only: %i[create update]
before_action :set_watch, only: %i[show]

def index; end
def index
@reports = Report.list.page(params[:page]).per(PAGER_NUMBER)
@reports = @reports.joins(:practices).where(practices: { id: params[:practice_id] }) if params[:practice_id].present?
end

def show
@products = @report.user.products.not_wip.order(published_at: :desc)
Expand Down Expand Up @@ -58,6 +63,7 @@ def create
end

def update
before_wip_status = @report.wip
set_wip
@report.practice_ids = nil if params[:report][:practice_ids].nil?
@report.assign_attributes(report_params)
Expand All @@ -66,6 +72,7 @@ def update
Newspaper.publish(:report_save, { report: @report })
redirect_to redirect_url(@report), notice: notice_message(@report), flash: flash_contents(@report)
else
@report.wip = before_wip_status
render :edit
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def fetch_target_users
end

def target_allowlist
target_allowlist = %w[student_and_trainee followings mentor graduate adviser trainee year_end_party]
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party]
target_allowlist.push('job_seeking') if current_user.adviser?
target_allowlist.concat(%w[job_seeking hibernated retired inactive all]) if current_user.mentor? || current_user.admin?
target_allowlist
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ def all_countries_with_subdivisions
.to_h
.to_json
end

def roles_for_select
roles = %w[all student_and_trainee inactive hibernated retired graduate adviser mentor trainee year_end_party campaign]
roles.map { |role| [t("target.#{role}"), role] }
end

def jobs_for_select
user_jobs = User.jobs.keys.map { |job| [t("activerecord.enums.user.job.#{job}"), job] }
user_jobs.prepend(%w[全員 all])
end
end
5 changes: 4 additions & 1 deletion app/javascript/components/CommentUserIcon.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react'

export default function CommentUserIcon({ comment }) {
const roleClass = `is-${comment.primary_role}`
return (
<a
className="card-list-item__user-icons-icon"
href={`/users/${comment.user_id}`}>
<img className="a-user-icon" src={comment.user_icon} />
<span className={`a-user-role ${roleClass}`}>
<img className="a-user-icon" src={comment.user_icon} />
</span>
</a>
)
}
14 changes: 8 additions & 6 deletions app/javascript/components/Product.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ const UserIcons = ({ users }) => {
key={user.url}
href={user.url}
className="card-list-item__user-icons-icon">
<img
title={user.icon_title}
alt={user.icon_title}
src={user.avatar_url}
className={`a-user-icon is-${user.primary_role}`}
/>
<span className={`a-user-role is-${user.primary_role}`}>
<img
title={user.icon_title}
alt={user.icon_title}
src={user.avatar_url}
className="a-user-icon"
/>
</span>
</a>
))}
</div>
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/components/external-entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
.card-list-item__inner
.card-list-item__user
a.card-list-item__user-link(:href='externalEntry.user.url')
img.card-list-item__user-icon.a-user-icon(
:title='externalEntry.user.icon_title',
:alt='externalEntry.user.icon_title',
:src='externalEntry.user.avatar_url')
span(:class='`a-user-role is-${externalEntry.user.primary_role}`')
img.card-list-item__user-icon.a-user-icon(
:title='externalEntry.user.icon_title',
:alt='externalEntry.user.icon_title',
:src='externalEntry.user.avatar_url')
.card-list-item__rows
.card-list-item__row
.card-list-item-title
Expand Down
57 changes: 0 additions & 57 deletions app/javascript/elapsed_days.vue

This file was deleted.

40 changes: 40 additions & 0 deletions app/javascript/invitation-url-updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
document.addEventListener('DOMContentLoaded', async () => {
const invitationElements = Array.from(
document.querySelectorAll('.invitation__element select')
)
const invitationUrl = document.querySelector('.js-invitation-url')
const invitationUrlText = document.querySelector('.js-invitation-url-text')

if (invitationElements.length === 0 || !invitationUrlText || !invitationUrl) {
return
}

const updateInvitationURL = async () => {
const invitationCompany = document.querySelector('.js-invitation-company')
const invitationRole = document.querySelector('.js-invitation-role')
const invitationCourse = document.querySelector('.js-invitation-course')

const selectedCompanyId =
invitationCompany.options[invitationCompany.selectedIndex].value
const selectedRole =
invitationRole.options[invitationRole.selectedIndex].value
const selectedCourseId =
invitationCourse.options[invitationCourse.selectedIndex].value

const invitationUrlTemplate =
document.querySelector('.invitation__url').dataset.invitationUrlTemplate
const targetUrl = invitationUrlTemplate
.replace(/company_id=[^&]*/, `company_id=${selectedCompanyId}`)
.replace(/role=[^&]*/, `role=${selectedRole}`)
.replace(/course_id=[^&]*/, `course_id=${selectedCourseId}`)

invitationUrl.href = targetUrl
invitationUrlText.value = targetUrl
}

invitationElements.forEach((invitationElement) => {
invitationElement.addEventListener('change', updateInvitationURL)
})

window.addEventListener('pageshow', updateInvitationURL)
})
1 change: 1 addition & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import '../upload-image-to-article.js'
import '../header-dropdown.js'
import '../editor-selection-form.js'
import '../user_mentor_memo.js'
import '../invitation-url-updater.js'

import VueMounter from '../VueMounter.js'
import Books from '../components/books.vue'
Expand Down
Loading

0 comments on commit 05326cb

Please sign in to comment.