corporate-frontend-mithril
Version:
Corporate frontend MithrilJS modules
99 lines (90 loc) • 6.86 kB
JavaScript
const _ = require('lodash');
const ComparedBundlesPanelModel = require('./compared-bundles-panel-model');
module.exports = class ComparedBundlesPanelView {
constructor() {
}
view(vnode) {
return m('.b-bundles-panel.b-component', [
m('h2.b-title--first.b-title.b-title--h2.b-text--upper.b-text--align-center.b-component--tight', `Compare ${vnode.attrs.source.server} and ${vnode.attrs.destination.server}`),
m('.b-bundles-panel__content-container.b-component', [
m('.b-featured-table', [
m('.b-featured-table__row', [
m('.4/12.b-featured-table__cell.b-featured-table__cell--head', ' '),
m('.5/24.b-featured-table__cell.b-featured-table__cell--head', 'AUTHORS'),
m('.8/24.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--no-border-right', 'PUBLISHES'),
//HACK - merge this column with the above one doesn't work
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', ' '),
]),
m('.b-featured-table__row', [
m('.4/12.b-featured-table__cell.b-featured-table__cell--head', ' '),
//Source author
m('.1/12.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--white.b-text--upper', `${vnode.attrs.source.server}`),
//Destination author
m('.3/24.b-featured-table__cell.b-featured-table__cell--head.b-text--upper', `${vnode.attrs.destination.server}`),
//Source publish
m('.1/12.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--white.b-text--upper', `${vnode.attrs.source.server}`),
//Destination publish
m('.6/24.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--no-border-right.b-text--upper', `${vnode.attrs.destination.server}`),
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', ' '),
]),
m('.b-featured-table__row', [
m('.4/12.b-featured-table__cell.b-featured-table__cell--head', 'Bundle Name'),
//Source author
m('.1/12.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--white', 'Author1'),
//Destination author
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', 'Author1'),
//Source publish
m('.1/12.b-featured-table__cell.b-featured-table__cell--head.b-featured-table__cell--white', 'Publish1'),
//Destination publish
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', 'Publish1'),
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', 'Publish2'),
m('.3/24.b-featured-table__cell.b-featured-table__cell--head', 'Publish3'),
]),
_.map(ComparedBundlesPanelModel.getDisplayList(vnode.attrs.source, vnode.attrs.destination), (bundleGroup)=>{
return m('.b-featured-table__row', [
m(`.4/12.grid_cell.b-featured-table__cell
${ComparedBundlesPanelModel.getBundleNameClass(bundleGroup)}`, `${bundleGroup.name}`),
m('.1/12.grid_cell.b-featured-table__cell.b-featured-table__cell--white', bundleGroup.source.author1 ?
[
m('span.b-text', `${bundleGroup.source.author1.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.source.author1)}`),
] : '-'),
m(`.3/24.grid_cell.b-featured-table__cell
${ComparedBundlesPanelModel.getDestinationBundleClass(bundleGroup, 'author1')}`, bundleGroup.destination.author1 ?
[
m('span.b-text', `${bundleGroup.destination.author1.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.destination.author1)}`),
] : '-'),
m('.1/12.grid_cell.b-featured-table__cell.b-featured-table__cell--white', bundleGroup.source.publish1 ?
[
m('span.b-text', `${bundleGroup.source.publish1.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.source.publish1)}`),
] : '-'),
m(`.3/24.grid_cell.b-featured-table__cell
${ComparedBundlesPanelModel.getDestinationBundleClass(bundleGroup, 'publish1')}`, bundleGroup.destination.publish1 ?
[
m('span.b-text', `${bundleGroup.destination.publish1.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.destination.publish1)}`),
] : '-'),
m(`.3/24.grid_cell.b-featured-table__cell
${ComparedBundlesPanelModel.getDestinationBundleClass(bundleGroup, 'publish2')}`, bundleGroup.destination.publish2 ?
[
m('span.b-text', `${bundleGroup.destination.publish2.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.destination.publish2)}`),
] : '-'),
m(`.3/24.grid_cell.b-featured-table__cell
${ComparedBundlesPanelModel.getDestinationBundleClass(bundleGroup, 'publish3')}`, bundleGroup.destination.publish3 ?
[
m('span.b-text', `${bundleGroup.destination.publish3.version}`),
m('span.b-text', `${ComparedBundlesPanelModel.getBundleStateText(bundleGroup.destination.publish3)}`),
] : '-'),
]);
}),
]),
]),
m('div', [
m('span', 'Synchronise bundle status every 5 seconds for DEV, TEST, TRAIN and PROD.'),
]),
]);
}
};