Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Не делать редирект на лендинг в случае локального деплоя #136

Merged
merged 1 commit into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import config from './config/environment';

const appConfig = config.APP;

export const IS_DEV = appConfig.environment === 'development';

export const IS_LITE_MODE = appConfig.isLiteMode || !appConfig.backend;

export const BACKEND_API = function() {
Expand Down
17 changes: 10 additions & 7 deletions app/routes/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ export default class extends Route {

afterModel(model) {
// todo: remove the stub
const company = this.get('store').createRecord('service-company', {
id: 100500,
name: 'Гараж 4x4',
phone: '8 (800) 555-35-35',
address: 'Ильменский пр., 9А, стр. 12, Москва',
});
model.user.get('companies').pushObject(company);
const check = this.get('store').peekRecord('service-company', 100500);
if (!check) {
const company = this.get('store').createRecord('service-company', {
id: 100500,
name: 'Гараж 4x4',
phone: '8 (800) 555-35-35',
address: 'Ильменский пр., 9А, стр. 12, Москва',
});
model.user.get('companies').pushObject(company);
}
}

@on('activate')
Expand Down
9 changes: 8 additions & 1 deletion app/routes/redirect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Route from '@ember/routing/route';
import {debug} from '@ember/debug';
import {IS_DEV} from '../constants';

const urls = {
'landing': '//meter4.me/about',
Expand All @@ -13,7 +15,12 @@ export default class extends Route {
const {to} = transition.to.queryParams;
const url = urls[to];
if (url) {
window.location = urls[to] || '/';
if (IS_DEV) {
debug(`Redirect to ${url} was blocked. Redirecting to account.index...`);
this.transitionTo('account.index');
} else {
window.location = urls[to] || '/';
}
} else {
this.transitionTo('index');
}
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = function(environment) {
},

'APP': {
environment,
isLiteMode: LITE_MODE,
isUsingProxy: USE_PROXY,
backend: {
Expand Down