Skip to content

Commit

Permalink
Merge pull request #93 from talvbansal/dayjs
Browse files Browse the repository at this point in the history
Replace moment.js with day.js
  • Loading branch information
talvbansal authored Oct 2, 2018
2 parents 2bad5f2 + dc6f08f commit ea555c4
Show file tree
Hide file tree
Showing 35 changed files with 3,330 additions and 98 deletions.
17 changes: 17 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"presets": [
["env", {
"modules": "commonjs",
"targets": {
"browsers": ["> 1%", "last 2 versions", "ie >= 10"]
}
}],
"stage-2"
],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["istanbul"]
}
}
}
33 changes: 31 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,51 @@
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"eslint": "./node_modules/.bin/eslint resources/assets/js/ test/ --ext .js,.vue"
"eslint": "./node_modules/.bin/eslint resources/assets/js/ test/ --ext .js,.vue",
"test": "jest"
},
"jest": {
"verbose": true,
"moduleNameMapper": {
"^vue$": "vue/dist/vue.common.js"
},
"moduleFileExtensions": [
"js",
"vue"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor"
},
"globals": {
"NODE_ENV": "test"
},
"moduleDirectories": [
"node_modules",
"resources/assets/js"
]
},
"devDependencies": {
"@vue/test-utils": "^1.0.0-beta.12",
"axios": "^0.16.2",
"babel-jest": "^23.0.0-alpha.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.24.1",
"bootstrap-notify": "^3.1.3",
"cross-env": "^5.0.1",
"dayjs": "^1.7.7",
"dropzone": "^4.3.0",
"eslint": "^4.19.0",
"eslint-plugin-vue": "^4.3.0",
"gulp": "^3.9.1",
"hammerjs": "^2.0.8",
"jest": "^22.4.2",
"jest-vue-preprocessor": "^1.4.0",
"laravel-mix": "^1.0",
"lodash": "^4.16.2",
"moment": "^2.17.1",
"node": "8.9.4",
"vue": "^2.3.0",
"vue-jest": "^2.2.1",
"vue-touch2": "^1.0.0"
}
}
Empty file modified public/fonts/icomoon.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified public/fonts/icomoon.ttf
100644 → 100755
Empty file.
Empty file modified public/fonts/icomoon.woff
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion public/js/media-manager.js
100644 → 100755

Large diffs are not rendered by default.

Empty file modified resources/assets/fonts/icomoon.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified resources/assets/fonts/icomoon.ttf
100644 → 100755
Empty file.
Empty file modified resources/assets/fonts/icomoon.woff
100644 → 100755
Empty file.
Empty file modified resources/assets/js/base.js
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions resources/assets/js/components/MediaManager.vue
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</a>
</td>
<td>folder</td>
<td>{{ folder.modified.date | moment('DD/MM/YYYY') }}</td>
<td>{{ folder.modified.date | formatDate('DD/MM/YYYY') }}</td>
</tr>

<tr
Expand All @@ -134,7 +134,7 @@

