From 888f807a7b418981566f79f8fc3d0eeb143b0d9a Mon Sep 17 00:00:00 2001 From: Felix Linker Date: Sun, 31 Jan 2021 16:57:55 +0100 Subject: [PATCH] Remove orbis related code --- src/app/components/Header.jsx | 39 ------- src/app/components/ModalBatchOrbis.jsx | 93 ---------------- src/app/components/ModalOrbis.jsx | 141 ------------------------- src/app/components/SvgIcons.jsx | 3 +- src/app/pages/OutfittingPage.jsx | 25 ----- src/app/stores/Persist.js | 24 ----- 6 files changed, 2 insertions(+), 323 deletions(-) delete mode 100644 src/app/components/ModalBatchOrbis.jsx delete mode 100644 src/app/components/ModalOrbis.jsx diff --git a/src/app/components/Header.jsx b/src/app/components/Header.jsx index 6c56e504..18cca21a 100644 --- a/src/app/components/Header.jsx +++ b/src/app/components/Header.jsx @@ -10,7 +10,6 @@ import { Ships } from 'coriolis-data/dist'; import Persist from '../stores/Persist'; import { toDetailedExport } from '../shipyard/Serializer'; import Ship from '../shipyard/Ship'; -import ModalBatchOrbis from './ModalBatchOrbis'; import ModalDeleteAll from './ModalDeleteAll'; import ModalExport from './ModalExport'; import ModalHelp from './ModalHelp'; @@ -241,43 +240,6 @@ export default class Header extends TranslatedComponent { />); }; - /** - * Uploads all ship-builds to orbis - * @param {e} e Event - */ - _uploadAllBuildsToOrbis(e) { - e.preventDefault(); - const data = Persist.getBuilds(); - let postObject = []; - for (const ship in data) { - for (const code in data[ship]) { - const shipModel = ship; - if (!shipModel) { - throw 'No such ship found: "' + ship + '"'; - } - const shipTemplate = Ships[shipModel]; - const shipPostObject = {}; - let shipInstance = new Ship(shipModel, shipTemplate.properties, shipTemplate.slots); - shipInstance.buildWith(null); - shipInstance.buildFrom(data[ship][code]); - shipPostObject.coriolisId = shipInstance.id; - shipPostObject.coriolisShip = shipInstance; - - shipPostObject.coriolisShip.url = window.location.origin + outfitURL(shipModel, data[ship][code], code); - shipPostObject.title = code || shipInstance.id; - shipPostObject.description = code || shipInstance.id; - shipPostObject.ShipName = shipInstance.id; - shipPostObject.Ship = shipInstance.id; - postObject.push(shipPostObject); - } - } - console.log(postObject); - - this.context.showModal(); - } - /** * Show export modal with detailed export * @param {SyntheticEvent} e Event @@ -499,7 +461,6 @@ export default class Header extends TranslatedComponent { {translate('builds')} & {translate('comparisons')}
  • {translate('backup')}
  • {translate('detailed export')}
  • -
  • {translate('upload all builds to orbis')}
  • {translate('import')}
  • {translate('delete all')}
  • diff --git a/src/app/components/ModalBatchOrbis.jsx b/src/app/components/ModalBatchOrbis.jsx deleted file mode 100644 index 3e1c9ad5..00000000 --- a/src/app/components/ModalBatchOrbis.jsx +++ /dev/null @@ -1,93 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import request from 'superagent'; -import TranslatedComponent from './TranslatedComponent'; -import { orbisUpload } from '../utils/ShortenUrl'; -import Persist from '../stores/Persist'; - -/** - * Permalink modal - */ -export default class ModalBatchOrbis extends TranslatedComponent { - - static propTypes = { - ships: PropTypes.any.isRequired - }; - - /** - * Constructor - * @param {Object} props React Component properties - */ - constructor(props) { - super(props); - - this.state = { - orbisCreds: Persist.getOrbisCreds(), - resp: '' - }; - } - - /** - * Send ship to Orbis.zone - * @param {SyntheticEvent} e React Event - * @return {Promise} Promise sending post request to orbis - */ - sendToOrbis(e) { - let agent; - try { - agent = request.agent(); // apparently this crashes somehow - } catch (e) { - console.error(e); - } - if (!agent) { - agent = request; - } - const API_ORBIS = 'https://orbis.zone/api/builds/add/batch'; - return new Promise((resolve, reject) => { - try { - agent - .post(API_ORBIS) - .withCredentials() - .redirects(0) - .set('Content-Type', 'application/json') - .send(this.props.ships) - .end((err, response) => { - console.log(response); - if (err) { - console.error(err); - this.setState({ resp: response.text }); - reject('Bad Request'); - } else { - this.setState({ resp: 'All builds uploaded. Check https://orbis.zone' }); - resolve('All builds uploaded. Check https://orbis.zone'); - } - }); - } catch (e) { - console.log(e); - reject(e.message ? e.message : e); - } - }); - } - - /** - * Render the modal - * @return {React.Component} Modal Content - */ - render() { - let translate = this.context.language.translate; - this.sendToOrbis = this.sendToOrbis.bind(this); - - return
    e.stopPropagation() }> -

    {translate('permalink')}

    -
    - Log in / signup to Orbis -

    -

    {translate('success')}

    - e.target.select() }/> -

    -

    Orbis.zone is currently in a trial period, and may be wiped at any time as development progresses. Some elements are also still placeholders.

    - - -
    ; - } -} diff --git a/src/app/components/ModalOrbis.jsx b/src/app/components/ModalOrbis.jsx deleted file mode 100644 index 9580fdfb..00000000 --- a/src/app/components/ModalOrbis.jsx +++ /dev/null @@ -1,141 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import TranslatedComponent from './TranslatedComponent'; -import { orbisUpload } from '../utils/ShortenUrl'; -import Persist from '../stores/Persist'; - -/** - * 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 = { - orbisCreds: Persist.getOrbisCreds(), - orbisUrl: '...', - ship: this.props.ship, - authenticatedStatus: 'Checking...' - }; - this.orbisCategory = this.orbisCategory.bind(this); - } - - /** - * Send ship to Orbis.zone - * @param {SyntheticEvent} e React Event - */ - sendToOrbis(e) { - const target = e.target; - target.disabled = true; - this.setState({ orbisUrl: 'Sending...' }, () => { - orbisUpload(this.props.ship, this.state.orbisCreds) - .then(orbisUrl => { - target.disabled = false; - this.setState({ orbisUrl }); - }) - .catch(err => { - target.disabled = false; - this.setState({ orbisUrl: 'Error - ' + err }); - }); - }); - } - - /** - * Get Orbis.zone auth status - * @returns {Object} auth status - */ - getOrbisAuthStatus() { - return fetch('https://orbis.zone/api/checkauth', { - credentials: 'include', - mode: 'cors' - }) - .then(data => data.json()) - .then(res => { - this.setState({ authenticatedStatus: res.status || res.error }); - }) - .catch(err => { - console.error(err); - this.setState({ authenticatedStatus: err.message }); - }); - } - - /** - * Handler for changing cmdr name - * @param {SyntheticEvent} e React Event - */ - orbisPasswordHandler(e) { - let password = e.target.value; - this.setState({ orbisCreds: { email: this.state.orbisCreds.email, password } }, () => { - Persist.setOrbisCreds(this.state.orbisCreds); - }); - } - - /** - * Handler for changing cmdr name - * @param {SyntheticEvent} e React Event - */ - orbisUsername(e) { - let orbisUsername = e.target.value; - this.setState({ orbisCreds: { email: orbisUsername, password: this.state.orbisCreds.password } }, () => { - Persist.setOrbisCreds(this.state.orbisCreds); - }); - } - - /** - * Handler for changing category - * @param {SyntheticEvent} e React Event - */ - orbisCategory(e) { - let ship = this.state.ship; - let cat = e.target.value; - ship.category = cat; - this.setState({ship}); - } - - /** - * Render the modal - * @return {React.Component} Modal Content - */ - render() { - let translate = this.context.language.translate; - this.orbisPasswordHandler = this.orbisPasswordHandler.bind(this); - this.orbisUsername = this.orbisUsername.bind(this); - this.sendToOrbis = this.sendToOrbis.bind(this); - this.getOrbisAuthStatus(); - return
    e.stopPropagation() }> -

    {translate('upload to orbis')}

    -
    - - e.target.select() }/> -

    - Log in / signup to Orbis -

    -

    Category

    - -

    -

    {translate('Orbis link')}

    - e.target.select() }/> -

    -

    Orbis.zone is currently in a trial period, and may be wiped at any time as development progresses. Some elements are also still placeholders.

    - - -
    ; - } -} diff --git a/src/app/components/SvgIcons.jsx b/src/app/components/SvgIcons.jsx index c226f892..ce4627eb 100644 --- a/src/app/components/SvgIcons.jsx +++ b/src/app/components/SvgIcons.jsx @@ -247,7 +247,8 @@ export class OrbisIcon extends SvgIcon { - ); + + ); } } diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index 3b709258..adc89f58 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -19,7 +19,6 @@ import { LinkIcon, ShoppingIcon, MatIcon, - OrbisIcon } from '../components/SvgIcons'; import LZString from 'lz-string'; import ShipSummaryTable from '../components/ShipSummaryTable'; @@ -37,7 +36,6 @@ import OutfittingSubpages from '../components/OutfittingSubpages'; import ModalExport from '../components/ModalExport'; import ModalPermalink from '../components/ModalPermalink'; import ModalShoppingList from '../components/ModalShoppingList'; -import ModalOrbis from '../components/ModalOrbis'; /** * Document Title Generator @@ -680,22 +678,6 @@ export default class OutfittingPage extends Page { this.context.showModal(); } - /** - * Generate Orbis link - */ - _genOrbis() { - const data = {}; - const ship = this.state.ship; - data.title = this.state.buildName || ship.id; - data.description = this.state.buildName || ship.id; - data.body = ship; - data.url = `https://coriolis.io${outfitURL(ship.id, ship.toString(), data.title)}`; - ship.type = ship.id; - - console.log(data); - this.context.showModal(); - } - /** * Open up a window for EDDB with a shopping list of our components */ @@ -945,13 +927,6 @@ export default class OutfittingPage extends Page { > -