From 1a1fd39cf8e42c143fe9057b50aad5e074b91947 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Wed, 6 Apr 2016 14:23:26 +0200 Subject: PLT-2525: Render attachment fields similar to Slack * Render attachment fields similar to Slack * Add /loadtest json url command This allows us to easily create test posts with more props like Slack attachments --- webapp/components/post_attachment.jsx | 131 ++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 62 deletions(-) (limited to 'webapp') diff --git a/webapp/components/post_attachment.jsx b/webapp/components/post_attachment.jsx index 7c4125c27..1c3df6ea2 100644 --- a/webapp/components/post_attachment.jsx +++ b/webapp/components/post_attachment.jsx @@ -87,75 +87,82 @@ class PostAttachment extends React.Component { return ''; } - const compactTable = fields.filter((field) => field.short).length > 0; - let tHead; - let tBody; - - if (compactTable) { - let headerCols = []; - let bodyCols = []; - - fields.forEach((field, i) => { - headerCols.push( - { + if (rowPos === 2 || !(field.short === true) || lastWasLong) { + fieldTables.push( + - {field.title} - + + + {headerCols} + + + + + {bodyCols} + + +
); - bodyCols.push( - - - ); - }); - - tHead = ( - - {headerCols} - + headerCols = []; + bodyCols = []; + rowPos = 0; + nrTables += 1; + lastWasLong = false; + } + headerCols.push( + + {field.title} + ); - tBody = ( - - {bodyCols} - + bodyCols.push( + + ); - } else { - tBody = []; - - fields.forEach((field, i) => { - tBody.push( - - - {field.title} - - - - + rowPos += 1; + lastWasLong = !(field.short === true); + }); + if (headerCols.length > 0) { // Flush last fields + fieldTables.push( + + + + {headerCols} + + + + + {bodyCols} + + +
); - }); } - return ( - - - {tHead} - - - {tBody} - -
+
+ {fieldTables} +
); } -- cgit v1.2.3-1-g7c22