prune commit message at build item

This commit is contained in:
oleg 2015-10-16 01:52:23 +03:00
parent 9b0895a4e7
commit e1b1d5e688
6 changed files with 54 additions and 16 deletions

View File

@ -40,7 +40,7 @@ Ui fixes
* current successfully streak icons at project page
* ~~don't appear build from other project on project page~~
* ~~update project info changes (avg duration, etc) on the fly - project page~~
* long commit comment breakes build card makeup
* ~~long commit comment breakes build card makeup~~
* ~~comment start/duration should be on same place during all steps~~
## Roadmap

View File

@ -1,15 +1,9 @@
'use strict';
exports.prune = function(str, length) {
var result = '',
words = str.split(' ');
var _ = require('underscore'),
sharedUtils = require('../static/js/shared/utils');
do {
result += words.shift() + ' ';
} while (words.length && result.length < length);
return result.replace(/ $/, words.length ? '...' : '');
};
_(exports).extend(sharedUtils);
exports.lpad = function(str, length, chr) {
chr = chr || '0';

View File

@ -70,7 +70,7 @@ mixin statusText(build)
span.build_info
i.fa.fa-fw.fa-comment-o
|
span= build.scm.rev.comment
span= utils.prune(build.scm.rev.comment, 40)
|
.build_controls

View File

@ -3,11 +3,13 @@
define([
'react', 'react-router', 'app/actions/project',
'app/actions/build', 'templates/app/components/builds/item',
'app/components/terminal/terminal',
'app/components/common/index'
'app/components/terminal/terminal', 'app/components/common/index',
'app/utils'
], function(
React, Router, ProjectActions, BuildActions, template,
TerminalComponent, CommonComponents
React, Router, ProjectActions,
BuildActions, template,
TerminalComponent, CommonComponents,
utils
) {
template = template.locals({
DateTime: CommonComponents.DateTime,
@ -15,7 +17,8 @@ define([
Progress: CommonComponents.Progress,
Scm: CommonComponents.Scm,
Terminal: TerminalComponent,
Link: Router.Link
Link: Router.Link,
utils: utils
});
var Component = React.createClass({

9
static/js/app/utils.js Normal file
View File

@ -0,0 +1,9 @@
'use strict';
define(['underscore', 'shared/utils'], function(_, sharedUtils) {
var utils = {};
_(utils).extend(sharedUtils);
return utils;
});

32
static/js/shared/utils.js Normal file
View File

@ -0,0 +1,32 @@
'use strict';
(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {
// CommonJS
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD
define(function() {
return factory();
});
}
}(this, function() {
var utils = {};
utils.prune = function(str, length) {
var result = '',
words = str.split(' ');
do {
result += words.shift() + ' ';
} while (words.length && result.length < length);
return result.replace(/ $/, words.length ? '...' : '');
};
return utils;
}));