mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
7 commits
1ab5bd66fb
...
27bc012264
Author | SHA1 | Date | |
---|---|---|---|
|
27bc012264 | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
08235a8da7 | ||
|
48fafc7389 | ||
|
becc24a3b1 | ||
|
3d08ea81a9 |
12 changed files with 51 additions and 52 deletions
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
||||||
|
|
||||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||||
type: NotificationWithStatusType;
|
type: NotificationWithStatusType;
|
||||||
status: ApiStatusJSON;
|
status_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||||
|
|
|
@ -49,22 +49,15 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
||||||
<span>
|
<span>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='filtered_notifications_banner.pending_requests'
|
id='filtered_notifications_banner.pending_requests'
|
||||||
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||||
values={{ count: policy.summary.pending_requests_count }}
|
values={{ count: policy.summary.pending_requests_count }}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='filtered-notifications-banner__badge'>
|
<div className='filtered-notifications-banner__badge'>
|
||||||
<div className='filtered-notifications-banner__badge__badge'>
|
|
||||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||||
</div>
|
</div>
|
||||||
<FormattedMessage
|
|
||||||
id='filtered_notifications_banner.mentions'
|
|
||||||
defaultMessage='{count, plural, one {mention} other {mentions}}'
|
|
||||||
values={{ count: policy.summary.pending_notifications_count }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -300,8 +300,7 @@
|
||||||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||||
"filter_modal.select_filter.title": "Filter this post",
|
"filter_modal.select_filter.title": "Filter this post",
|
||||||
"filter_modal.title.status": "Filter a post",
|
"filter_modal.title.status": "Filter a post",
|
||||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
|
||||||
"filtered_notifications_banner.title": "Filtered notifications",
|
"filtered_notifications_banner.title": "Filtered notifications",
|
||||||
"firehose.all": "All",
|
"firehose.all": "All",
|
||||||
"firehose.local": "This server",
|
"firehose.local": "This server",
|
||||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
||||||
case 'mention':
|
case 'mention':
|
||||||
case 'poll':
|
case 'poll':
|
||||||
case 'update': {
|
case 'update': {
|
||||||
const { status, ...groupWithoutStatus } = group;
|
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||||
return {
|
return {
|
||||||
statusId: status.id,
|
statusId,
|
||||||
sampleAccountIds,
|
sampleAccountIds,
|
||||||
...groupWithoutStatus,
|
...groupWithoutStatus,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10170,27 +10170,12 @@ noscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__badge {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--background-border-color);
|
|
||||||
color: $darker-text-color;
|
|
||||||
padding: 4px;
|
|
||||||
padding-inline-end: 8px;
|
|
||||||
gap: 6px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 11px;
|
|
||||||
line-height: 16px;
|
|
||||||
word-break: keep-all;
|
|
||||||
|
|
||||||
&__badge {
|
&__badge {
|
||||||
background: $ui-button-background-color;
|
background: $ui-button-background-color;
|
||||||
color: $white;
|
color: $white;
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-request {
|
.notification-request {
|
||||||
|
|
|
@ -10,7 +10,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
attribute :critical_updates_pending, if: -> { object&.role&.can?(:view_devops) && SoftwareUpdate.check_enabled? }
|
attribute :critical_updates_pending, if: -> { object&.role&.can?(:view_devops) && SoftwareUpdate.check_enabled? }
|
||||||
|
|
||||||
has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer
|
has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
has_one :role, serializer: REST::RoleSerializer
|
has_one :role, serializer: REST::CredentialRoleSerializer
|
||||||
|
|
||||||
def meta
|
def meta
|
||||||
store = default_meta_store
|
store = default_meta_store
|
||||||
|
|
|
@ -30,15 +30,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RoleSerializer < ActiveModel::Serializer
|
has_many :roles, serializer: REST::RoleSerializer, if: :local?
|
||||||
attributes :id, :name, :color
|
|
||||||
|
|
||||||
def id
|
|
||||||
object.id.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
has_many :roles, serializer: RoleSerializer, if: :local?
|
|
||||||
|
|
||||||
class FieldSerializer < ActiveModel::Serializer
|
class FieldSerializer < ActiveModel::Serializer
|
||||||
include FormattingHelper
|
include FormattingHelper
|
||||||
|
|
|
@ -11,7 +11,7 @@ class REST::Admin::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
has_many :ips, serializer: REST::Admin::IpSerializer
|
has_many :ips, serializer: REST::Admin::IpSerializer
|
||||||
has_one :account, serializer: REST::AccountSerializer
|
has_one :account, serializer: REST::AccountSerializer
|
||||||
has_one :role, serializer: REST::RoleSerializer
|
has_one :role, serializer: REST::CredentialRoleSerializer
|
||||||
|
|
||||||
def id
|
def id
|
||||||
object.id.to_s
|
object.id.to_s
|
||||||
|
|
9
app/serializers/rest/credential_role_serializer.rb
Normal file
9
app/serializers/rest/credential_role_serializer.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::CredentialRoleSerializer < REST::RoleSerializer
|
||||||
|
attributes :permissions
|
||||||
|
|
||||||
|
def permissions
|
||||||
|
object.computed_permissions.to_s
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,8 +6,4 @@ class REST::RoleSerializer < ActiveModel::Serializer
|
||||||
def id
|
def id
|
||||||
object.id.to_s
|
object.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def permissions
|
|
||||||
object.computed_permissions.to_s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
||||||
describe REST::AccountSerializer do
|
describe REST::AccountSerializer do
|
||||||
subject { serialized_record_json(account, described_class) }
|
subject { serialized_record_json(account, described_class) }
|
||||||
|
|
||||||
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) }
|
||||||
let(:user) { Fabricate(:user, role: role) }
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
let(:account) { user.account }
|
let(:account) { user.account }
|
||||||
|
|
||||||
|
@ -20,15 +20,19 @@ describe REST::AccountSerializer do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the account has a highlighted role' do
|
context 'when the account has a highlighted role' do
|
||||||
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) }
|
||||||
|
|
||||||
it 'returns the expected role' do
|
it 'returns the expected role' do
|
||||||
expect(subject['roles'].first).to include({ 'name' => 'Role' })
|
expect(subject['roles'].first).to include({ 'name' => 'Fancy User' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not expose the roles permissions' do
|
||||||
|
expect(subject['roles'].first).to_not include({ 'permissions' => role.computed_permissions.to_s })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the account has a non-highlighted role' do
|
context 'when the account has a non-highlighted role' do
|
||||||
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) }
|
let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: false) }
|
||||||
|
|
||||||
it 'returns empty roles' do
|
it 'returns empty roles' do
|
||||||
expect(subject['roles']).to eq []
|
expect(subject['roles']).to eq []
|
||||||
|
|
21
spec/serializers/rest/credential_account_serializer_spec.rb
Normal file
21
spec/serializers/rest/credential_account_serializer_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe REST::CredentialAccountSerializer do
|
||||||
|
subject { serialized_record_json(account, described_class) }
|
||||||
|
|
||||||
|
let(:role) { Fabricate(:user_role, name: 'Fancy User') }
|
||||||
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
|
let(:account) { user.account }
|
||||||
|
|
||||||
|
context 'when the account has a role' do
|
||||||
|
it 'returns the expected role' do
|
||||||
|
expect(subject['roles'].first).to include({ 'name' => 'Fancy User' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'exposes the role permissions' do
|
||||||
|
expect(subject['roles'].first).to include({ 'permissions' => role.computed_permissions.to_s })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue