* Add: #483 特定の公開範囲を無効にするオプション * Fix test partically * Complete
This commit is contained in:
parent
7f9ec2e510
commit
f79fb3adae
24 changed files with 177 additions and 59 deletions
|
@ -116,7 +116,7 @@ class ComposeForm extends ImmutablePureComponent {
|
|||
const fulltext = this.getFulltextForCharacterCounting();
|
||||
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
|
||||
|
||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (isOnlyWhitespace && !anyMedia) || (privacy === 'circle' && !isEditing && !circleId));
|
||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (isOnlyWhitespace && !anyMedia) || (privacy === 'circle' && !isEditing && !circleId) || privacy === 'banned');
|
||||
};
|
||||
|
||||
handleSubmit = (e) => {
|
||||
|
|
|
@ -9,6 +9,7 @@ import Overlay from 'react-overlays/Overlay';
|
|||
|
||||
import CircleIcon from '@/material-icons/400-24px/account_circle.svg?react';
|
||||
import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react';
|
||||
import BlockIcon from '@/material-icons/400-24px/block.svg?react';
|
||||
import PublicUnlistedIcon from '@/material-icons/400-24px/cloud.svg?react';
|
||||
import MutualIcon from '@/material-icons/400-24px/compare_arrows.svg?react';
|
||||
import LoginIcon from '@/material-icons/400-24px/key.svg?react';
|
||||
|
@ -18,7 +19,7 @@ import QuietTimeIcon from '@/material-icons/400-24px/quiet_time.svg?react';
|
|||
import ReplyIcon from '@/material-icons/400-24px/reply.svg?react';
|
||||
import LimitedIcon from '@/material-icons/400-24px/shield.svg?react';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { enableLoginPrivacy, enableLocalPrivacy, enablePublicPrivacy } from 'mastodon/initial_state';
|
||||
import { enabledVisibilites } from 'mastodon/initial_state';
|
||||
|
||||
import { PrivacyDropdownMenu } from './privacy_dropdown_menu';
|
||||
|
||||
|
@ -42,6 +43,8 @@ const messages = defineMessages({
|
|||
reply_long: { id: 'privacy.reply.long', defaultMessage: 'Reply to limited post' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Specific people' },
|
||||
direct_long: { id: 'privacy.direct.long', defaultMessage: 'Everyone mentioned in the post' },
|
||||
banned_short: { id: 'privacy.banned.short', defaultMessage: 'No posting' },
|
||||
banned_long: { id: 'privacy.banned.long', defaultMessage: 'All public range submissions are disabled. User settings need to be modified.' },
|
||||
change_privacy: { id: 'privacy.change', defaultMessage: 'Change post privacy' },
|
||||
unlisted_extra: { id: 'privacy.unlisted.additional', defaultMessage: 'This behaves exactly like public, except the post will not appear in live feeds or hashtags, explore, or Mastodon search, even if you are opted-in account-wide.' },
|
||||
});
|
||||
|
@ -131,7 +134,12 @@ class PrivacyDropdown extends PureComponent {
|
|||
UNSAFE_componentWillMount () {
|
||||
const { intl: { formatMessage } } = this.props;
|
||||
|
||||
this.options = [
|
||||
this.dynamicOptions = [
|
||||
{ icon: 'reply', iconComponent: ReplyIcon, value: 'reply', text: formatMessage(messages.reply_short), meta: formatMessage(messages.reply_long), extra: formatMessage(messages.limited_short), extraIcomComponent: LimitedIcon },
|
||||
{ icon: 'ban', iconComponent: BlockIcon, value: 'banned', text: formatMessage(messages.banned_short), meta: formatMessage(messages.banned_long) },
|
||||
];
|
||||
|
||||
this.originalOptions = [
|
||||
{ icon: 'globe', iconComponent: PublicIcon, value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
||||
{ icon: 'cloud', iconComponent: PublicUnlistedIcon, value: 'public_unlisted', text: formatMessage(messages.public_unlisted_short), meta: formatMessage(messages.public_unlisted_long) },
|
||||
{ icon: 'key', iconComponent: LoginIcon, value: 'login', text: formatMessage(messages.login_short), meta: formatMessage(messages.login_long) },
|
||||
|
@ -139,31 +147,28 @@ class PrivacyDropdown extends PureComponent {
|
|||
{ icon: 'lock', iconComponent: LockIcon, value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
||||
{ icon: 'exchange', iconComponent: MutualIcon, value: 'mutual', text: formatMessage(messages.mutual_short), meta: formatMessage(messages.mutual_long), extra: formatMessage(messages.limited_short), extraIcomComponent: LimitedIcon },
|
||||
{ icon: 'user-circle', iconComponent: CircleIcon, value: 'circle', text: formatMessage(messages.circle_short), meta: formatMessage(messages.circle_long), extra: formatMessage(messages.limited_short), extraIcomComponent: LimitedIcon },
|
||||
{ icon: 'at', iconComponent: AlternateEmailIcon, value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||
...this.dynamicOptions,
|
||||
];
|
||||
|
||||
if (!this.props.noDirect) {
|
||||
this.options.push(
|
||||
{ icon: 'at', iconComponent: AlternateEmailIcon, value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||
);
|
||||
this.options = [...this.originalOptions];
|
||||
|
||||
if (this.props.noDirect) {
|
||||
this.options = this.options.filter((opt) => opt.value !== 'direct');
|
||||
}
|
||||
|
||||
if (this.props.noLimited) {
|
||||
this.options = this.options.filter((opt) => !['mutual', 'circle'].includes(opt.value));
|
||||
}
|
||||
|
||||
if (!enableLoginPrivacy) {
|
||||
this.options = this.options.filter((opt) => opt.value !== 'login');
|
||||
if (enabledVisibilites) {
|
||||
this.options = this.options.filter((opt) => enabledVisibilites.includes(opt.value));
|
||||
}
|
||||
|
||||
if (!enableLocalPrivacy) {
|
||||
this.options = this.options.filter((opt) => opt.value !== 'public_unlisted');
|
||||
if (this.options.length === 0) {
|
||||
this.options.push(this.dynamicOptions.find((opt) => opt.value === 'banned'));
|
||||
this.props.onChange('banned');
|
||||
}
|
||||
|
||||
if (!enablePublicPrivacy) {
|
||||
this.options = this.options.filter((opt) => opt.value !== 'public');
|
||||
}
|
||||
|
||||
this.selectableOptions = [...this.options];
|
||||
}
|
||||
|
||||
setTargetRef = c => {
|
||||
|
@ -183,18 +188,16 @@ class PrivacyDropdown extends PureComponent {
|
|||
const { open, placement } = this.state;
|
||||
|
||||
if (replyToLimited) {
|
||||
if (!this.selectableOptions.some((op) => op.value === 'reply')) {
|
||||
this.selectableOptions.unshift(
|
||||
{ icon: 'reply', iconComponent: ReplyIcon, value: 'reply', text: intl.formatMessage(messages.reply_short), meta: intl.formatMessage(messages.reply_long), extra: intl.formatMessage(messages.limited_short), extraIcomComponent: LimitedIcon },
|
||||
);
|
||||
if (!this.options.some((op) => op.value === 'reply')) {
|
||||
this.options.unshift(this.dynamicOptions.find((opt) => opt.value === 'reply'));
|
||||
}
|
||||
} else {
|
||||
if (this.selectableOptions.some((op) => op.value === 'reply')) {
|
||||
this.selectableOptions = this.selectableOptions.filter((op) => op.value !== 'reply');
|
||||
if (this.options.some((op) => op.value === 'reply')) {
|
||||
this.options = this.options.filter((op) => op.value !== 'reply');
|
||||
}
|
||||
}
|
||||
|
||||
const valueOption = this.selectableOptions.find(item => item.value === value) || this.selectableOptions[0];
|
||||
const valueOption = (disabled ? this.originalOptions : this.options).find(item => item.value === value) || this.options[0];
|
||||
|
||||
return (
|
||||
<div ref={this.setTargetRef} onKeyDown={this.handleKeyDown}>
|
||||
|
@ -217,7 +220,7 @@ class PrivacyDropdown extends PureComponent {
|
|||
<div {...props}>
|
||||
<div className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}>
|
||||
<PrivacyDropdownMenu
|
||||
items={this.selectableOptions}
|
||||
items={this.options}
|
||||
value={value}
|
||||
onClose={this.handleClose}
|
||||
onChange={this.handleChange}
|
||||
|
|
|
@ -14,7 +14,7 @@ import LockIcon from '@/material-icons/400-24px/lock.svg?react';
|
|||
import LockOpenIcon from '@/material-icons/400-24px/no_encryption.svg?react';
|
||||
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { enableLocalPrivacy } from 'mastodon/initial_state';
|
||||
import { enabledVisibilites } from 'mastodon/initial_state';
|
||||
|
||||
|
||||
const messages = defineMessages({
|
||||
|
@ -236,7 +236,7 @@ class SearchabilityDropdown extends PureComponent {
|
|||
{ icon: 'at', iconComponent: AlternateEmailIcon, value: 'limited', text: formatMessage(messages.limited_short), meta: formatMessage(messages.limited_long) },
|
||||
];
|
||||
|
||||
if (!enableLocalPrivacy) {
|
||||
if (!enabledVisibilites.includes('public_unlisted')) {
|
||||
this.options = this.options.filter((opt) => opt.value !== 'public_unlisted');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue