-
Notifications
You must be signed in to change notification settings - Fork 387
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 #11744 from nanaya/member-remove
Add member management page
- Loading branch information
Showing
9 changed files
with
226 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Teams; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Team; | ||
use App\Models\TeamMember; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MembersController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->middleware('auth'); | ||
} | ||
|
||
public function destroy(string $teamId, string $userId): Response | ||
{ | ||
$teamMember = TeamMember::where([ | ||
'team_id' => $teamId, | ||
'user_id' => $userId, | ||
])->firstOrFail(); | ||
|
||
if ($teamMember->user_id === \Auth::user()->getKey()) { | ||
abort(422, 'can not remove self from team'); | ||
} | ||
|
||
priv_check('TeamUpdate', $teamMember->team)->ensureCan(); | ||
|
||
$teamMember->delete(); | ||
\Session::flash('popup', osu_trans('teams.members.destroy.success')); | ||
|
||
return response(null, 204); | ||
} | ||
|
||
public function index(string $teamId): Response | ||
{ | ||
$team = Team::findOrFail($teamId); | ||
|
||
priv_check('TeamUpdate', $team)->ensureCan(); | ||
|
||
$team->load('members.user'); | ||
|
||
return ext_view('teams.members.index', compact('team')); | ||
} | ||
} |
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
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,41 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
.team-members-manage { | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
font-size: @font-size--title-small; | ||
display: grid; | ||
gap: 2px 10px; | ||
grid-template-columns: auto 1fr auto auto auto; | ||
|
||
&__avatar { | ||
.default-border-radius(); | ||
overflow: hidden; | ||
width: @user-list-icon-size; | ||
height: $width; | ||
} | ||
|
||
&__item { | ||
--bg: hsl(var(--hsl-b3)); | ||
--bg-hover: hsl(var(--hsl-b2)); | ||
.default-border-radius(); | ||
display: grid; | ||
grid-template-columns: subgrid; | ||
grid-column: 1 / -1; | ||
align-items: center; | ||
padding: 3px 10px; | ||
background: var(--bg); | ||
|
||
&:hover { | ||
background: var(--bg-hover); | ||
} | ||
|
||
&--header { | ||
--bg: none; | ||
--bg-hover: var(--bg); | ||
font-weight: 600; | ||
} | ||
} | ||
} |
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
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,92 @@ | ||
{{-- | ||
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
See the LICENCE file in the repository root for full licence text. | ||
--}} | ||
@extends('master') | ||
|
||
@section('content') | ||
@include('layout._page_header_v4', ['params' => [ | ||
'theme' => 'team', | ||
'backgroundImage' => $team->header()->url(), | ||
]]) | ||
|
||
<div class="osu-page osu-page--generic-compact"> | ||
<div class="user-profile-pages user-profile-pages--no-tabs"> | ||
<div class="page-extra"> | ||
<h2 class="title title--page-extra-small title--page-extra-small-top"> | ||
{{ osu_trans('teams.members.index.table.title') }} | ||
</h2> | ||
<ul class="team-members-manage"> | ||
<li class="team-members-manage__item team-members-manage__item--header"> | ||
<span></span> | ||
<span></span> | ||
<span>{{ osu_trans('teams.members.index.table.status') }}</span> | ||
<span>{{ osu_trans('teams.members.index.table.joined_at') }}</span> | ||
<span></span> | ||
@foreach ($team->members as $member) | ||
<li class="team-members-manage__item"> | ||
<span class="team-members-manage__avatar"> | ||
<span | ||
class="avatar avatar--full avatar--guest" | ||
{!! background_image($member->user->user_avatar) !!} | ||
></span> | ||
</span> | ||
<span> | ||
{!! link_to_user($member->user, null, '', []) !!} | ||
</span> | ||
<span> | ||
{{ osu_trans('teams.members.index.status.status_'.(int) $member->user->isActive()) }} | ||
@if ($member->user->isOnline()) | ||
<small> | ||
({!! osu_trans('users.show.lastvisit_online') !!}) | ||
</small> | ||
@elseif (($lastvisit = $member->user->displayed_last_visit) !== null) | ||
<small> | ||
({!! osu_trans('users.show.lastvisit', ['date' => timeago($lastvisit)]) !!}) | ||
</small> | ||
@endif | ||
</span> | ||
<span> | ||
{!! timeago($member->created_at) !!} | ||
</span> | ||
<span> | ||
<form | ||
action="{{ route('teams.members.destroy', compact('member', 'team')) }}" | ||
class="u-contents" | ||
data-confirm="{{ osu_trans('common.confirmation') }}" | ||
data-reload-on-success="1" | ||
data-remote="1" | ||
method="POST" | ||
> | ||
<input type="hidden" name="_method" value="DELETE" /> | ||
<button | ||
class="btn-osu-big btn-osu-big--rounded-small" | ||
{{ $member->user_id === $team->leader_id ? 'disabled' : '' }} | ||
> | ||
{{ osu_trans('teams.members.index.table.remove') }} | ||
</button> | ||
</form> | ||
</span> | ||
@endforeach | ||
</ul> | ||
</div> | ||
|
||
<div class="page-extra"> | ||
<div class="team-settings"> | ||
<div class="team-settings__item team-settings__item--buttons"> | ||
<div> | ||
<a | ||
class="btn-osu-big btn-osu-big--rounded-thin" | ||
href="{{ route('teams.show', ['team' => $team]) }}" | ||
> | ||
{{ osu_trans('common.buttons.back') }} | ||
</a> | ||
</div> | ||
|
||
<div></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
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