mirror of
https://github.com/funamitech/mastodon
synced 2024-12-11 13:19:01 +09:00
Move URLs to backend in their own file
This commit is contained in:
parent
a77ee0bb6d
commit
b3ff35a75c
@ -7,6 +7,7 @@ import { defineMessages, injectIntl } from 'react-intl';
|
|||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
||||||
import RelativeTimestamp from './relative_timestamp';
|
import RelativeTimestamp from './relative_timestamp';
|
||||||
|
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||||
@ -188,10 +189,20 @@ export default class StatusActionBar extends ImmutablePureComponent {
|
|||||||
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||||
if (isStaff) {
|
if (isStaff && (accountAdminLink || statusAdminLink)) {
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
if (accountAdminLink !== undefined) {
|
||||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }),
|
||||||
|
href: accountAdminLink(status.getIn(['account', 'id'])),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (statusAdminLink !== undefined) {
|
||||||
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.admin_status),
|
||||||
|
href: statusAdminLink(status.getIn(['account', 'id']), status.get('id')),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_cont
|
|||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
|
||||||
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
||||||
|
import { profileLink, accountAdminLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
|
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
|
||||||
@ -77,7 +78,9 @@ export default class ActionBar extends React.PureComponent {
|
|||||||
menu.push(null);
|
menu.push(null);
|
||||||
|
|
||||||
if (account.get('id') === me) {
|
if (account.get('id') === me) {
|
||||||
menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
|
if (profileLink !== undefined) {
|
||||||
|
menu.push({ text: intl.formatMessage(messages.edit_profile), href: profileLink });
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (account.getIn(['relationship', 'following'])) {
|
if (account.getIn(['relationship', 'following'])) {
|
||||||
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||||
@ -131,9 +134,12 @@ export default class ActionBar extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.get('id') !== me && isStaff) {
|
if (account.get('id') !== me && isStaff && (accountAdminLink !== undefined)) {
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: account.get('username') }), href: `/admin/accounts/${account.get('id')}` });
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.admin_account, { name: account.get('username') }),
|
||||||
|
href: accountAdminLink(account.get('id')),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
import Motion from 'flavours/glitch/util/optional_motion';
|
||||||
import spring from 'react-motion/lib/spring';
|
import spring from 'react-motion/lib/spring';
|
||||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
import { termsLink} from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
// This is the spring used with our motion.
|
// This is the spring used with our motion.
|
||||||
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
|
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
|
||||||
@ -42,7 +43,8 @@ export default function ComposerDirectWarning () {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<FormattedMessage {...messages.disclaimer} /> <a href='/terms' target='_blank'><FormattedMessage {...messages.learn_more} /></a>
|
<FormattedMessage {...messages.disclaimer} />
|
||||||
|
{ termsLink !== undefined && <a href={termsLink} target='_blank'><FormattedMessage {...messages.learn_more} /></a> }
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
import Motion from 'flavours/glitch/util/optional_motion';
|
||||||
import spring from 'react-motion/lib/spring';
|
import spring from 'react-motion/lib/spring';
|
||||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
import { profileLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
// This is the spring used with our motion.
|
// This is the spring used with our motion.
|
||||||
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
|
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
|
||||||
@ -20,6 +21,10 @@ const messages = defineMessages({
|
|||||||
|
|
||||||
// The component.
|
// The component.
|
||||||
export default function ComposerWarning () {
|
export default function ComposerWarning () {
|
||||||
|
let lockedLink = <FormattedMessage {...messages.locked} />;
|
||||||
|
if (profileLink !== undefined) {
|
||||||
|
lockedLink = <a href={profileLink}>{lockedLink}</a>;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Motion
|
<Motion
|
||||||
defaultStyle={{
|
defaultStyle={{
|
||||||
@ -43,7 +48,7 @@ export default function ComposerWarning () {
|
|||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
{...messages.disclaimer}
|
{...messages.disclaimer}
|
||||||
values={{ locked: <a href='/settings/profile'><FormattedMessage {...messages.locked} /></a> }}
|
values={{ locked: lockedLink }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -12,6 +12,7 @@ import Permalink from 'flavours/glitch/components/permalink';
|
|||||||
|
|
||||||
// Utils.
|
// Utils.
|
||||||
import { hiddenComponent } from 'flavours/glitch/util/react_helpers';
|
import { hiddenComponent } from 'flavours/glitch/util/react_helpers';
|
||||||
|
import { profileLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
// Messages.
|
// Messages.
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
@ -28,12 +29,14 @@ export default function DrawerAccount ({ account }) {
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
return (
|
return (
|
||||||
<div className='drawer--account'>
|
<div className='drawer--account'>
|
||||||
|
{ profileLink !== undefined && (
|
||||||
<a
|
<a
|
||||||
className='edit'
|
className='edit'
|
||||||
href='/settings/profile'
|
href={ profileLink }
|
||||||
>
|
>
|
||||||
<FormattedMessage {...messages.edit} />
|
<FormattedMessage {...messages.edit} />
|
||||||
</a>
|
</a>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -59,10 +62,12 @@ export default function DrawerAccount ({ account }) {
|
|||||||
>
|
>
|
||||||
<strong>@{account.get('acct')}</strong>
|
<strong>@{account.get('acct')}</strong>
|
||||||
</Permalink>
|
</Permalink>
|
||||||
|
{ profileLink !== undefined && (
|
||||||
<a
|
<a
|
||||||
className='edit'
|
className='edit'
|
||||||
href='/settings/profile'
|
href={ profileLink }
|
||||||
><FormattedMessage {...messages.edit} /></a>
|
><FormattedMessage {...messages.edit} /></a>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import Icon from 'flavours/glitch/components/icon';
|
|||||||
|
|
||||||
// Utils.
|
// Utils.
|
||||||
import { conditionalRender } from 'flavours/glitch/util/react_helpers';
|
import { conditionalRender } from 'flavours/glitch/util/react_helpers';
|
||||||
|
import { signOutLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
// Messages.
|
// Messages.
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
@ -109,7 +110,7 @@ export default function DrawerHeader ({
|
|||||||
<a
|
<a
|
||||||
aria-label={intl.formatMessage(messages.logout)}
|
aria-label={intl.formatMessage(messages.logout)}
|
||||||
data-method='delete'
|
data-method='delete'
|
||||||
href='/auth/sign_out'
|
href={ signOutLink }
|
||||||
title={intl.formatMessage(messages.logout)}
|
title={intl.formatMessage(messages.logout)}
|
||||||
><Icon icon='sign-out' /></a>
|
><Icon icon='sign-out' /></a>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -13,6 +13,7 @@ import { fetchFollowRequests } from 'flavours/glitch/actions/accounts';
|
|||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { fetchLists } from 'flavours/glitch/actions/lists';
|
import { fetchLists } from 'flavours/glitch/actions/lists';
|
||||||
|
import { preferencesLink, profileLink, signOutLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
|
heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
|
||||||
@ -157,9 +158,9 @@ export default class GettingStarted extends ImmutablePureComponent {
|
|||||||
<ColumnSubheading text={intl.formatMessage(messages.lists_subheading)} />
|
<ColumnSubheading text={intl.formatMessage(messages.lists_subheading)} />
|
||||||
{listItems}
|
{listItems}
|
||||||
<ColumnSubheading text={intl.formatMessage(messages.settings_subheading)} />
|
<ColumnSubheading text={intl.formatMessage(messages.settings_subheading)} />
|
||||||
<ColumnLink icon='cog' text={intl.formatMessage(messages.preferences)} href='/settings/preferences' />
|
{ preferencesLink !== undefined && <ColumnLink icon='cog' text={intl.formatMessage(messages.preferences)} href={preferencesLink} /> }
|
||||||
<ColumnLink icon='cogs' text={intl.formatMessage(messages.settings)} onClick={openSettings} />
|
<ColumnLink icon='cogs' text={intl.formatMessage(messages.settings)} onClick={openSettings} />
|
||||||
<ColumnLink icon='sign-out' text={intl.formatMessage(messages.sign_out)} href='/auth/sign_out' method='delete' />
|
<ColumnLink icon='sign-out' text={intl.formatMessage(messages.sign_out)} href={signOutLink} method='delete' />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='getting-started__footer'>
|
<div className='getting-started__footer'>
|
||||||
|
@ -5,6 +5,7 @@ import { injectIntl, defineMessages } from 'react-intl';
|
|||||||
|
|
||||||
// Our imports
|
// Our imports
|
||||||
import LocalSettingsNavigationItem from './item';
|
import LocalSettingsNavigationItem from './item';
|
||||||
|
import { preferencesLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ export default class LocalSettingsNavigation extends React.PureComponent {
|
|||||||
/>
|
/>
|
||||||
<LocalSettingsNavigationItem
|
<LocalSettingsNavigationItem
|
||||||
active={index === 5}
|
active={index === 5}
|
||||||
href='/settings/preferences'
|
href={ preferencesLink }
|
||||||
index={5}
|
index={5}
|
||||||
icon='sliders'
|
icon='sliders'
|
||||||
title={intl.formatMessage(messages.preferences)}
|
title={intl.formatMessage(messages.preferences)}
|
||||||
|
@ -5,6 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||||||
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
import { me, isStaff } from 'flavours/glitch/util/initial_state';
|
||||||
|
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/util/backend_links';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||||
@ -148,10 +149,20 @@ export default class ActionBar extends React.PureComponent {
|
|||||||
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||||
if (isStaff) {
|
if (isStaff && (accountAdminLink || statusAdminLink)) {
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
if (accountAdminLink !== undefined) {
|
||||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }),
|
||||||
|
href: accountAdminLink(status.getIn(['account', 'id'])),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (statusAdminLink !== undefined) {
|
||||||
|
menu.push({
|
||||||
|
text: intl.formatMessage(messages.admin_status),
|
||||||
|
href: statusAdminLink(status.getIn(['account', 'id']), status.get('id')),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
app/javascript/flavours/glitch/util/backend_links.js
Normal file
6
app/javascript/flavours/glitch/util/backend_links.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export const preferencesLink = '/settings/preferences';
|
||||||
|
export const profileLink = '/settings/profile';
|
||||||
|
export const signOutLink = '/auth/sign_out';
|
||||||
|
export const termsLink = '/terms';
|
||||||
|
export const accountAdminLink = (id) => `/admin/accounts/${id}`;
|
||||||
|
export const statusAdminLink = (account_id, status_id) => `/admin/accounts/${account_id}/statuses/${status_id}`;
|
Loading…
Reference in New Issue
Block a user