Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add group history page #10430

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3b45416
Stricter / more accurate query parsing, return params in response
cl8n Sep 22, 2023
1dd4c09
Return relevant groups in response
cl8n Sep 22, 2023
9eef9c3
Show actor for default group events only if user is privileged
cl8n Sep 22, 2023
94f2c2d
Include actor as null rather than all null values
cl8n Sep 22, 2023
16270f9
Add group history page
cl8n Sep 22, 2023
80eb4e3
Fix test name
cl8n Sep 22, 2023
9588b1d
Remove duplicate get_params type
cl8n Sep 22, 2023
3801d1c
Merge master
cl8n May 21, 2024
cf2121e
Rename playmodes to rulesets where possible
cl8n Feb 24, 2024
731d16a
Normal map observable for group store
cl8n Feb 26, 2024
634f4dc
Make group-history style options modifiers instead of elements
cl8n May 21, 2024
0160922
Readonly lint
cl8n May 21, 2024
0cea8e5
Set css vars at group-history-event block
cl8n May 21, 2024
0738dba
Fix `for` on labels
cl8n May 28, 2024
e6896cb
Use form-select for group selector
cl8n May 28, 2024
a9ba277
Fix date selector icon colors on some browsers
cl8n May 28, 2024
e97b94c
Merge master
cl8n May 28, 2024
a9b3697
Don't build FA var names
cl8n Jun 17, 2024
fe42af5
flex-end instead of end
cl8n Jun 17, 2024
285fcd5
Unify margin for group history form select
cl8n Jun 17, 2024
80a3881
Move text overflow behavior to all form-select inputs
cl8n Jun 17, 2024
220dfcb
No kebab
cl8n Jun 17, 2024
5c29f57
Set grid span on element
cl8n Jun 17, 2024
a7de9a8
Fixed with icons
cl8n Jun 17, 2024
5c9e70f
Refactor current param updating & button behavior
cl8n Jun 17, 2024
aa51786
Fix state when navigating back
cl8n Jun 17, 2024
d9797d1
Merge master
cl8n Jun 17, 2024
7ec8a6c
Unneeded for/id for label/input
cl8n Jun 20, 2024
398ce31
Merge group history event type styling
cl8n Jun 20, 2024
87573fe
Better name
cl8n Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions app/Http/Controllers/GroupHistoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace App\Http\Controllers;

use App\Models\Group;
use App\Models\User;
use App\Models\UserGroupEvent;

Expand All @@ -16,11 +17,10 @@ public function index()
{
$rawParams = request()->all();
$params = get_params($rawParams, null, [
'group:string',
'group',
'max_date:time',
'min_date:time',
'sort:string',
'user:string',
'user',
], ['null_missing' => true]);
$query = UserGroupEvent::visibleForUser(auth()->user());

Expand All @@ -36,11 +36,19 @@ public function index()
}

if ($params['max_date'] !== null) {
$params['max_date']->endOfDay();

$query->where('created_at', '<=', $params['max_date']);

$params['max_date'] = json_date($params['max_date']);
}

if ($params['min_date'] !== null) {
$params['min_date']->startOfDay();

$query->where('created_at', '>=', $params['min_date']);

$params['min_date'] = json_date($params['min_date']);
}

if ($params['user'] !== null) {
Expand All @@ -53,16 +61,28 @@ public function index()
}
}

$cursorHelper = UserGroupEvent::makeDbCursorHelper($params['sort']);
$cursorHelper = UserGroupEvent::makeDbCursorHelper($rawParams['sort'] ?? null);
$params['sort'] = $cursorHelper->getSortName();
[$events, $hasMore] = $query
->cursorSort($cursorHelper, cursor_from_params($rawParams))
->limit(50)
->getWithHasMore();
$cursor = $cursorHelper->next($events, $hasMore);

return [
$eventGroupIds = $events->pluck('group_id');
$groups = app('groups')->all()->filter(
fn (Group $group) =>
$eventGroupIds->contains($group->getKey()) ||
priv_check('GroupShow', $group)->can(),
);
$json = [
...cursor_for_response($cursorHelper->next($events, $hasMore)),
'events' => json_collection($events, 'UserGroupEvent'),
...cursor_for_response($cursor),
'groups' => json_collection($groups, 'Group'),
'params' => $params,
];

return is_json_request()
? $json
: ext_view('group_history.index', compact('json'));
}
}
14 changes: 14 additions & 0 deletions app/Libraries/OsuAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use App\Models\Forum\Topic;
use App\Models\Forum\TopicCover;
use App\Models\Genre;
use App\Models\Group;
use App\Models\Language;
use App\Models\LegacyMatch\LegacyMatch;
use App\Models\Multiplayer\Room;
Expand Down Expand Up @@ -1769,6 +1770,15 @@ public function checkForumTopicVote(?User $user, Topic $topic): string
return 'ok';
}

public function checkGroupShow(?User $user, Group $group): string
{
if ($group->hasListing() || $user?->isGroup($group)) {
return 'ok';
}

return 'unauthorized';
}

