From a572789a41411d69308e05b655ff960353f633b7 Mon Sep 17 00:00:00 2001 From: Enguerran Date: Wed, 4 Oct 2017 12:05:08 +0200 Subject: [PATCH 01/30] prettier --- config/webpack.config.base.js | 17 +++--- config/webpack.config.cozy-ui.js | 6 ++- config/webpack.config.dev.js | 10 ++-- config/webpack.config.disable-contexts.js | 4 +- config/webpack.config.manifest.js | 13 +++-- config/webpack.config.pictures.js | 2 +- config/webpack.config.preact.js | 14 ++--- config/webpack.config.vendors.js | 7 ++- config/webpack.target.browser.js | 64 ++++++++++++++--------- config/webpack.target.mobile.js | 6 +-- webpack.config.js | 6 ++- 11 files changed, 92 insertions(+), 57 deletions(-) diff --git a/config/webpack.config.base.js b/config/webpack.config.base.js index 284ed30840..812d7baf59 100644 --- a/config/webpack.config.base.js +++ b/config/webpack.config.base.js @@ -7,7 +7,7 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin') const SRC_DIR = path.resolve(__dirname, '../src') -module.exports = function (production) { +module.exports = function(production) { return { resolve: { modules: ['node_modules', SRC_DIR], @@ -44,16 +44,16 @@ module.exports = function (production) { loader: 'postcss-loader', options: { sourceMap: true, - plugins: () => [require('autoprefixer')({ browsers: ['last 2 versions'] })] + plugins: () => [ + require('autoprefixer')({ browsers: ['last 2 versions'] }) + ] } } ] }) } ], - noParse: [ - /localforage\/dist/ - ] + noParse: [/localforage\/dist/] }, plugins: [ new ScriptExtHtmlWebpackPlugin({ @@ -67,7 +67,12 @@ module.exports = function (production) { require('postcss-discard-duplicates'), require('postcss-discard-empty') ].concat( - production ? require('csswring')({preservehacks: true, removeallcomments: true}) : [] + production + ? require('csswring')({ + preservehacks: true, + removeallcomments: true + }) + : [] ) }) ] diff --git a/config/webpack.config.cozy-ui.js b/config/webpack.config.cozy-ui.js index 1baeed0a23..3261856b37 100644 --- a/config/webpack.config.cozy-ui.js +++ b/config/webpack.config.cozy-ui.js @@ -31,7 +31,9 @@ module.exports = { loader: 'postcss-loader', options: { sourceMap: true, - plugins: () => [require('autoprefixer')({ browsers: ['last 2 versions'] })] + plugins: () => [ + require('autoprefixer')({ browsers: ['last 2 versions'] }) + ] } }, 'stylus-loader' @@ -44,7 +46,7 @@ module.exports = { new LoaderOptionsPlugin({ options: { stylus: { - use: [ require('cozy-ui/stylus')() ] + use: [require('cozy-ui/stylus')()] } } }) diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 6501686701..19d847f6fa 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -6,10 +6,12 @@ module.exports = { devtool: '#source-map', externals: ['cozy'], module: { - rules: [{ - test: require.resolve('cozy-bar/dist/cozy-bar.js'), - loader: 'imports-loader?css=./cozy-bar.css' - }] + rules: [ + { + test: require.resolve('cozy-bar/dist/cozy-bar.js'), + loader: 'imports-loader?css=./cozy-bar.css' + } + ] }, plugins: [ new DefinePlugin({ diff --git a/config/webpack.config.disable-contexts.js b/config/webpack.config.disable-contexts.js index db8d1c93b2..94d30076fa 100644 --- a/config/webpack.config.disable-contexts.js +++ b/config/webpack.config.disable-contexts.js @@ -3,7 +3,5 @@ const { IgnorePlugin } = require('webpack') module.exports = { - plugins: [ - new IgnorePlugin(/^\.\.\/contexts/) - ] + plugins: [new IgnorePlugin(/^\.\.\/contexts/)] } diff --git a/config/webpack.config.manifest.js b/config/webpack.config.manifest.js index c43e3c5917..75357250a8 100644 --- a/config/webpack.config.manifest.js +++ b/config/webpack.config.manifest.js @@ -2,14 +2,16 @@ const CopyPlugin = require('copy-webpack-plugin') -module.exports = function (production, app) { +module.exports = function(production, app) { // Method to modify the manifest slug on dev builds. On production builds the // manifest should be copied without modification. // // For dev builds we use the generic "app" slug to share the same application // domain for each applications. - function transformManifest (buffer) { - if (production) { return buffer } + function transformManifest(buffer) { + if (production) { + return buffer + } const content = JSON.parse(buffer.toString()) content.slug = 'app' @@ -19,7 +21,10 @@ module.exports = function (production, app) { return { plugins: [ new CopyPlugin([ - { from: `targets/${app}/manifest.webapp`, transform: transformManifest }, + { + from: `targets/${app}/manifest.webapp`, + transform: transformManifest + }, { from: 'README.md' }, { from: 'LICENSE' } ]) diff --git a/config/webpack.config.pictures.js b/config/webpack.config.pictures.js index 593fd51a55..f6fde9ade6 100644 --- a/config/webpack.config.pictures.js +++ b/config/webpack.config.pictures.js @@ -1,6 +1,6 @@ 'use strict' -module.exports = function (production) { +module.exports = function(production) { return { module: { rules: [ diff --git a/config/webpack.config.preact.js b/config/webpack.config.preact.js index baec9838a5..78fd3c01b8 100644 --- a/config/webpack.config.preact.js +++ b/config/webpack.config.preact.js @@ -2,16 +2,18 @@ module.exports = { module: { - rules: [{ - test: /\.jsx$/, - exclude: /node_modules\/(?!(cozy-ui))/, - loader: 'babel-loader' - }] + rules: [ + { + test: /\.jsx$/, + exclude: /node_modules\/(?!(cozy-ui))/, + loader: 'babel-loader' + } + ] }, resolve: { extensions: ['.jsx'], alias: { - 'react': 'preact-compat', + react: 'preact-compat', 'react-dom': 'preact-compat' } } diff --git a/config/webpack.config.vendors.js b/config/webpack.config.vendors.js index b51d91983c..4c00f87fde 100644 --- a/config/webpack.config.vendors.js +++ b/config/webpack.config.vendors.js @@ -2,11 +2,14 @@ const CopyPlugin = require('copy-webpack-plugin') -module.exports = function (production, app) { +module.exports = function(production, app) { return { plugins: [ new CopyPlugin([ - { from: `targets/${app}/vendor/assets/app-icon.svg`, to: 'public/app-icon.svg' }, + { + from: `targets/${app}/vendor/assets/app-icon.svg`, + to: 'public/app-icon.svg' + }, { from: `targets/${app}/vendor/assets`, ignore: ['.gitkeep'] } ]) ] diff --git a/config/webpack.target.browser.js b/config/webpack.target.browser.js index 05baee7f00..07f2933b45 100644 --- a/config/webpack.target.browser.js +++ b/config/webpack.target.browser.js @@ -5,7 +5,7 @@ const fs = require('fs') const { DefinePlugin } = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin') -module.exports = function (production, app) { +module.exports = function(production, app) { var entry = { app: path.resolve(__dirname, `../targets/${app}/web/main`) } @@ -25,32 +25,48 @@ module.exports = function (production, app) { }) ] - if (fs.existsSync(path.resolve(__dirname, `../targets/${app}/web/services.jsx`))) { + if ( + fs.existsSync(path.resolve(__dirname, `../targets/${app}/web/services.jsx`)) + ) { entry.services = path.resolve(__dirname, `../targets/${app}/web/services`) - plugins.push(new HtmlWebpackPlugin({ - template: path.resolve(__dirname, `../targets/${app}/web/services.ejs`), - title: `cozy-${app}`, - filename: 'services.html', - chunks: ['services'], - inject: 'head', - minify: { - collapseWhitespace: true - } - })) + plugins.push( + new HtmlWebpackPlugin({ + template: path.resolve(__dirname, `../targets/${app}/web/services.ejs`), + title: `cozy-${app}`, + filename: 'services.html', + chunks: ['services'], + inject: 'head', + minify: { + collapseWhitespace: true + } + }) + ) } - if (fs.existsSync(path.resolve(__dirname, `../targets/${app}/web/public/main.jsx`))) { - entry['public/app'] = path.resolve(__dirname, `../targets/${app}/web/public/main`) - plugins.push(new HtmlWebpackPlugin({ - template: path.resolve(__dirname, `../targets/${app}/web/public/index.ejs`), - title: `cozy-${app}`, - filename: 'public/index.html', - chunks: ['public/app'], - inject: 'head', - minify: { - collapseWhitespace: true - } - })) + if ( + fs.existsSync( + path.resolve(__dirname, `../targets/${app}/web/public/main.jsx`) + ) + ) { + entry['public/app'] = path.resolve( + __dirname, + `../targets/${app}/web/public/main` + ) + plugins.push( + new HtmlWebpackPlugin({ + template: path.resolve( + __dirname, + `../targets/${app}/web/public/index.ejs` + ), + title: `cozy-${app}`, + filename: 'public/index.html', + chunks: ['public/app'], + inject: 'head', + minify: { + collapseWhitespace: true + } + }) + ) } return { diff --git a/config/webpack.target.mobile.js b/config/webpack.target.mobile.js index cb96db05b1..70d57b416c 100644 --- a/config/webpack.target.mobile.js +++ b/config/webpack.target.mobile.js @@ -6,7 +6,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin') const pkg = require(path.resolve(__dirname, '../package.json')) -module.exports = function (production, app) { +module.exports = function(production, app) { return { entry: { app: [path.resolve(__dirname, `../targets/${app}/mobile/main`)] @@ -23,8 +23,8 @@ module.exports = function (production, app) { __APP_VERSION__: JSON.stringify(pkg.version) }), new ProvidePlugin({ - 'PouchDB': 'pouchdb', - 'pouchdbFind': 'pouchdb-find', + PouchDB: 'pouchdb', + pouchdbFind: 'pouchdb-find', 'cozy.client': 'cozy-client-js/dist/cozy-client.js', 'cozy.bar': 'cozy-bar/dist/cozy-bar.mobile.js' }), diff --git a/webpack.config.js b/webpack.config.js index 536e3345a9..830bd25aea 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const merge = require('webpack-merge') -module.exports = function (env) { +module.exports = function(env) { const { target = 'browser', app = 'drive' } = env const production = env.production === true return merge( @@ -14,6 +14,8 @@ module.exports = function (env) { require('./config/webpack.config.vendors')(production, app), require('./config/webpack.config.manifest')(production, app), require(`./config/webpack.target.${target}`)(production, app), - require(production ? './config/webpack.config.prod' : './config/webpack.config.dev') + require(production + ? './config/webpack.config.prod' + : './config/webpack.config.dev') ) } From e1ac28ac91c3fab22176586f514707fa7eb93b73 Mon Sep 17 00:00:00 2001 From: Enguerran Date: Fri, 6 Oct 2017 12:03:32 +0200 Subject: [PATCH 02/30] fix: import file only once see http://stylus-lang.com/docs/import.html\#require for more details about stylus @import vs @require --- src/drive/ducks/upload/styles.styl | 2 +- src/drive/styles/confirms.styl | 2 +- src/drive/styles/main.styl | 2 +- src/drive/styles/table.styl | 2 +- src/photos/ducks/upload/styles.styl | 2 +- src/photos/styles/addToAlbum.styl | 2 +- src/photos/styles/alerter.styl | 2 +- src/photos/styles/confirms.styl | 2 +- src/photos/styles/createAlbumForm.styl | 2 +- src/photos/styles/layout.styl | 2 +- src/photos/styles/main.styl | 2 +- src/photos/styles/newAlbum.styl | 2 +- src/sharing/components/autosuggest.styl | 2 +- src/sharing/components/recipient.styl | 2 +- src/sharing/share.styl | 2 +- targets/photos/web/public/index.styl | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/drive/ducks/upload/styles.styl b/src/drive/ducks/upload/styles.styl index 5bd360f3a8..07109b9c42 100644 --- a/src/drive/ducks/upload/styles.styl +++ b/src/drive/ducks/upload/styles.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' @import '../../styles/mimetypes' .upload-queue diff --git a/src/drive/styles/confirms.styl b/src/drive/styles/confirms.styl index 543ea2fc52..862cbfe8f1 100644 --- a/src/drive/styles/confirms.styl +++ b/src/drive/styles/confirms.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .fil-confirm-text left-padded(25px) diff --git a/src/drive/styles/main.styl b/src/drive/styles/main.styl index 81683b3416..6bbea27469 100644 --- a/src/drive/styles/main.styl +++ b/src/drive/styles/main.styl @@ -1,5 +1,5 @@ @import 'cozy-ui/defaults' -@import 'cozy-ui' +@require 'cozy-ui' div:focus outline: none diff --git a/src/drive/styles/table.styl b/src/drive/styles/table.styl index 2f2eeaa63b..75f8be7a39 100644 --- a/src/drive/styles/table.styl +++ b/src/drive/styles/table.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' @import './mimetypes' .fil-content-table diff --git a/src/photos/ducks/upload/styles.styl b/src/photos/ducks/upload/styles.styl index aaaca078f3..2d41c3fb58 100644 --- a/src/photos/ducks/upload/styles.styl +++ b/src/photos/ducks/upload/styles.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .upload-queue @extend $popover diff --git a/src/photos/styles/addToAlbum.styl b/src/photos/styles/addToAlbum.styl index 2fd6bd7bcb..f28c59ff94 100644 --- a/src/photos/styles/addToAlbum.styl +++ b/src/photos/styles/addToAlbum.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' :local @extend $modals diff --git a/src/photos/styles/alerter.styl b/src/photos/styles/alerter.styl index cfe405cb9e..ba0fc0f81f 100644 --- a/src/photos/styles/alerter.styl +++ b/src/photos/styles/alerter.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .pho-alerter @extends $alerts diff --git a/src/photos/styles/confirms.styl b/src/photos/styles/confirms.styl index 599bd4405f..d32511c6c5 100644 --- a/src/photos/styles/confirms.styl +++ b/src/photos/styles/confirms.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .fil-confirm-text left-padded(25px) diff --git a/src/photos/styles/createAlbumForm.styl b/src/photos/styles/createAlbumForm.styl index 073ef72c81..b4286b7fd2 100644 --- a/src/photos/styles/createAlbumForm.styl +++ b/src/photos/styles/createAlbumForm.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .pho-create-album-form @extend $form-text diff --git a/src/photos/styles/layout.styl b/src/photos/styles/layout.styl index 9cc4ef222f..680668b8cc 100755 --- a/src/photos/styles/layout.styl +++ b/src/photos/styles/layout.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .pho-wrapper @extend $app-2panes-sticky diff --git a/src/photos/styles/main.styl b/src/photos/styles/main.styl index 4eb16189a0..27806ecc93 100755 --- a/src/photos/styles/main.styl +++ b/src/photos/styles/main.styl @@ -1,5 +1,5 @@ @import 'cozy-ui/defaults' -@import 'cozy-ui' +@require 'cozy-ui' :global // Global utils classes comes here diff --git a/src/photos/styles/newAlbum.styl b/src/photos/styles/newAlbum.styl index 43ac05a919..2ee4ced81c 100644 --- a/src/photos/styles/newAlbum.styl +++ b/src/photos/styles/newAlbum.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .pho-panel position fixed diff --git a/src/sharing/components/autosuggest.styl b/src/sharing/components/autosuggest.styl index f8efbb8fce..7243216821 100644 --- a/src/sharing/components/autosuggest.styl +++ b/src/sharing/components/autosuggest.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .container position relative diff --git a/src/sharing/components/recipient.styl b/src/sharing/components/recipient.styl index 05e4627fb3..6a7ea67911 100644 --- a/src/sharing/components/recipient.styl +++ b/src/sharing/components/recipient.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' .pho-recipient display flex diff --git a/src/sharing/share.styl b/src/sharing/share.styl index b886cea23a..98914d6d37 100644 --- a/src/sharing/share.styl +++ b/src/sharing/share.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' :global label[for='pho-album-share-toggle'] diff --git a/targets/photos/web/public/index.styl b/targets/photos/web/public/index.styl index a70c4d53e4..5a301be438 100644 --- a/targets/photos/web/public/index.styl +++ b/targets/photos/web/public/index.styl @@ -1,4 +1,4 @@ -@import 'cozy-ui' +@require 'cozy-ui' @import '~photos/styles/topbar' @import '~photos/styles/toolbar' From 82e2e2652284044f842a952dcc92b0442e169c77 Mon Sep 17 00:00:00 2001 From: Yannick Lohse Date: Tue, 10 Oct 2017 15:30:25 +0200 Subject: [PATCH 03/30] chore: update list library items plugin --- targets/drive/mobile/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/drive/mobile/config.xml b/targets/drive/mobile/config.xml index cfc06c8a1b..60e29dd41d 100644 --- a/targets/drive/mobile/config.xml +++ b/targets/drive/mobile/config.xml @@ -90,5 +90,5 @@ - + From 5c283245b8a39d117d10b0aa36f5340a52684740 Mon Sep 17 00:00:00 2001 From: Yannick Lohse Date: Tue, 10 Oct 2017 16:03:27 +0200 Subject: [PATCH 04/30] chore: update ios to latest engine --- targets/drive/mobile/config.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/drive/mobile/config.xml b/targets/drive/mobile/config.xml index cfc06c8a1b..4c22d58245 100644 --- a/targets/drive/mobile/config.xml +++ b/targets/drive/mobile/config.xml @@ -35,7 +35,7 @@ - + @@ -61,6 +61,7 @@ + From baaa2a273a4d9464b3af0a802369b565576008e2 Mon Sep 17 00:00:00 2001 From: Yannick Lohse Date: Wed, 11 Oct 2017 16:53:13 +0200 Subject: [PATCH 05/30] chore: upgrade list library items --- targets/drive/mobile/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/drive/mobile/config.xml b/targets/drive/mobile/config.xml index 83019e821c..6201c24c4f 100644 --- a/targets/drive/mobile/config.xml +++ b/targets/drive/mobile/config.xml @@ -91,5 +91,5 @@ - + From 221bf2e49b69ed74fbc385fccfac63ea29593692 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Thu, 12 Oct 2017 12:02:13 +0200 Subject: [PATCH 06/30] feat: new route to display files --- src/drive/components/AppRoute.jsx | 4 +- src/drive/ducks/files/FileOpener.js | 64 +++++++++++++++++++++++++++++ src/drive/ducks/files/index.jsx | 1 + src/drive/ducks/files/styles.styl | 4 ++ src/drive/locales/en.json | 1 + 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/drive/ducks/files/FileOpener.js create mode 100644 src/drive/ducks/files/styles.styl diff --git a/src/drive/components/AppRoute.jsx b/src/drive/components/AppRoute.jsx index 9a95ca5341..19a240a852 100644 --- a/src/drive/components/AppRoute.jsx +++ b/src/drive/components/AppRoute.jsx @@ -6,7 +6,8 @@ import FileExplorer from '../containers/FileExplorer' import { FolderContainer as Folder, - RecentContainer as Recent + RecentContainer as Recent, + FileOpener } from '../ducks/files' import { Container as Trash } from '../ducks/trash' @@ -17,6 +18,7 @@ const AppRoute = ( + ) diff --git a/src/drive/ducks/files/FileOpener.js b/src/drive/ducks/files/FileOpener.js new file mode 100644 index 0000000000..737e481d21 --- /dev/null +++ b/src/drive/ducks/files/FileOpener.js @@ -0,0 +1,64 @@ +/* global cozy */ + +import { getFileDownloadUrl } from '../../actions' +import { Spinner, Modal } from 'cozy-ui/react' +import React, { Component } from 'react' +import { connect } from 'react-redux' +import styles from './styles' + +const withAlert = Wrapped => + connect(null, dispatch => ({ + alert: data => dispatch({ type: 'ALERT', alert: data }) + }))(Wrapped) + +export default withAlert( + class extends Component { + state = { url: null, loading: false, closing: false } + + componentWillMount() { + this.openFile() + } + + async openFile() { + const { router, params: { fileId } } = this.props + try { + const url = await getFileDownloadUrl(fileId) + this.setState({ url }) + } catch (e) { + router.push('/') + alert({ + message: 'alert.could_not_open_file' + }) + } finally { + this.setState({ loading: false }) + } + } + + handleClose = async () => { + this.setState({ closing: true }) + const { router, params: { fileId } } = this.props + const { relationships: { parent } } = await cozy.client.files.statById( + fileId + ) + + // Go to the parent folder + router.push(`/files/${parent.data.id}`) + } + + render() { + const { closing, loading, url } = this.state + return ( +
+ {loading || closing ? ( + + ) : null} + {url && !closing ? ( + +