Move URLs to backend in their own file

master
Thibaut Girka 6 years ago committed by ThibG
parent a77ee0bb6d
commit b3ff35a75c
  1. 17
      app/javascript/flavours/glitch/components/status_action_bar.js
  2. 12
      app/javascript/flavours/glitch/features/account/components/action_bar.js
  3. 4
      app/javascript/flavours/glitch/features/composer/direct_warning/index.js
  4. 7
      app/javascript/flavours/glitch/features/composer/warning/index.js
  5. 25
      app/javascript/flavours/glitch/features/drawer/account/index.js
  6. 3
      app/javascript/flavours/glitch/features/drawer/header/index.js
  7. 5
      app/javascript/flavours/glitch/features/getting_started/index.js
  8. 3
      app/javascript/flavours/glitch/features/local_settings/navigation/index.js
  9. 17
      app/javascript/flavours/glitch/features/status/components/action_bar.js
  10. 6
      app/javascript/flavours/glitch/util/backend_links.js

@ -7,6 +7,7 @@ import { defineMessages, injectIntl } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { me, isStaff } from 'flavours/glitch/util/initial_state';
import RelativeTimestamp from './relative_timestamp';
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/util/backend_links';
const messages = defineMessages({
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.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
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({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
if (accountAdminLink !== undefined) {
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 { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl';
import { me, isStaff } from 'flavours/glitch/util/initial_state';
import { profileLink, accountAdminLink } from 'flavours/glitch/util/backend_links';
const messages = defineMessages({
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
@ -77,7 +78,9 @@ export default class ActionBar extends React.PureComponent {
menu.push(null);
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 {
if (account.getIn(['relationship', 'following'])) {
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({ 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 (

@ -2,6 +2,7 @@ import React from 'react';
import Motion from 'flavours/glitch/util/optional_motion';
import spring from 'react-motion/lib/spring';
import { defineMessages, FormattedMessage } from 'react-intl';
import { termsLink} from 'flavours/glitch/util/backend_links';
// This is the spring used with our motion.
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
@ -42,7 +43,8 @@ export default function ComposerDirectWarning () {
}}
>
<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>
</div>
)}

@ -2,6 +2,7 @@ import React from 'react';
import Motion from 'flavours/glitch/util/optional_motion';
import spring from 'react-motion/lib/spring';
import { defineMessages, FormattedMessage } from 'react-intl';
import { profileLink } from 'flavours/glitch/util/backend_links';
// This is the spring used with our motion.
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
@ -20,6 +21,10 @@ const messages = defineMessages({
// The component.
export default function ComposerWarning () {
let lockedLink = <FormattedMessage {...messages.locked} />;
if (profileLink !== undefined) {
lockedLink = <a href={profileLink}>{lockedLink}</a>;
}
return (
<Motion
defaultStyle={{
@ -43,7 +48,7 @@ export default function ComposerWarning () {
>
<FormattedMessage
{...messages.disclaimer}
values={{ locked: <a href='/settings/profile'><FormattedMessage {...messages.locked} /></a> }}
values={{ locked: lockedLink }}
/>
</div>
)}

@ -12,6 +12,7 @@ import Permalink from 'flavours/glitch/components/permalink';
// Utils.
import { hiddenComponent } from 'flavours/glitch/util/react_helpers';
import { profileLink } from 'flavours/glitch/util/backend_links';
// Messages.
const messages = defineMessages({
@ -28,12 +29,14 @@ export default function DrawerAccount ({ account }) {
if (!account) {
return (
<div className='drawer--account'>
<a
className='edit'
href='/settings/profile'
>
<FormattedMessage {...messages.edit} />
</a>
{ profileLink !== undefined && (
<a
className='edit'
href={ profileLink }
>
<FormattedMessage {...messages.edit} />
</a>
)}
</div>
);
}
@ -59,10 +62,12 @@ export default function DrawerAccount ({ account }) {
>
<strong>@{account.get('acct')}</strong>
</Permalink>
<a
className='edit'
href='/settings/profile'
><FormattedMessage {...messages.edit} /></a>
{ profileLink !== undefined && (
<a
className='edit'
href={ profileLink }
><FormattedMessage {...messages.edit} /></a>
)}
</div>
);
}

@ -10,6 +10,7 @@ import Icon from 'flavours/glitch/components/icon';
// Utils.
import { conditionalRender } from 'flavours/glitch/util/react_helpers';
import { signOutLink } from 'flavours/glitch/util/backend_links';
// Messages.
const messages = defineMessages({
@ -109,7 +110,7 @@ export default function DrawerHeader ({
<a
aria-label={intl.formatMessage(messages.logout)}
data-method='delete'
href='/auth/sign_out'
href={ signOutLink }
title={intl.formatMessage(messages.logout)}
><Icon icon='sign-out' /></a>
</nav>

@ -13,6 +13,7 @@ import { fetchFollowRequests } from 'flavours/glitch/actions/accounts';
import { List as ImmutableList } from 'immutable';
import { createSelector } from 'reselect';
import { fetchLists } from 'flavours/glitch/actions/lists';
import { preferencesLink, profileLink, signOutLink } from 'flavours/glitch/util/backend_links';
const messages = defineMessages({
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)} />
{listItems}
<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='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 className='getting-started__footer'>

@ -5,6 +5,7 @@ import { injectIntl, defineMessages } from 'react-intl';
// Our imports
import LocalSettingsNavigationItem from './item';
import { preferencesLink } from 'flavours/glitch/util/backend_links';
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -71,7 +72,7 @@ export default class LocalSettingsNavigation extends React.PureComponent {
/>
<LocalSettingsNavigationItem
active={index === 5}
href='/settings/preferences'
href={ preferencesLink }
index={5}
icon='sliders'
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 { defineMessages, injectIntl } from 'react-intl';
import { me, isStaff } from 'flavours/glitch/util/initial_state';
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/util/backend_links';
const messages = defineMessages({
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.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
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({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
if (accountAdminLink !== undefined) {
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')),
});
}
}
}

@ -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…
Cancel
Save