public function checkIsOwnClient(?User $user, Client $client): string
{
if ($user === null || $user->getKey() !== $client->user_id) {
Expand Down Expand Up @@ -1918,6 +1928,10 @@ public function checkScorePin(?User $user, ScoreBest|Solo\Score $score): string

public function checkUserGroupEventShowActor(?User $user, UserGroupEvent $event): string
{
if ($event->group->identifier === 'default') {
return $user?->isPrivileged() ? 'ok' : 'unauthorized';
}

if ($user?->isGroup($event->group)) {
return 'ok';
}
Expand Down
3 changes: 3 additions & 0 deletions app/Libraries/RouteSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class RouteSection
'friends_controller' => [
'_' => 'home',
],
'group_history_controller' => [
'_' => 'home',
],
'groups_controller' => [
'_' => 'home',
],
Expand Down
4 changes: 4 additions & 0 deletions app/Transformers/UserGroupEventTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function transform(UserGroupEvent $event): array

public function includeActor(UserGroupEvent $event): ResourceInterface
{
if ($event->actor_id === null) {
return $this->null();
}

return $this->primitive([
'id' => $event->actor_id,
'username' => $event->details['actor_name'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@discordapp/twemoji": "^14.0.2",
"@fortawesome/fontawesome-free": "^5.6.3",
"@fortawesome/fontawesome-free": "^5.15.4",
"@types/autosize": "^4.0.1",
"@types/bootstrap": "^3.3.0",
"@types/d3": "^7.1.0",
Expand Down
3 changes: 3 additions & 0 deletions resources/css/bem-index.less
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
@import "bem/game-mode";
@import "bem/game-mode-link";
@import "bem/grid-items";
@import "bem/group-history";
@import "bem/group-history-event";
@import "bem/group-history-search-form";
@import "bem/header-buttons";
@import "bem/header-nav-mobile";
@import "bem/header-nav-v4";
Expand Down
65 changes: 65 additions & 0 deletions resources/css/bem/group-history-event.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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.

.group-history-event {
@_top: group-history-event;

align-items: center;
display: flex;
font-size: @font-size--title-small;
gap: 15px;

&__icon {
@icons: {
group-add: users;
group-remove: users-slash;
group-rename: users-cog;
user-add: user-plus;
user-add-playmodes: user-tag;
user-remove: user-minus;
user-remove-playmodes: user-tag;
user-set-default: user-cog;
};
each(@icons, {
.@{_top}--@{key} & {
@icon-var: 'fa-var-@{value}';
--icon: @@icon-var;
}
});
cl8n marked this conversation as resolved.
Show resolved Hide resolved

.fas();
cl8n marked this conversation as resolved.
Show resolved Hide resolved
background-color: var(--group-colour, hsl(var(--hsl-b1)));
border-radius: 10000px;
color: hsl(var(--hsl-b6));
padding: 3px 6px;

&::before {
content: var(--icon);
}
}

&__info {
align-items: end;
cl8n marked this conversation as resolved.
Show resolved Hide resolved
color: hsl(var(--hsl-f1));
column-gap: 15px;
display: flex;
flex-direction: column;
flex-shrink: 0;
font-size: @font-size--normal;

@media @desktop {
flex-direction: row-reverse;
}
}

&__message {
@bold-events: group-add, group-remove, group-rename;
each(@bold-events, {
.@{_top}--@{value} & {
font-weight: bold;
}
});

flex-grow: 1;
}
}
63 changes: 63 additions & 0 deletions resources/css/bem/group-history-search-form.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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.

.group-history-search-form {
--input-bg: hsl(var(--hsl-b5));
--input-border-radius: @border-radius--large;
background: hsl(var(--hsl-b4));

&__content {
.default-gutter-v2();
padding-bottom: 20px;
padding-top: 20px;

&--buttons {
background-color: hsl(var(--hsl-b3));
display: flex;
gap: 10px;
justify-content: center;
padding-bottom: 10px;
padding-top: 10px;
}

&--inputs {
display: grid;
gap: 10px;
grid-template-columns: repeat(2, 1fr) repeat(2, 180px);

@media @mobile {
grid-template-columns: repeat(2, 1fr);

> :nth-child(-n + 2) {
grid-column: span 2;
}
cl8n marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

&__input {
.reset-input();
font-size: @font-size--title-small-3;
width: 100%;
}

&__label {
color: var(--label-colour);
padding-bottom: 5px;
}

&__select-container {
position: relative;

&::after {
.center-content();
.fas();
content: @fa-var-chevron-down;
height: 100%;
padding-left: 10px;
pointer-events: none;
position: absolute;
right: 5px;
}
}
}
16 changes: 16 additions & 0 deletions resources/css/bem/group-history.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

.group-history {
&__events {
display: flex;
flex-direction: column;
gap: 10px;
}

&__none {
cl8n marked this conversation as resolved.
Show resolved Hide resolved
font-size: @font-size--title-small-3;
margin: 0;
text-align: center;
}
}
10 changes: 10 additions & 0 deletions resources/css/bem/osu-page.less
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@
.default();
}

&--group-history-footer {
.default();
.default-gutter-v2();
background-color: hsl(var(--hsl-b4));
font-size: @font-size--normal;
padding-bottom: 10px;
padding-top: 10px;
text-align: center;
}

&--info-bar {
.default-gutter-v2();
padding-top: 5px;
Expand Down
3 changes: 2 additions & 1 deletion resources/css/bem/show-more-link.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
margin: 40px 0;
}

&--chat-conversation-earlier-messages {
&--chat-conversation-earlier-messages,
&--group-history {
margin: 20px auto 0;
}

Expand Down
11 changes: 11 additions & 0 deletions resources/js/entrypoints/group-history.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

import Main from 'group-history/main';
import core from 'osu-core-singleton';
import * as React from 'react';
import { parseJson } from 'utils/json';

core.reactTurbolinks.register('group-history', () => (
<Main {...parseJson('json-group-history')} />
));
Loading