Verified Commit 9f515e80 authored by Haelwenn's avatar Haelwenn
Browse files

Getting-Started: Add button to switch between the two flavours

parent 8e3718cf
......@@ -8,6 +8,7 @@ import ColumnLink from 'flavours/glitch/features/ui/components/column_link';
import ColumnSubheading from 'flavours/glitch/features/ui/components/column_subheading';
import { openModal } from 'flavours/glitch/actions/modal';
import { connect } from 'react-redux';
import { switchFlavour } from 'mastodon/actions/pleroma';
const messages = defineMessages({
heading: { id: 'column.heading', defaultMessage: 'Misc' },
......@@ -22,6 +23,7 @@ const messages = defineMessages({
info: { id: 'navigation_bar.info', defaultMessage: 'Extended information' },
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Keyboard shortcuts' },
featured_users: { id: 'navigation_bar.featured_users', defaultMessage: 'Featured users' },
switch_to_vanilla: { id: 'navigation_bar.switch_to_vanilla', defaultMessage: 'Switch to Vanilla Flavour' },
});
@connect()
......@@ -31,6 +33,7 @@ export default class gettingStartedMisc extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
switchFlavour: PropTypes.func.isRequired,
};
openOnboardingModal = (e) => {
......@@ -41,6 +44,10 @@ export default class gettingStartedMisc extends ImmutablePureComponent {
this.props.dispatch(openModal('PINNED_ACCOUNTS_EDITOR'));
}
switch_flavour_vanilla = (e) => {
this.props.dispatch(switchFlavour('vanilla'));
}
render () {
const { intl } = this.props;
......@@ -61,6 +68,7 @@ export default class gettingStartedMisc extends ImmutablePureComponent {
<ColumnLink key='{i++}' icon='question' text={intl.formatMessage(messages.keyboard_shortcuts)} to='/keyboard-shortcuts' />
<ColumnLink key='{i++}' icon='book' text={intl.formatMessage(messages.info)} href='/about/more' />
<ColumnLink key='{i++}' icon='hand-o-right' text={intl.formatMessage(messages.show_me_around)} onClick={this.openOnboardingModal} />
<ColumnLink key='{i++}' icon='exchange' text={intl.formatMessage(messages.switch_to_vanilla)} onClick={this.switch_flavour_vanilla} />
</div>
</Column>
);
......
......@@ -3,6 +3,9 @@ import api from '../api';
export const TOS_FETCH_REQUEST = 'TOS_FETCH_REQUEST';
export const TOS_FETCH_SUCCESS = 'TOS_FETCH_SUCCESS';
export const TOS_FETCH_FAIL = 'TOS_FETCH_FAIL';
export const FLAVOUR_SWITCH_REQUEST = 'FLAVOUR_SWITCH_REQUEST';
export const FLAVOUR_SWITCH_SUCCESS = 'FLAVOUR_SWITCH_SUCCESS';
export const FLAVOUR_SWITCH_FAIL = 'FLAVOUR_SWITCH_FAIL';
export const PANEL_FETCH_REQUEST = 'PANEL_FETCH_REQUEST';
export const PANEL_FETCH_SUCCESS = 'PANEL_FETCH_SUCCESS';
export const PANEL_FETCH_FAIL = 'PANEL_FETCH_FAIL';
......@@ -10,6 +13,22 @@ export const PLEROMA_CONFIG_FETCH_REQUEST = 'PLEROMA_CONFIG_FETCH_REQUEST';
export const PLEROMA_CONFIG_FETCH_SUCCESS = 'PLEROMA_CONFIG_FETCH_SUCCESS';
export const PLEROMA_CONFIG_FETCH_FAIL = 'PLEROMA_CONFIG_FETCH_FAIL';
export function switchFlavour(flavour) {
return (dispatch, getState) => {
dispatch(switchFlavourRequest());
if(flavour === undefined) {
flavour = 'glitch';
}
api(getState).post('/api/v1/pleroma/flavour/'+flavour).then(response => {
dispatch(switchFlavourSuccess(response.data));
location.href = '/web/getting-started';
}).catch(error => {
dispatch(switchFlavourFail(error));
});
};
};
export function fetchTOS() {
return (dispatch, getState) => {
dispatch(fetchTOSRequest());
......@@ -66,6 +85,27 @@ export function fetchTOSFail(error) {
};
};
export function switchFlavourRequest() {
return {
type: FLAVOUR_SWITCH_REQUEST,
};
};
export function switchFlavourSuccess(tos) {
return {
type: FLAVOUR_SWITCH_SUCCESS,
tos,
};
};
export function switchFlavourFail(error) {
return {
type: FLAVOUR_SWITCH_FAIL,
error,
};
};
export function fetchPanelRequest() {
return {
type: PANEL_FETCH_REQUEST,
......
......@@ -9,7 +9,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { me, invitesEnabled, profile_directory } from '../../initial_state';
import { fetchFollowRequests } from '../../actions/accounts';
import { fetchPanel, fetchPleromaConfig } from 'mastodon/actions/pleroma';
import { fetchPanel, fetchPleromaConfig, switchFlavour } from 'mastodon/actions/pleroma';
import { List as ImmutableList } from 'immutable';
import { Link } from 'react-router-dom';
import NavigationBar from '../compose/components/navigation_bar';
......@@ -35,6 +35,7 @@ const messages = defineMessages({
security: { id: 'navigation_bar.security', defaultMessage: 'Security' },
menu: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
profile_directory: { id: 'getting_started.directory', defaultMessage: 'Profile directory' },
switch_to_glitch: { id: 'navigation_bar.switch_to_glitch', defaultMessage: 'Switch to Glitch Flavour' },
});
const mapStateToProps = state => ({
......@@ -48,6 +49,7 @@ const mapDispatchToProps = dispatch => ({
fetchFollowRequests: () => dispatch(fetchFollowRequests()),
fetchPanel: () => dispatch(fetchPanel()),
fetchPleromaConfig: () => dispatch(fetchPleromaConfig()),
switchFlavour: () => dispatch(switchFlavour()),
});
const badgeDisplay = (number, limit) => {
......@@ -72,12 +74,17 @@ class GettingStarted extends ImmutablePureComponent {
fetchFollowRequests: PropTypes.func.isRequired,
fetchPanel: PropTypes.func.isRequired,
fetchPleromaConfig: PropTypes.func.isRequired,
switchFlavour: PropTypes.func.isRequired,
unreadFollowRequests: PropTypes.number,
unreadNotifications: PropTypes.number,
customPanelEnabled: PropTypes.bool,
customPanel: PropTypes.string.isRequired,
};
switch_flavour_glitch = (e) => {
this.props.switchFlavour('glitch');
}
componentDidMount () {
const { myAccount, fetchFollowRequests, fetchPleromaConfig, fetchPanel } = this.props;
......@@ -129,7 +136,8 @@ class GettingStarted extends ImmutablePureComponent {
navItems.push(
<ColumnLink key={i++} icon='envelope' text={intl.formatMessage(messages.direct)} to='/timelines/direct' />,
<ColumnLink key={i++} icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />,
<ColumnLink key={i++} icon='list-ul' text={intl.formatMessage(messages.lists)} to='/lists' />
<ColumnLink key={i++} icon='list-ul' text={intl.formatMessage(messages.lists)} to='/lists' />,
<a key={i++} href='#' onClick={this.switch_flavour_glitch} className='column-link' tabIndex='0'><i className={`fa fa-fw fa-exchange column-link__icon`} />{intl.formatMessage(messages.switch_to_glitch)}</a>
);
height += 48*3;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment