Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for machine traits #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lib/machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ function getProject (projectId, create) {
update: '',
logs: ''
},
traits: ['c9sdk'],
data: {}
};
projects[projectId] = project;
Expand Down
12 changes: 12 additions & 0 deletions lib/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ function getOrCreateUser (email) {
if (!machine.project) {
machine.project = projectId;
}

// Temporary migration code: Previous machines didn't have traits.
if (!machine.traits) {
const updated = new Date(machine.data.updated);
const c9sdkStart = new Date('2017-08-02');

machine.traits = [];

if (updated > c9sdkStart) {
machine.traits.push('c9sdk');
}
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions templates/contributions.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ <h4>{{= name in html}}</h4>
</a>
<ul class="dropdown-menu">{{
const updated = new Date(machine.data.updated);
const c9sdkStart = new Date('2017-08-02');
const c9ioEnd = new Date('2017-09-02');
if (updated > c9sdkStart && updated < c9ioEnd) { }}
if (machine.traits.includes('c9sdk') && updated < c9ioEnd) { }}
<li>
<a href="https://c9.io/open/ssh?name={{= projectId in id}}-{{= id in id}}&description={{= project.name in uri}}%20on%20janitor.technology&host={{= machine.docker.host in uri}}&port={{= machine.docker.ports['22'].port in integer}}&user=user&workspaceDir={{= project.docker.path in uri}}&nodePath=%2Fhome%2Fuser%2F.c9%2Fnode%2Fbin%2Fnode" target="_blank">Edit via c9.io</a>
</li>{{ } }}
Expand All @@ -41,8 +40,8 @@ <h4>{{= name in html}}</h4>
</ul>
<a class="btn btn-default" href="https://{{= machine.docker.host in uri}}/{{= machine.docker.container.slice(0,16) in uri}}/8088/vnc.html" target="_blank">VNC</a>
<a class="btn btn-primary"{{
if (updated < c9sdkStart) { }} href="https://c9.io/open/ssh?name={{= projectId in id}}-{{= id in id}}&description={{= project.name in uri}}%20on%20janitor.technology&host={{= machine.docker.host in uri}}&port={{= machine.docker.ports['22'].port in integer}}&user=user&workspaceDir={{= project.docker.path in uri}}&nodePath=%2Fhome%2Fuser%2F.c9%2Fnode%2Fbin%2Fnode" {{ }
else { }} href="https://{{= machine.docker.host in uri}}/{{= machine.docker.container.slice(0,16) in uri}}/8089/ide.html" {{ }
if (machine.traits.includes('c9sdk')) { }} href="https://{{= machine.docker.host in uri}}/{{= machine.docker.container.slice(0,16) in uri}}/8089/ide.html" {{ }
else { }} href="https://c9.io/open/ssh?name={{= projectId in id}}-{{= id in id}}&description={{= project.name in uri}}%20on%20janitor.technology&host={{= machine.docker.host in uri}}&port={{= machine.docker.ports['22'].port in integer}}&user=user&workspaceDir={{= project.docker.path in uri}}&nodePath=%2Fhome%2Fuser%2F.c9%2Fnode%2Fbin%2Fnode" {{ }
}}target="_blank"><span class="hidden-xs">Edit in </span>Cloud9</a>
</div>
</div>
Expand Down