-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7694 from fjordllc/main
Release 2024-04-17 02:48:52
- Loading branch information
Showing
80 changed files
with
1,153 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class Connection::DiscordController < ApplicationController | ||
skip_before_action :require_active_user_login, raise: false | ||
|
||
def destroy | ||
current_user.discord_profile.update(account_name: nil) | ||
redirect_to root_path, notice: 'Discordとの連携を解除しました。' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ def work_params | |
:description, | ||
:url, | ||
:repository, | ||
:launch_article, | ||
:thumbnail | ||
) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import React, { useState, useRef } from 'react' | ||
import CSRF from '../csrf.js' | ||
|
||
export default function Following({ isFollowing, userId, isWatching }) { | ||
const [following, setFollowing] = useState(isFollowing) | ||
const [watching, setWatching] = useState(isWatching) | ||
const followingDetailsRef = useRef(null) | ||
|
||
const followOrChangeFollow = (watch) => { | ||
const params = { id: userId, watch: watch } | ||
const method = following ? 'PATCH' : 'POST' | ||
const url = following ? `/api/followings/${userId}` : `/api/followings` | ||
fetch(url, { | ||
method: method, | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8', | ||
'X-Requested-With': 'XMLHttpRequest', | ||
'X-CSRF-Token': CSRF.getToken() | ||
}, | ||
credentials: 'same-origin', | ||
redirect: 'manual', | ||
body: JSON.stringify(params) | ||
}) | ||
.then((response) => { | ||
if (response.ok) { | ||
setFollowing(true) | ||
setWatching(watch) | ||
} else { | ||
alert('フォロー処理に失敗しました') | ||
} | ||
}) | ||
.catch((error) => { | ||
console.warn(error) | ||
}) | ||
.finally(() => { | ||
followingDetailsRef.current.open = false | ||
}) | ||
} | ||
|
||
const unfollow = () => { | ||
const params = { id: userId } | ||
fetch(`/api/followings/${userId}`, { | ||
method: 'DELETE', | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8', | ||
'X-Requested-With': 'XMLHttpRequest', | ||
'X-CSRF-Token': CSRF.getToken() | ||
}, | ||
credentials: 'same-origin', | ||
redirect: 'manual', | ||
body: JSON.stringify(params) | ||
}) | ||
.then((response) => { | ||
if (response.ok) { | ||
setFollowing(false) | ||
setWatching(false) | ||
} else { | ||
alert('フォロー処理に失敗しました') | ||
} | ||
}) | ||
.catch((error) => { | ||
console.warn(error) | ||
}) | ||
.finally(() => { | ||
followingDetailsRef.current.open = false | ||
}) | ||
} | ||
|
||
return ( | ||
<details ref={followingDetailsRef} className="following"> | ||
<summary className="following__summary"> | ||
{following && watching ? ( | ||
<span className="a-button is-warning is-sm is-block"> | ||
<i className="fa-solid fa-check"></i> | ||
<span>コメントあり</span> | ||
</span> | ||
) : following && !watching ? ( | ||
<span className="a-button is-warning is-sm is-block"> | ||
<i className="fa-solid fa-check"></i> | ||
<span>コメントなし</span> | ||
</span> | ||
) : ( | ||
<span className="a-button is-secondary is-sm is-block"> | ||
フォローする | ||
</span> | ||
)} | ||
</summary> | ||
<div className="following__dropdown a-dropdown"> | ||
<ul className="a-dropdown__items"> | ||
<li className="following__dropdown-item a-dropdown__item"> | ||
{following && watching ? ( | ||
<button className="following-option a-dropdown__item-inner is-active"> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">コメントあり</div> | ||
<div className="following-option__desciption"> | ||
フォローしたユーザーの日報を自動でWatch状態にします。日報投稿時の通知と日報にコメントが来た際に通知を受け取ります。 | ||
</div> | ||
</div> | ||
</button> | ||
) : ( | ||
<button | ||
className="following-option a-dropdown__item-inner" | ||
onClick={() => followOrChangeFollow(true)}> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">コメントあり</div> | ||
<div className="following-option__desciption"> | ||
フォローしたユーザーの日報を自動でWatch状態にします。日報投稿時の通知と日報にコメントが来た際に通知を受け取ります。 | ||
</div> | ||
</div> | ||
</button> | ||
)} | ||
</li> | ||
<li className="following__dropdown-item a-dropdown__item"> | ||
{following && !watching ? ( | ||
<button className="following-option a-dropdown__item-inner is-active"> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">コメントなし</div> | ||
<div className="following-option__desciption"> | ||
フォローしたユーザーの日報はWatch状態にしません。日報投稿時の通知だけ通知を受けとります。 | ||
</div> | ||
</div> | ||
</button> | ||
) : ( | ||
<button | ||
className="following-option a-dropdown__item-inner" | ||
onClick={() => followOrChangeFollow(false)}> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">コメントなし</div> | ||
<div className="following-option__desciption"> | ||
フォローしたユーザーの日報はWatch状態にしません。日報投稿時の通知だけ通知を受けとります。 | ||
</div> | ||
</div> | ||
</button> | ||
)} | ||
</li> | ||
<li className="following__dropdown-item a-dropdown__item"> | ||
{!following && !watching ? ( | ||
<button className="following-option a-dropdown__item-inner is-active"> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">フォローしない</div> | ||
</div> | ||
</button> | ||
) : ( | ||
<button | ||
className="following-option a-dropdown__item-inner" | ||
onClick={unfollow}> | ||
<div className="following-option__inner"> | ||
<div className="following-option__label">フォローしない</div> | ||
</div> | ||
</button> | ||
)} | ||
</li> | ||
</ul> | ||
</div> | ||
</details> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react' | ||
import useSWR from 'swr' | ||
import User from './User.jsx' | ||
import Pagination from './Pagination' | ||
import usePage from './hooks/usePage' | ||
import fetcher from '../fetcher' | ||
|
||
export default function GenerationUsers({ generationID }) { | ||
const itemsPerPage = 24 | ||
const { page, setPage } = usePage() | ||
const { data, error } = useSWR( | ||
`/api/generations/${generationID}.json?page=${page}&per=${itemsPerPage}`, | ||
fetcher | ||
) | ||
|
||
if (error) return <>An error has occurred.</> | ||
if (!data) return <>Loading...</> | ||
|
||
return ( | ||
<div className="page-body"> | ||
{data.totalPages > 1 && ( | ||
<Pagination | ||
sum={data.totalPages * itemsPerPage} | ||
per={itemsPerPage} | ||
page={page} | ||
setPage={setPage} | ||
/> | ||
)} | ||
<div className="container"> | ||
<div className="users row"> | ||
{data.users === null ? ( | ||
<div className="empty"> | ||
<i className="fa-solid fa-spinner fa-pulse" /> | ||
ロード中 | ||
</div> | ||
) : data.users.length !== 0 ? ( | ||
data.users.map((user) => ( | ||
<User key={user.id} user={user} currentUser={data.currentUser} /> | ||
)) | ||
) : ( | ||
<div className="row"> | ||
<div className="o-empty-message"> | ||
<div className="o-empty-message__icon"> | ||
<i className="fa-regular fa-smile"></i> | ||
</div> | ||
<p className="o-empty-message_text"> | ||
{generationID}期のユーザー一覧はありません | ||
</p> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
{data.totalPages > 1 && ( | ||
<Pagination | ||
sum={data.totalPages * itemsPerPage} | ||
per={itemsPerPage} | ||
page={page} | ||
setPage={setPage} | ||
/> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.