Skip to content

Commit

Permalink
Merge pull request #332 from apinf/feature/remove-sky
Browse files Browse the repository at this point in the history
Remove upload system modularity
  • Loading branch information
JeHugawa committed Nov 27, 2017
2 parents beff13a + f3e4392 commit 649ed9a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 64 deletions.
7 changes: 2 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {EventAggregator} from 'aurelia-event-aggregator';
import {parseJSON} from './resources/jsonparser';
import {Field} from './resources/form/abstract/field';
import {schema, fieldsToShow} from './schemas/index';
import {sky} from './sky';
import {Validation} from './validation';
import * as space from './space';
import YAML from 'yamljs';
Expand Down Expand Up @@ -47,7 +46,6 @@ export class App {
@bindable
language = window.localStorage.language || 'en';
enableBranding = true;
sky = [];
spaceLoginApinf = false;
ieWarningDismissed = window.localStorage.ieWarningDismissed === 'true';

Expand All @@ -65,7 +63,6 @@ export class App {
Field.internationalizer = i18n;
Field.eventAggregator = ea;
Field.validationFunctions = new Validation(i18n);
this.sky = sky;
// Allow access from browser console
window.$oai = this;

Expand Down Expand Up @@ -367,8 +364,8 @@ export class App {
}
}

upload(theCloud) {
theCloud.upload.call(theCloud, this.getFormData(), this);
uploadSpace() {
space.upload.call(space, this.getFormData(), this);
}

delete(force = false, notify = false) {
Expand Down
38 changes: 20 additions & 18 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,26 @@
"output-editor": {
"save": "Save changes"
},
"sky": {
"space": {
"upload-complete": {
"title": "Upload complete",
"clickhere": "Click here to open the uploaded document.",
"uploaded-has-been": "{{title}} v{{version}} has been ",
"updated": "$t(sky.space.upload-complete.uploaded-has-been) updated in OpenAPI space.\n\n$t(sky.space.upload-complete.clickhere)",
"created": "$t(sky.space.upload-complete.uploaded-has-been) added to OpenAPI space.\n\n$t(sky.space.upload-complete.clickhere)",
"unknown": "$t(sky.space.upload-complete.uploaded-has-been) uploaded to OpenAPI space.\n\n$t(sky.space.upload-complete.clickhere)"
},
"upload-failed": {
"title": "Upload failed",
"invalid-document": "Invalid Swagger document",
"access-denied": "Access denied",
"version-published": "Can't edit published API",
"unknown": "Unknown error: HTTP {{status}}",
"missing-title": "The API must have a title in order to upload to OpenAPI space."
}
"space": {
"title": {
"upload": "Upload",
"publish": "Publish (NYI)"
},
"upload-complete": {
"title": "Upload complete",
"clickhere": "Click here to open the uploaded document.",
"uploaded-has-been": "{{title}} v{{version}} has been ",
"updated": "$t(space.upload-complete.uploaded-has-been) updated in OpenAPI space.\n\n$t(space.upload-complete.clickhere)",
"created": "$t(space.upload-complete.uploaded-has-been) added to OpenAPI space.\n\n$t(space.upload-complete.clickhere)",
"unknown": "$t(space.upload-complete.uploaded-has-been) uploaded to OpenAPI space.\n\n$t(space.upload-complete.clickhere)"
},
"upload-failed": {
"title": "Upload failed",
"invalid-document": "Invalid Swagger document",
"access-denied": "Access denied",
"version-published": "Can't edit published API",
"unknown": "Unknown error: HTTP {{status}}",
"missing-title": "The API must have a title in order to upload to OpenAPI space."
}
},
"notify": {
Expand Down
38 changes: 20 additions & 18 deletions src/lang/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,26 @@
"output-editor": {
"save": "Tallenna muutokset"
},
"sky": {
"space": {
"upload-complete": {
"title": "Tiedosto lähetetty",
"clickhere": "Paina tästä avataksesi lähetetyn tiedoston.",
"uploaded-has-been": "{{title}} v{{version}} on ",
"updated": "$t(sky.space.upload-complete.uploaded-has-been) päivitetty OpenAPI spaceen.\n\n$t(sky.space.upload-complete.clickhere)",
"created": "$t(sky.space.upload-complete.uploaded-has-been) lisätty OpenAPI spaceen.\n\n$t(sky.space.upload-complete.clickhere)",
"unknown": "$t(sky.space.upload-complete.uploaded-has-been) lähetetty OpenAPI spaceen.\n\n$t(sky.space.upload-complete.clickhere)"
},
"upload-failed": {
"title": "Lähetys epäonnistui",
"invalid-document": "Epäkelpo Swagger-dokumentti",
"access-denied": "Pääsy estetty",
"version-published": "Julkaistua rajapintaa ei voi muokata",
"unknown": "Tuntematon virhe: HTTP {{status}}",
"missing-title": "Rajapinnalla on oltava otsikko, jotta sen voi lähettää OpenAPI spaceen."
}
"space": {
"title": {
"upload": "Lähetä",
"publish": "Julkaise (Ei valmis)"
},
"upload-complete": {
"title": "Tiedosto lähetetty",
"clickhere": "Paina tästä avataksesi lähetetyn tiedoston.",
"uploaded-has-been": "{{title}} v{{version}} on ",
"updated": "$t(space.upload-complete.uploaded-has-been) päivitetty OpenAPI spaceen.\n\n$t(space.upload-complete.clickhere)",
"created": "$t(space.upload-complete.uploaded-has-been) lisätty OpenAPI spaceen.\n\n$t(space.upload-complete.clickhere)",
"unknown": "$t(space.upload-complete.uploaded-has-been) lähetetty OpenAPI spaceen.\n\n$t(space.upload-complete.clickhere)"
},
"upload-failed": {
"title": "Lähetys epäonnistui",
"invalid-document": "Epäkelpo Swagger-dokumentti",
"access-denied": "Pääsy estetty",
"version-published": "Julkaistua rajapintaa ei voi muokata",
"unknown": "Tuntematon virhe: HTTP {{status}}",
"missing-title": "Rajapinnalla on oltava otsikko, jotta sen voi lähettää OpenAPI spaceen."
}
},
"notify": {
Expand Down
7 changes: 5 additions & 2 deletions src/sections/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@
<img src="res/upload.svg" alt="Upload"/>
</button>
<div class="content">
<a repeat.for="cloud of sky" href="javascript:void(0)" click.delegate="upload(cloud)">
${cloud.name}
<a href="javascript:void(0)" click.delegate="spaceUpload()" t="space.action.upload">
Upload
</a>
<a href="javascript:void(0)" click.delegate="alert('Not yet implemented')" t="space.action.publish">
Publish (NYI)
</a>
</div>
</div>
Expand Down
10 changes: 0 additions & 10 deletions src/sky.js

This file was deleted.

22 changes: 11 additions & 11 deletions src/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function checkAuth(designer, callback) {

function titleExists(apiSpec, designer) {
if (!apiSpec || !apiSpec.info || !apiSpec.info.title) {
const title = designer.i18n.tr('sky.space.upload-failed.title');
const body = designer.i18n.tr('sky.space.upload-failed.missing-title');
const title = designer.i18n.tr('space.upload-failed.title');
const body = designer.i18n.tr('space.upload-failed.missing-title');
designer.notify(title, body, 'error');
return false;
}
Expand All @@ -106,35 +106,35 @@ export function upload(apiSpec, designer) {
contentType: 'application/json',
data: JSON.stringify(apiSpec)
}).then((data, _, {status}) => {
const title = designer.i18n.tr('sky.space.upload-complete.title');
const title = designer.i18n.tr('space.upload-complete.title');
let body;
switch (status) {
case 200:
body = designer.i18n.tr('sky.space.upload-complete.updated', {title: apiTitle, version});
body = designer.i18n.tr('space.upload-complete.updated', {title: apiTitle, version});
break;
case 201:
body = designer.i18n.tr('sky.space.upload-complete.created', {title: apiTitle, version});
body = designer.i18n.tr('space.upload-complete.created', {title: apiTitle, version});
break;
default:
body = designer.i18n.tr('sky.space.upload-complete.unknown', {title: apiTitle, version});
body = designer.i18n.tr('space.upload-complete.unknown', {title: apiTitle, version});
break;
}
designer.notify(title, body, 'success', data.url);
}).fail(({status}) => {
const title = designer.i18n.tr('sky.space.upload-failed.title');
const title = designer.i18n.tr('space.upload-failed.title');
let body;
switch (status) {
case 400:
body = designer.i18n.tr('sky.space.upload-failed.invalid-document');
body = designer.i18n.tr('space.upload-failed.invalid-document');
break;
case 403:
body = designer.i18n.tr('sky.space.upload-failed.access-denied');
body = designer.i18n.tr('space.upload-failed.access-denied');
break;
case 409:
body = designer.i18n.tr('sky.space.upload-failed.version-published');
body = designer.i18n.tr('space.upload-failed.version-published');
break;
default:
body = designer.i18n.tr('sky.space.upload-failed.unknown', {status});
body = designer.i18n.tr('space.upload-failed.unknown', {status});
}
designer.notify(title, body, 'error');
});
Expand Down

0 comments on commit 649ed9a

Please sign in to comment.