Skip to content

Commit

Permalink
chore(POC Shim): Remove unneeded iconfont shim for the webId POC
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Apr 22, 2019
1 parent 3ce23cd commit 42947f3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 1,679 deletions.
613 changes: 0 additions & 613 deletions app/extensions/safe/iconfont/iconfont.css

This file was deleted.

Binary file removed app/extensions/safe/iconfont/iconfont.eot
Binary file not shown.
927 changes: 0 additions & 927 deletions app/extensions/safe/iconfont/iconfont.svg

This file was deleted.

90 changes: 0 additions & 90 deletions app/extensions/safe/iconfont/iconfont.ts

This file was deleted.

Binary file removed app/extensions/safe/iconfont/iconfont.ttf
Binary file not shown.
Binary file removed app/extensions/safe/iconfont/iconfont.woff
Binary file not shown.
28 changes: 14 additions & 14 deletions app/extensions/safe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import { handleSafeBrowserStoreChanges } from './safeBrowserApplication';
import blockNonSAFERequests from './blockNonSafeReqs';
import registerSafeAuthProtocol from './protocols/safe-auth';
import registerSafeProtocol from './protocols/safe';
import setupRoutes from './server-routes';
import { setupRoutes } from './server-routes';
import * as ffiLoader from './auth-api/ffiLoader';

const onWebviewPreload = store => webviewPreload( store );
const onWebviewPreload = ( store ) => webviewPreload( store );

const preAppLoad = () => {
// app.setPath( 'userData', path.resolve( app.getPath( 'temp' ), 'safe-browser' ) );
Expand All @@ -61,7 +61,7 @@ const addExtensionMenuItems = ( store, menusArray ) => {

const newMenuArray = [];

menusArray.forEach( menu => {
menusArray.forEach( ( menu ) => {
const { label } = menu;
let newMenu = menu;

Expand Down Expand Up @@ -96,7 +96,7 @@ const actionsForBrowser = {
...SafeBrowserActions
};

const onInitBgProcess = async store => {
const onInitBgProcess = async ( store ) => {
logger.info( 'Registering SAFE Network Protocols' );
try {
setSafeBgProcessStore( store );
Expand All @@ -112,15 +112,15 @@ const onInitBgProcess = async store => {
// load the auth/safe libs
const theLibs = await ffiLoader.loadLibrary( startedRunningMock );

let prevAuthLibStatus;
let previousAuthLibraryStatus;

store.subscribe( () => {
const authLibStatus = getLibStatus();
const authLibraryStatus = getLibStatus();

if ( authLibStatus && authLibStatus !== prevAuthLibStatus ) {
logger.info( 'Authenticator lib status: ', authLibStatus );
prevAuthLibStatus = authLibStatus;
store.dispatch( setAuthLibStatus( authLibStatus ) );
if ( authLibraryStatus && authLibraryStatus !== previousAuthLibraryStatus ) {
logger.info( 'Authenticator lib status: ', authLibraryStatus );
previousAuthLibraryStatus = authLibraryStatus;
store.dispatch( setAuthLibStatus( authLibraryStatus ) );

initSafeBrowserApp( store );
}
Expand All @@ -145,7 +145,7 @@ const onInitBgProcess = async store => {
* on open of peruse application
* @param {Object} store redux store
*/
const onOpen = store =>
const onOpen = ( store ) =>
new Promise( ( resolve, reject ) => {
logger.info( 'OnOpen: Setting mock in store. ', startedRunningMock );
store.dispatch( setIsMock( startedRunningMock ) );
Expand All @@ -157,7 +157,7 @@ const onOpen = store =>
* on open of peruse application
* @param {Object} store redux store
*/
const onAppReady = store => {
const onAppReady = ( store ) => {
logger.info( 'OnAppReady: Setting mock in store. ', startedRunningMock );
store.dispatch( setIsMock( startedRunningMock ) );
};
Expand All @@ -166,7 +166,7 @@ const onAppReady = store => {
* Add middleware to Peruse redux store
* @param {Object} store redux store
*/
const middleware = store => next => action => {
const middleware = ( store ) => ( next ) => ( action ) => {
if ( isRunningSpectronTestProcess ) {
logger.info( 'ACTION:', action );
}
Expand All @@ -180,7 +180,7 @@ const parseSafeUri = function( uri ) {
};

const waitForBasicConnection = ( theStore, timeout = 15000 ) =>
new Promise( resolve => {
new Promise( ( resolve ) => {
let timeLeft = timeout;
const check = () => {
timeLeft -= 500;
Expand Down
39 changes: 4 additions & 35 deletions app/extensions/safe/server-routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
import { logger } from '$Logger';
import {
isRunningPackaged,
isRunningSpectronTestProcess,
isRunningSpectronTestProcessingPackagedApp
} from '$Constants';
import path from 'path';
import url from 'url';

import safeRoute from './safe';
import authRoute from './auth';

const setupRoutes = ( server, store ) => {
export const setupRoutes = ( server, store ): void => {
const routes = [safeRoute( store ), authRoute];

// TODO: Remove serving onf antd files when we can package
// webId manager properly.
server.get( /dummy/, ( request, res ) => {
const { link } = request.params;
const linkUrl = url.parse( link );

let safeFolder = isRunningPackaged
? '../extensions/safe/'
: './extensions/safe/';
safeFolder =
isRunningSpectronTestProcess &&
!isRunningSpectronTestProcessingPackagedApp
? 'extensions/safe/'
: safeFolder;

const antdIcons = path.resolve( __dirname, safeFolder, 'iconfont/' );
const finalPath = path.resolve( antdIcons, link );
res
.sendFile( finalPath, { confine: false } )
.header( 'Access-Control-Allow-Origin', '*' );
} );

routes.forEach( route => {
routes.forEach( ( route ) => {
try {
server.get( route.path, route.handler );
} catch ( e ) {
logger.error( 'Problem initing a route.', route, e );
} catch ( error ) {
logger.error( 'Problem initing a route.', route, error );
}
} );
};

export default setupRoutes;

0 comments on commit 42947f3

Please sign in to comment.