File tree Expand file tree Collapse file tree
skins/base/views/molecules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 },
2222 "dependencies" : {
2323 "classnames" : " ^2.1.2" ,
24+ "filesize" : " ^3.1.2" ,
2425 "flux" : " ^2.0.3" ,
2526 "matrix-js-sdk" : " 0.1.1" ,
2627 "q" : " ^1.4.1" ,
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 OpenMarket Ltd
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ 'use strict' ;
18+
19+ var React = require ( 'react' ) ;
20+ var filesize = require ( 'filesize' ) ;
21+
22+ var MFileTileController = require ( "../../../../src/controllers/molecules/MFileTile" ) ;
23+
24+ var MatrixClientPeg = require ( '../../../../src/MatrixClientPeg' ) ;
25+
26+ module . exports = React . createClass ( {
27+ displayName : 'MFileTile' ,
28+ mixins : [ MFileTileController ] ,
29+
30+ render : function ( ) {
31+ var content = this . props . mxEvent . getContent ( ) ;
32+ var cli = MatrixClientPeg . get ( ) ;
33+
34+ return (
35+ < span className = "mx_MFileTile" >
36+ < a href = { cli . mxcUrlToHttp ( content . url ) } >
37+ { this . presentableTextForFile ( content ) }
38+ </ a >
39+ </ span >
40+ ) ;
41+ } ,
42+ } ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ var tileTypes = {
3131 'm.text' : ComponentBroker . get ( 'molecules/MTextTile' ) ,
3232 'm.notice' : ComponentBroker . get ( 'molecules/MNoticeTile' ) ,
3333 'm.emote' : ComponentBroker . get ( 'molecules/MEmoteTile' ) ,
34- 'm.image' : ComponentBroker . get ( 'molecules/MImageTile' )
34+ 'm.image' : ComponentBroker . get ( 'molecules/MImageTile' ) ,
35+ 'm.file' : ComponentBroker . get ( 'molecules/MFileTile' )
3536} ;
3637
3738var MessageTileController = require ( "../../../../src/controllers/molecules/MessageTile" ) ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ require('../skins/base/views/molecules/MTextTile');
7070require ( '../skins/base/views/molecules/MNoticeTile' ) ;
7171require ( '../skins/base/views/molecules/MEmoteTile' ) ;
7272require ( '../skins/base/views/molecules/MImageTile' ) ;
73+ require ( '../skins/base/views/molecules/MFileTile' ) ;
7374require ( '../skins/base/views/molecules/MRoomMemberTile' ) ;
7475require ( '../skins/base/views/molecules/RoomHeader' ) ;
7576require ( '../skins/base/views/molecules/MessageComposer' ) ;
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 OpenMarket Ltd
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ 'use strict' ;
18+
19+ module . exports = {
20+ presentableTextForFile : function ( content ) {
21+ var linkText = 'Attachment' ;
22+ if ( content . body && content . body . length > 0 ) {
23+ linkText = content . body ;
24+ }
25+
26+ var additionals = [ ] ;
27+ if ( content . info . mimetype && content . info . mimetype . length > 0 ) {
28+ additionals . push ( content . info . mimetype ) ;
29+ }
30+ if ( content . info . size && content . info . size . length > 0 ) {
31+ additionals . push ( filesize ( content . info . size ) ) ;
32+ }
33+
34+ if ( additionals . length > 0 ) {
35+ linkText += ' (' + additionals . join ( ',' ) + ')' ;
36+ }
37+ return linkText ;
38+ }
39+ } ;
40+
You can’t perform that action at this time.
0 commit comments