mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(columns) add name-size (#139)
This commit is contained in:
parent
22142e00ba
commit
b232a936fb
8 changed files with 52 additions and 6 deletions
|
|
@ -3,6 +3,7 @@
|
|||
require('../css/main.css');
|
||||
require('../css/nojs.css');
|
||||
require('../css/columns/name-size-date.css');
|
||||
require('../css/columns/name-size.css');
|
||||
|
||||
// prevent additional loading of exec by spero, remedy, ishtar, salam, omnes
|
||||
window.exec = require('execon');
|
||||
|
|
|
|||
15
css/columns/name-size.css
Normal file
15
css/columns/name-size.css
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
.name {
|
||||
width: 78%;
|
||||
}
|
||||
|
||||
.owner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mode {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.date {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -1,19 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs= require('fs');
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
const isMap = (a) => /\.map$/.test(a);
|
||||
const not = (fn) => (a) => !fn(a);
|
||||
|
||||
const defaultColumns = {
|
||||
'': '',
|
||||
'name-size-date-owner-mode': '',
|
||||
};
|
||||
|
||||
const isDev = process.NODE_ENV === 'development';
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist';
|
||||
|
||||
const dist = getDist(isDev);
|
||||
const columnsDir = path.join(__dirname, '..', dist, 'columns');
|
||||
const columns = readFilesSync(columnsDir, 'utf8');
|
||||
|
||||
const names = fs.readdirSync(columnsDir)
|
||||
.filter(not(isMap));
|
||||
|
||||
const columns = readFilesSync(columnsDir, names, 'utf8');
|
||||
|
||||
module.exports = Object.assign(
|
||||
columns,
|
||||
|
|
|
|||
|
|
@ -36,11 +36,17 @@ module.exports.packer = (name) => {
|
|||
};
|
||||
|
||||
module.exports.columns = (type) => {
|
||||
const addQuotes = (a) => `"${a}"`;
|
||||
const all = Object
|
||||
.keys(columns)
|
||||
.concat('');
|
||||
|
||||
const names = all
|
||||
.filter(Boolean)
|
||||
.map(addQuotes)
|
||||
.join(', ');
|
||||
|
||||
if (!~all.indexOf(type))
|
||||
exit('cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"');
|
||||
exit(`cloudcmd --columns: can be only one of: ${names}`);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,18 +6,29 @@ const clean = require('clear-module');
|
|||
const columnsPath = '../../server/columns';
|
||||
|
||||
test('columns', (t) => {
|
||||
clean(columnsPath);
|
||||
|
||||
const {NODE_ENV} = process.env;
|
||||
process.env.NODE_ENV = '';
|
||||
const columns = require(columnsPath);
|
||||
|
||||
t.equal(columns[''], '', 'should equal');
|
||||
process.env.NODE_ENV = NODE_ENV;
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('columns: dev', (t) => {
|
||||
clean(columnsPath);
|
||||
process.NODE_ENV = 'development';
|
||||
const {NODE_ENV} = process.env;
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
const columns = require(columnsPath);
|
||||
const css = fs.readFileSync(`${__dirname}/../../css/columns/name-size-date.css`, 'utf8');
|
||||
|
||||
t.equal(columns['name-size-date'], css, 'should equal');
|
||||
process.env.NODE_ENV = NODE_ENV;
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ const dir = '../..';
|
|||
|
||||
const validatePath = `${dir}/server/validate`;
|
||||
const exitPath = `${dir}/server/exit`;
|
||||
const columnsPath = `${dir}/server/columns`;
|
||||
|
||||
const validate = require(validatePath);
|
||||
const stub = require('mock-require');
|
||||
|
|
@ -126,11 +127,16 @@ test('validate: columns: wrong', (t) => {
|
|||
const fn = sinon.stub();
|
||||
|
||||
clean();
|
||||
clear(columnsPath);
|
||||
require(exitPath);
|
||||
stub(exitPath, fn);
|
||||
stub(columnsPath, {
|
||||
'name-size-date': '',
|
||||
'name-size': '',
|
||||
});
|
||||
|
||||
const {columns} = require(validatePath);
|
||||
const msg = 'cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"';
|
||||
const msg = 'cloudcmd --columns: can be only one of: "name-size-date", "name-size"';
|
||||
|
||||
columns('hello');
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
<select data-name="js-columns" class="form-control full-width" title="Columns">
|
||||
<option {{ name-size-date-owner-mode-selected }}>name-size-date-owner-mode</option>
|
||||
<option {{ name-size-date-selected }}>name-size-date</option>
|
||||
<option {{ name-size-selected }}>name-size</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@ function getMinifyHtmlOptions() {
|
|||
removeStyleLinkTypeAttributes: true,
|
||||
|
||||
minifyJS: true,
|
||||
minifyCSS: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue