diff --git a/src/app/components/ModalOrbis.jsx b/src/app/components/ModalOrbis.jsx
new file mode 100644
index 00000000..b7d72b94
--- /dev/null
+++ b/src/app/components/ModalOrbis.jsx
@@ -0,0 +1,56 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import TranslatedComponent from './TranslatedComponent';
+import { orbisUpload } from '../utils/ShortenUrl';
+
+/**
+ * Permalink modal
+ */
+export default class ModalOrbis extends TranslatedComponent {
+
+ static propTypes = {
+ ship: PropTypes.any.isRequired
+ };
+
+ /**
+ * Constructor
+ * @param {Object} props React Component properties
+ */
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ orbisUrl: 'Shortening...'
+ };
+ }
+
+ /**
+ * Shorten URL on mount
+ */
+ componentWillMount() {
+ orbisUpload(this.props.ship,
+ (orbisUrl) => this.setState({ orbisUrl }),
+ (error) => this.setState({ orbisUrl: 'Error - ' + error })
+ );
+ }
+
+ /**
+ * Render the modal
+ * @return {React.Component} Modal Content
+ */
+ render() {
+ let translate = this.context.language.translate;
+
+ return
e.stopPropagation() }>
+
{translate('permalink')}
+
+ {translate('URL')}
+ e.target.select() }/>
+
+ {translate('shortened')}
+ e.target.select() }/>
+
+
+ ;
+ }
+}
diff --git a/src/app/utils/CompanionApiUtils.js b/src/app/utils/CompanionApiUtils.js
index 325f32b9..23fd557f 100644
--- a/src/app/utils/CompanionApiUtils.js
+++ b/src/app/utils/CompanionApiUtils.js
@@ -6,7 +6,7 @@ import { getBlueprint } from '../utils/BlueprintFunctions';
import * as ModuleUtils from '../shipyard/ModuleUtils';
// mapping from fd's ship model names to coriolis'
-const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
+export const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
'Adder': 'adder',
'Anaconda': 'anaconda',
'Asp': 'asp',
diff --git a/src/app/utils/ShortenUrl.js b/src/app/utils/ShortenUrl.js
index a8c77b97..71f3dfc4 100644
--- a/src/app/utils/ShortenUrl.js
+++ b/src/app/utils/ShortenUrl.js
@@ -6,9 +6,9 @@ import request from 'superagent';
* @param {string} url The URL to shorten
* @param {function} success Success callback
* @param {function} error Failure/Error callback
- */
+ */
export default function shorternUrl(url, success, error) {
- shortenUrlOrbis(url, success, error);
+ orbisUpload(url, success, error);
}
const SHORTEN_API_GOOGLE = 'https://www.googleapis.com/urlshortener/v1/url?key=';
@@ -72,7 +72,7 @@ const SHORTEN_API_ORBIS = 'https://s.orbis.zone/a';
* @param {function} success Success callback
* @param {function} error Failure/Error callback
*/
-function shortenUrlOrbis(url, success, error) {
+function orbisUpload(url, success, error) {
if (window.navigator.onLine) {
try {
request.post(SHORTEN_API_ORBIS)
@@ -93,3 +93,31 @@ function shortenUrlOrbis(url, success, error) {
error('Not Online');
}
}
+
+const API_ORBIS = 'http://localhost:3000/builds/add';
+/**
+ * Upload to Orbis
+ * @param {object} ship The URL to shorten
+ * @param {function} success Success callback
+ * @param {function} error Failure/Error callback
+ */
+export function orbisUpload(ship, success, error) {
+ if (window.navigator.onLine) {
+ try {
+ request.post(API_ORBIS)
+ .send(ship)
+ .end(function(err, response) {
+ if (err) {
+ error('Bad Request');
+ } else {
+ success(response.body.link);
+ }
+ });
+ } catch (e) {
+ console.log(e);
+ error(e.message ? e.message : e);
+ }
+ } else {
+ error('Not Online');
+ }
+}