Skip to content

Commit 4448b7a

Browse files
committed
Merge pull request #146 from vincent99/projects
Project updates
2 parents 264951f + cdad4e4 commit 4448b7a

File tree

15 files changed

+43
-57
lines changed

15 files changed

+43
-57
lines changed

app/activesetting/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var ActiveSetting = Cattle.TransitioningResource.extend({
66

77
ActiveSetting.reopenClass({
88
headers: {
9-
[C.HEADER.PROJECT]: C.HEADER.PROJECT_USER_SCOPE, // Requests for projects use the user's scope, not the project
9+
[C.HEADER.PROJECT]: undefined, // Requests for projects use the user's scope, not the project
1010
}
1111
});
1212

app/authenticated/route.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
1515

1616
// Load schemas
1717
var headers = {};
18-
headers[C.HEADER.PROJECT] = C.HEADER.PROJECT_USER_SCOPE;
18+
headers[C.HEADER.PROJECT] = undefined;
1919
return store.find('schema', null, {url: 'schemas', headers: headers}).then((schemas) => {
2020
if ( schemas && schemas.xhr )
2121
{
@@ -63,7 +63,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
6363
this.activeProjectFromId(session.get(C.SESSION.PROJECT)).then(select)
6464
.catch(() => {
6565
// Then the default project ID from the session
66-
this.activeProjectFromId(session.get(C.SESSION.PROJECT_DEFAULT)).then(select)
66+
this.activeProjectFromId(this.get('prefs').get(C.PREFS.PROJECT_DEFAULT)).then(select)
6767
.catch(() => {
6868
// Then the first active project
6969
var project = active.get('firstObject');
@@ -111,14 +111,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
111111
function fail() {
112112
// Then cry
113113
select(null);
114-
if ( self.get('app.authenticationEnabled') && !self.get('app.isAuthenticationAdmin') )
115-
{
116-
self.send('logout');
117-
}
118-
else
119-
{
120-
self.transitionTo('projects');
121-
}
114+
self.transitionTo('projects');
122115
}
123116
},
124117

app/githubconfig/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var GithubConfig = Cattle.TransitioningResource.extend({
88
// Projects don't get pushed by /subscribe WS, so refresh more often
99
GithubConfig.reopenClass({
1010
headers: {
11-
[C.HEADER.PROJECT]: C.HEADER.PROJECT_USER_SCOPE, // Requests for projects use the user's scope, not the project
11+
[C.HEADER.PROJECT]: undefined, // Requests for projects use the user's scope, not the project
1212
}
1313
});
1414

app/mixins/edit-project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default Ember.Mixin.create(Cattle.NewOrEditMixin, {
99
var member = Ember.Object.create({
1010
externalId: obj.get('id'),
1111
externalIdType: C.PROJECT.FROM_GITHUB[ obj.get('type') ],
12-
role: C.PROJECT.ROLE_MEMBER
12+
role: (this.get('members.length') === 0 ? C.PROJECT.ROLE_OWNER : C.PROJECT.ROLE_MEMBER)
1313
});
1414

1515
var existing = this.get('members')
@@ -65,7 +65,7 @@ export default Ember.Mixin.create(Cattle.NewOrEditMixin, {
6565
doneSaving: function() {
6666
var out = this._super();
6767
this.transitionToRoute('projects');
68-
this.send('refreshProjectDropdown');
68+
this.send('refreshProjects');
6969
return out;
7070
},
7171
});

app/project/controller.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ var ProjectController = Cattle.TransitioningResourceController.extend({
3434
},
3535

3636
setAsDefault: function() {
37-
var headers = {};
38-
headers[C.HEADER.PROJECT] = C.HEADER.PROJECT_USER_SCOPE;
39-
40-
return this.doAction('setasdefault', undefined, headers).then(() => {
41-
this.get('session').set(C.SESSION.PROJECT_DEFAULT, this.get('id'));
42-
});
37+
this.get('prefs').set(C.PREFS.PROJECT_DEFAULT, this.get('id'));
4338
},
4439

4540
switchTo: function() {
@@ -67,8 +62,8 @@ var ProjectController = Cattle.TransitioningResourceController.extend({
6762
}.property('active','isDefault'),
6863

6964
isDefault: function() {
70-
return this.get('session.' + C.SESSION.PROJECT_DEFAULT) === this.get('id');
71-
}.property('session.' + C.SESSION.PROJECT_DEFAULT, 'id'),
65+
return this.get('prefs.' + C.PREFS.PROJECT_DEFAULT) === this.get('id');
66+
}.property('prefs.' + C.PREFS.PROJECT_DEFAULT, 'id'),
7267

7368
active: function() {
7469
return this.get('session.' + C.SESSION.PROJECT) === this.get('id');
@@ -79,8 +74,8 @@ var ProjectController = Cattle.TransitioningResourceController.extend({
7974
}.property('state','actions.remove'),
8075

8176
canSetDefault: function() {
82-
return this.get('state') === 'active' && this.hasAction('setasdefault') && !this.get('isDefault');
83-
}.property('state','actions.setasdefault','isDefault'),
77+
return this.get('state') === 'active' && !this.get('isDefault');
78+
}.property('state','isDefault'),
8479

8580
availableActions: function() {
8681
var a = this.get('actions');
@@ -96,11 +91,7 @@ var ProjectController = Cattle.TransitioningResourceController.extend({
9691
];
9792

9893
choices.pushObject({label: 'Switch to this Project', icon: '', action: 'switchTo', enabled: this.get('state') === 'active' });
99-
100-
if ( this.get('app.authenticationEnabled') )
101-
{
102-
choices.pushObject({label: 'Set as my default Project', icon: '', action: 'setAsDefault', enabled: this.get('canSetDefault')});
103-
}
94+
choices.pushObject({label: 'Set as my default Project', icon: '', action: 'setAsDefault', enabled: this.get('canSetDefault')});
10495

10596
return choices;
10697
}.property('actions.{activate,deactivate,update,restore,purge}','canRemove','canSetDefault'),

app/project/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Project.reopenClass({
1515
pollTransitioningInterval: 5000,
1616

1717
headers: {
18-
[C.HEADER.PROJECT]: C.HEADER.PROJECT_USER_SCOPE, // Requests for projects use the user's scope, not the project
18+
[C.HEADER.PROJECT]: undefined, // Requests for projects use the user's scope, not the project
1919
}
2020
});
2121

app/projects/index/template.hbs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
<th width="120">State</th>
2525
<th>Name</th>
2626
<th>Description</th>
27-
{{#if app.authenticationEnabled}}
2827
<th width="80">Default</th>
29-
{{/if}}
3028
<th width="40">&nbsp;</th>
3129
</tr>
3230
</thead>
@@ -42,11 +40,9 @@
4240
<td>
4341
{{#if p.description}}{{p.description}}{{else}}<span class="text-italic">No description</span>{{/if}}
4442
</td>
45-
{{#if app.authenticationEnabled}}
4643
<td>
4744
{{#if p.isDefault}}<i class="ss-check"></i>{{/if}}
4845
</td>
49-
{{/if}}
5046
<td align="right">
5147
{{resource-actions-menu model=p choices=p.availableActions}}
5248
</td>

app/projects/new/route.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ export default Ember.Route.extend({
99
},
1010

1111
model: function(/*params, transition*/) {
12-
var me;
12+
var model = this.get('store').createRecord({
13+
type: 'project',
14+
name: '',
15+
description: '',
16+
});
17+
1318
if ( this.get('app.authenticationEnabled') )
1419
{
15-
me = Ember.Object.create({
20+
var me = Ember.Object.create({
1621
externalId: this.get('session').get(C.SESSION.USER_ID),
1722
externalIdType: C.PROJECT.TYPE_USER,
1823
role: C.PROJECT.ROLE_OWNER
1924
});
25+
model.set('members', [me]);
2026
}
2127
else
2228
{
23-
me = Ember.Object.create({
24-
externalId: this.get('session').get(C.SESSION.ACCOUNT_ID),
25-
externalIdType: C.PROJECT.TYPE_RANCHER,
26-
role: C.PROJECT.ROLE_OWNER
27-
});
29+
model.set('members',[]);
2830
}
2931

30-
var model = this.get('store').createRecord({
31-
type: 'project',
32-
externalIdType: 'project:github_user',
33-
externalId: this.get('session.user'),
34-
members: [me]
35-
});
36-
3732
return model;
3833
},
3934

app/projects/route.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import Ember from 'ember';
33

44
export default Ember.Route.extend(AuthenticatedRouteMixin, {
55
actions: {
6+
refreshProjects: function() {
7+
var store = this.get('store');
8+
store.resetType('project');
9+
return store.find('project', null, {filter: {all: 'true'}, forceReload: true}).then(() => {
10+
this.send('refreshProjectDropdown');
11+
});
12+
},
613
newProject: function() {
714
this.transitionTo('projects.new');
815
}

app/setting/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Setting = Cattle.TransitioningResource.extend({
66

77
Setting.reopenClass({
88
headers: {
9-
[C.HEADER.PROJECT]: C.HEADER.PROJECT_USER_SCOPE, // Requests for projects use the user's scope, not the project
9+
[C.HEADER.PROJECT]: undefined, // Requests for projects use the user's scope, not the project
1010
}
1111
});
1212

0 commit comments

Comments
 (0)