Skip to content

Commit 6b0cb98

Browse files
author
jleveugle
committed
fix: redirect only /default/kubernetes
1 parent b2b4bad commit 6b0cb98

File tree

3 files changed

+43
-63
lines changed

3 files changed

+43
-63
lines changed
Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import feedback from './feedback-icon.svg';
2-
import { DEFAULT_PROJECT_KEY } from './index.constants';
32

43
import options from './navbar.config';
54

@@ -51,63 +50,4 @@ export default class PublicCloudController {
5150
});
5251
});
5352
}
54-
55-
initRedirect() {
56-
return this.publicCloud
57-
.getProjects([{
58-
field: 'status',
59-
comparator: 'in',
60-
reference: ['creating', 'ok'],
61-
}])
62-
.then(((projects) => {
63-
// if in project creation and redirected from hipay or paypal
64-
// we don't necessary have any project so do not redirect to onboarding state
65-
// $transition is not injected and stateParams not setted
66-
// so use hash and parse it to detect if hipay/paypal param is present
67-
const hashes = this.$window.location.hash.slice(
68-
this.$window.location.hash.indexOf('?') + 1,
69-
).split('&');
70-
// as paypal redirect to search query
71-
// search also in location search
72-
const searchHashes = this.$window.location.search.slice(
73-
this.$window.location.search.indexOf('?') + 1,
74-
).split('&');
75-
const params = {};
76-
hashes.map((hash) => {
77-
const [key, val] = hash.split('=');
78-
params[key] = decodeURIComponent(val);
79-
return true;
80-
});
81-
searchHashes.map((hash) => {
82-
const [key, val] = hash.split('=');
83-
params[key] = decodeURIComponent(val);
84-
return true;
85-
});
86-
87-
if (params.hiPayStatus || params.paypalAgreementStatus) {
88-
return true;
89-
}
90-
91-
if (projects.length > 0) {
92-
return this.ovhUserPref
93-
.getValue(DEFAULT_PROJECT_KEY)
94-
.then(({ projectId }) => this.$state.go('pci.projects.project', {
95-
projectId,
96-
}))
97-
.catch((err) => {
98-
if (err.status === 404) {
99-
// No project is defined as favorite
100-
// Go on the first one :)
101-
return this.$state.go('pci.projects.project', {
102-
projectId: projects[0].project_id,
103-
});
104-
}
105-
// Go to error page
106-
return this.$state.go('pci.error');
107-
});
108-
}
109-
110-
return this.$state.go('pci.projects.onboarding');
111-
}));
112-
}
11353
}

packages/manager/apps/public-cloud/src/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<div class="d-flex w-100 h-100 position-relative">
1818
<div class="w-100 h-100 position-absolute" style="top: 0; left: 0;">
1919
<div class="h-100 w-100" data-ui-view>
20-
<div class="h-100 d-flex" data-ng-init="$ctrl.initRedirect()">
21-
<oui-spinner size="l" class="m-auto"></oui-spinner>
22-
</div>
2320
</div>
2421
</div>
2522
</div>

packages/manager/apps/public-cloud/src/index.routes.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,48 @@ export default /* @ngInject */ ($stateProvider, $urlRouterProvider) => {
4444
},
4545
});
4646

47+
$stateProvider
48+
.state('redirect-kube', {
49+
url: '/pci/projects/default/kubernetes',
50+
redirectTo: (trans) => {
51+
const ovhUserPref = trans.injector().get('ovhUserPref');
52+
const publicCloud = trans.injector().get('publicCloud');
53+
54+
return publicCloud
55+
.getProjects([{
56+
field: 'status',
57+
comparator: 'in',
58+
reference: ['creating', 'ok'],
59+
}])
60+
.then(((projects) => {
61+
if (projects.length > 0) {
62+
return ovhUserPref
63+
.getValue(DEFAULT_PROJECT_KEY)
64+
.then(({ projectId }) => ({
65+
state: 'pci.projects.project',
66+
params: {
67+
projectId,
68+
},
69+
}))
70+
.catch(({ status }) => {
71+
if (status === 404) {
72+
// No project is defined as favorite
73+
// Go on the first one :)
74+
return {
75+
state: 'pci.projects.project',
76+
params: {
77+
projectId: projects[0].project_id,
78+
},
79+
};
80+
}
81+
// [TODO] Go to error page
82+
return null;
83+
});
84+
}
85+
return { state: 'pci.projects.onboarding' };
86+
}));
87+
},
88+
});
89+
4790
$urlRouterProvider.otherwise('/');
4891
};

0 commit comments

Comments
 (0)