Skip to content

Commit

Permalink
Merge pull request #11428 from venix12/platform-issue-tags
Browse files Browse the repository at this point in the history
Add platform issue tags
  • Loading branch information
notbakaneko authored Feb 5, 2025
2 parents 13997fb + adfdb19 commit 03a6365
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Forum/TopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function issueTag($id)

$issueTag = presence(Request::input('issue_tag'));
$state = get_bool(Request::input('state'));
$type = 'issue_tag_'.$issueTag;
$type = 'issue_tag_'.str_slug($issueTag);

if ($issueTag === null || !$topic->isIssue() || !in_array($issueTag, $topic::ISSUE_TAGS, true)) {
abort(422);
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Forum/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class Topic extends Model implements AfterCommit
'duplicate',
'invalid',
'resolved',

'osu!lazer',
'osu!stable',
'osu!web',
];

const MAX_FIELD_LENGTHS = [
Expand Down
31 changes: 18 additions & 13 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,20 +1017,25 @@ function make_blade_safe(HtmlString|string $text): HtmlString

function issue_icon($issue)
{
switch ($issue) {
case 'added':
return 'fas fa-cogs';
case 'assigned':
return 'fas fa-user';
case 'confirmed':
return 'fas fa-exclamation-triangle';
case 'resolved':
return 'far fa-check-circle';
case 'duplicate':
return 'fas fa-copy';
case 'invalid':
return 'far fa-times-circle';
$fa = match ($issue) {
'added' => 'fas fa-cogs',
'assigned' => 'fas fa-user',
'confirmed' => 'fas fa-exclamation-triangle',
'duplicate' => 'fas fa-copy',
'invalid' => 'far fa-times-circle',
'resolved' => 'far fa-check-circle',
default => null,
};

if ($fa !== null) {
return tag('i', ['class' => $fa]);
}

return match ($issue) {
'osu!lazer' => 'lzr',
'osu!stable' => 'stb',
'osu!web' => 'web',
};
}

function build_url($build)
Expand Down
13 changes: 13 additions & 0 deletions resources/css/bem/forum-issue-icon.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
font-size: 10px;
color: #fff;
text-shadow: 0 0 2px #000;
--platform-tag: hsl(var(--hsl-darkorange-1));

margin: 0 5px;

Expand All @@ -35,4 +36,16 @@
&--resolved {
background-color: @green-dark;
}

&--osulazer {
background-color: var(--platform-tag);
}

&--osustable {
background-color: var(--platform-tag);
}

&--osuweb {
background-color: var(--platform-tag);
}
}
21 changes: 21 additions & 0 deletions resources/lang/en/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,27 @@
'to_1_done' => 'Added "resolved" tag',
],

'issue_tag_osulazer' => [
'to_0' => 'Remove "osu!lazer" tag',
'to_0_done' => 'Removed "osu!lazer" tag',
'to_1' => 'Add "osu!lazer" tag',
'to_1_done' => 'Added "osu!lazer" tag',
],

'issue_tag_osustable' => [
'to_0' => 'Remove "osu!stable" tag',
'to_0_done' => 'Removed "osu!stable" tag',
'to_1' => 'Add "osu!stable" tag',
'to_1_done' => 'Added "osu!stable" tag',
],

'issue_tag_osuweb' => [
'to_0' => 'Remove "osu!web" tag',
'to_0_done' => 'Removed "osu!web" tag',
'to_1' => 'Add "osu!web" tag',
'to_1_done' => 'Added "osu!web" tag',
],

'lock' => [
'is_locked' => 'This topic is locked and can not be replied to',
'to_0' => 'Unlock topic',
Expand Down
4 changes: 2 additions & 2 deletions resources/views/forum/forums/_topic.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class="
@foreach ($topic->issueTags() as $tag)
<div
title="{{ $tag }}"
class="forum-issue-icon forum-issue-icon--{{ $tag }}"
class="forum-issue-icon forum-issue-icon--{{ str_slug($tag) }}"
>
<i class="{{ issue_icon($tag) }}"></i>
{!! issue_icon($tag) !!}
</div>
@endforeach
</div>
Expand Down
7 changes: 4 additions & 3 deletions resources/views/forum/topics/_issue_tag.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
--}}
<?php
$state = $topic->hasIssueTag($issueTag);
$slug = str_slug($issueTag);
?>
<button
type="button"
class="
js-forum-topic-issue_tag_{{ $issueTag }}
js-forum-topic-issue_tag_{{ $slug }}
btn-circle
btn-circle--topic-nav
btn-circle--purple
{{ $state ? 'btn-circle--activated' : '' }}
"
data-topic-id="{{ $topic->topic_id }}"
title="{{ osu_trans('forum.topics.issue_tag_'.$issueTag.'.to_'.(int) !$state) }}"
title="{{ osu_trans('forum.topics.issue_tag_'.$slug.'.to_'.(int) !$state) }}"
data-url="{{ route('forum.topics.issue-tag', [
$topic,
'state' => !$state,
Expand All @@ -25,6 +26,6 @@ class="
data-method="post"
>
<span class="btn-circle__content">
<i class="{{ issue_icon($issueTag) }}"></i>
{!! issue_icon($issueTag) !!}
</span>
</button>
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_osulazer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'osu!lazer',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_osustable.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'osu!stable',
])
7 changes: 7 additions & 0 deletions resources/views/forum/topics/_issue_tag_osuweb.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{--
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.
--}}
@include('forum.topics._issue_tag', [
'issueTag' => 'osu!web',
])
2 changes: 1 addition & 1 deletion resources/views/forum/topics/_nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@if ($topic->isIssue())
@foreach ($topic::ISSUE_TAGS as $type)
@include("forum.topics._issue_tag_{$type}")
@include('forum.topics._issue_tag_'.str_slug($type))
@endforeach
@endif

Expand Down

0 comments on commit 03a6365

Please sign in to comment.