</td>
<td> {{ file.mimeType }}</td>
<td> {{ file.modified.date | moment('DD/MM/YYYY') }}</td>
<td> {{ file.modified.date | formatDate('DD/MM/YYYY') }}</td>
</tr>
</tbody>
</table>
Expand Down
Empty file modified resources/assets/js/components/MediaModal.vue
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified resources/assets/js/components/subcomponents/MediaErrors.vue
100644 → 100755
Empty file.
Empty file modified resources/assets/js/components/subcomponents/MoveItemModal.vue
100644 → 100755
Empty file.
3 changes: 1 addition & 2 deletions resources/assets/js/components/subcomponents/PreviewSideBar.vue
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</tr>
<tr>
<td class="description">Uploaded On</td>
<td class="file-value">{{ currentFile.modified.date | moment }}</td>
<td class="file-value">{{ currentFile.modified.date | formatDate }}</td>
</tr>
</tbody>
</table>
Expand All @@ -61,7 +61,6 @@ import fileManagerMixin from "./../../mixins/file-manager-mixin";
export default{
filters: {
// Take any integer of bytes and convert it into something more human readable...
humanFileSize: function (size) {
let i = Math.floor(Math.log(size) / Math.log(1024));
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion resources/assets/js/components/subcomponents/TopToolBar.vue
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<button
class="btn btn-primary btn-icon-text"
type="button"
title="Add Folder"
title="Add folder"
@click="openModalCreateFolder()">
<i class="icon-folder-plus"/>
<span class="hidden-xs">Add folder</span>
Expand Down
Empty file modified resources/assets/js/iconmoo.json
100644 → 100755
Empty file.
17 changes: 0 additions & 17 deletions resources/assets/js/media-manager.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,12 @@ require("./base");

window.Vue = require("vue");

/**
* Moment is a javascript library that we can use to format dates
* It's similar to Carbon in PHP so we mostly use it to format
* dates that are returned from our Laravel Eloquent models
*/
window.moment = require("moment");

/**
* Register Vue components...
*/
window.Vue.component("media-modal", require("./components/MediaModal.vue"));
window.Vue.component("media-manager", require("./components/MediaManager.vue"));

// Date formatting filter...
window.Vue.filter("moment", function (date, format) {

if (!date) return null;

if (!format) format = "DD/MM/YYYY LTS";

return window.moment(date).utc().format(format);
});

/**
* If it doesn't already exist, register a separate empty vue instance that
* is attached to the window, we can use it to listen out for and handle
Expand Down
9 changes: 9 additions & 0 deletions resources/assets/js/mixins/file-manager-mixin.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { isEmpty } from "lodash";
import dayjs from "dayjs";

export default {
filters:{
formatDate: (date, format = "DD/MM/YYYY hh:mm:ss A") => {
if (!date) return null;

return dayjs(date).format(format);
}
},

methods: {
getItemName: (file) => {
if(isEmpty(file)){
Expand Down
Empty file modified resources/assets/sass/_dropzone.scss
100644 → 100755
Empty file.
Empty file modified resources/assets/sass/icon-code.scss
100644 → 100755
Empty file.
Empty file modified resources/assets/sass/icons.scss
100644 → 100755
Empty file.
Empty file modified resources/assets/sass/media-manager.scss
100644 → 100755
Empty file.
Empty file modified resources/lang/de/messages.php
100644 → 100755
Empty file.
Empty file modified resources/lang/en/messages.php
100644 → 100755
Empty file.
Empty file modified tests/20151106-_SKB7220.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions tests/Frontend/Jest/PreviewSideBar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { shallow } from "@vue/test-utils";
import PreviewSideBar from "./../../../resources/assets/js/components/subcomponents/PreviewSideBar.vue";
import dayjs from "dayjs";

describe("Preview Sidebar", () => {
const wrapper = shallow(PreviewSideBar);

it("it shows a file summary", () => {
wrapper.setProps({
currentFile:{
name: "TestFile.jpg",
size: (1024 * 1024 * 32),
mimeType: "image/jpg",
webPath: "https://localhost/TestFile.jpg",
relativePath: "/TestFile.jpg",
modified: {
date: dayjs("2018-03-19")
}
}
});

expect(wrapper.html().indexOf(
`<img id="easel-preview-image" src="https://localhost/TestFile.jpg" class="img-responsive center-block">`
) !== -1).toBe(true);

expect(wrapper.html().indexOf(
`<td class="description">Name</td> <td class="file-value">TestFile.jpg</td>`
) !== -1).toBe(true);

expect(wrapper.html().indexOf(
`<td class="description">Size</td> <td class="file-value">32 MB</td>`
) !== -1).toBe(true);

expect(wrapper.html().indexOf(
`<td class="description">URL</td> <td class="file-value"><a href="https://localhost/TestFile.jpg" target="_blank" rel="noopener">/TestFile.jpg</a></td>`
) !== -1).toBe(true);

expect(wrapper.html().indexOf(
`<td class="description">Uploaded On</td> <td class="file-value">19/03/2018 12:00:00 AM</td>`
) !== -1).toBe(true);
})

});
67 changes: 67 additions & 0 deletions tests/Frontend/Jest/TopToolBar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { shallow } from "@vue/test-utils";
import TopToolBar from "./../../../resources/assets/js/components/subcomponents/TopToolBar.vue";

describe("TopToolBar", () => {
const wrapper = shallow(TopToolBar);

it("it has the correct buttons", () => {
const toolBarAsText = wrapper.text();
expect(toolBarAsText).toContain("Upload");
expect(toolBarAsText).toContain("Add folder");

expect(toolBarAsText).toContain("Refresh");

expect(toolBarAsText).toContain("Move");
expect(toolBarAsText).toContain("Delete");
expect(toolBarAsText).toContain("Rename");
})

it("emits the open-modal-create-folder event when add folder button is clicked", () => {
const reloadButton = wrapper.find("button[title='Add folder']");
reloadButton.trigger("click");
expect(wrapper.emitted("open-modal-create-folder")).toBeTruthy();
})

it("emits the reload-folder event when reload button is clicked", () => {
const reloadButton = wrapper.find("button[title='Refresh']");
reloadButton.trigger("click");
expect(wrapper.emitted("reload-folder")).toBeTruthy();
})

it("emits the open-modal-move-item event when move button is clicked", () => {
wrapper.setProps({
currentFile : {
name: "/test.jpg",
}
})

const reloadButton = wrapper.find("button[title='Move']");
reloadButton.trigger("click");
expect(wrapper.emitted("open-modal-move-item")).toBeTruthy();
})

it("emits the open-modal-delete-item event when delete button is clicked", () => {
wrapper.setProps({
currentFile : {
name: "/test.jpg",
}
})

const reloadButton = wrapper.find("button[title='Delete']");
reloadButton.trigger("click");
expect(wrapper.emitted("open-modal-delete-item")).toBeTruthy();
})

it("emits the open-modal-rename-item event when rename button is clicked", () => {
wrapper.setProps({
currentFile : {
name: "/test.jpg",
}
})

const reloadButton = wrapper.find("button[title='Rename']");
reloadButton.trigger("click");
expect(wrapper.emitted("open-modal-rename-item")).toBeTruthy();
})

});
Empty file modified tests/Functional/UsesMediaManagerTest.php
100644 → 100755
Empty file.
Empty file modified tests/Unit/MediaManagerTest.php
100644 → 100755
Empty file.
19 changes: 4 additions & 15 deletions webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const webpack = require('webpack');
let mix = require('laravel-mix');
let mix = require("laravel-mix");

/*
|--------------------------------------------------------------------------
Expand All @@ -8,16 +7,6 @@ let mix = require('laravel-mix');
|
*/

mix.webpackConfig({
plugins: [
new webpack.ContextReplacementPlugin(
// The path to directory which should be handled by this plugin
/moment[\/\\]locale/,
// A regular expression matching files that should be included
/(en-gb)\.js/
)
]
});
mix.sass('resources/assets/sass/media-manager.scss', 'public/css/')
.js('resources/assets/js/media-manager.js', 'public/js/')
.copy('resources/assets/fonts', 'public/fonts/')
mix.sass("resources/assets/sass/media-manager.scss", "public/css/")
.js("resources/assets/js/media-manager.js", "public/js/")
.copy("resources/assets/fonts", "public/fonts/");
Loading

0 comments on commit ea555c4

Please sign in to comment.