1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00
phorge-phorge/webroot/rsrc/js/application/diffusion/behavior-pull-lastmodified.js
epriestley 2a355d8548 Make Diffusion "Last Modified" rendering less fragile
Summary:
Ref T9524. Because fetching the last time files were modified in Diffusion can be slow, we bring it in over Ajax.

The logic to fetch and paint the table is kind of fragile because there are two different definitions of the columns right now and we break in a bad way if they differ.

In particular, calling `diffusion.updatecoverage` can populate a "lint commit" for a repository, which tries to generate lint information in one of the views (but not the other one).

In the longer run I think we're removing some of the concepts here and this rendering should be rebuilt to not have two separate column definitions, but just make it degrade gracefully for now since those are larger changes.

Test Plan:
Reproduced the issue in T9524 by calling `diffusion.updatecoverage` on a repostiory. Specifically, this has a side effect of creating a "lint commit" which triggers a "lint" column in this table, sort of.

Applied this patch, got a clean render.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9524

Differential Revision: https://secure.phabricator.com/D14243
2015-10-07 07:32:27 -07:00

34 lines
991 B
JavaScript

/**
* @provides javelin-behavior-diffusion-pull-lastmodified
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-workflow
* javelin-json
*/
JX.behavior('diffusion-pull-lastmodified', function(config) {
new JX.Workflow(config.uri, {paths: JX.JSON.stringify(JX.keys(config.map))})
.setHandler(function(r) {
for (var k in r) {
for (var l in r[k]) {
if (!config.map[k][l]) {
continue;
}
try {
JX.DOM.setContent(JX.$(config.map[k][l]), JX.$H(r[k][l]));
} catch (ex) {
// The way this works is weird and sometimes the components get
// out of sync. Fail gently until we can eventually improve the
// underlying mechanism.
// In particular, we currently may generate lint information
// without generating a lint column. See T9524.
}
}
}
})
.start();
});