Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienSansot committed Mar 16, 2019
1 parent 06237ae commit ce3c29f
Show file tree
Hide file tree
Showing 11 changed files with 403 additions and 403 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var RepositoryTablePath = React.createClass({
changeFolder: function(folder, event){
this.props.onChangeFolder.apply(this, arguments);
},

render: function(){

var folders = [{
Expand Down Expand Up @@ -48,8 +48,8 @@ var RepositoryTablePathNode = React.createClass({
render: function(){
return (
<a href="#" onClick={this.props.onChangeFolder}>
&nbsp;{this.props.folder.name}/
&nbsp;{this.props.folder.name}/
</a>
)
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ RepositoryTableRowFile = React.createClass({
});
},

handleSubmit: function (event) {
handleSubmit: function (event) {
this.setState({editing: false});

if(this.state.edited == false){
Expand Down Expand Up @@ -147,12 +147,12 @@ RepositoryTableRowFile = React.createClass({
<td onClick={this.props.onCheckItem} ><i className={"fa " + icon}></i></td>
<td>
{cell}
</td>
</td>
<td>
{this.props.file.size_pretty}
</td>
</tr>
);
}

})
})
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@

var RepositoryTableRowFolderCreation = React.createClass({

initialName: 'new folder',
initialName: 'new folder',

constants: {
ESCAPE_KEY: 27,
ENTER_KEY: 13
},
constants: {
ESCAPE_KEY: 27,
ENTER_KEY: 13
},

getInitialState: function() {
return({
editing: false,
editing: false,
folder_name: this.initialName,
edited: false,
loading: false
});
},

start: function(){
this.setState({
editing: true,
this.setState({
editing: true,
folder_name: this.initialName,
edited: false
});
},

componentDidUpdate: function (prevProps, prevState) {
if (!prevState.editing && this.state.editing) {
var node = React.findDOMNode(this.refs.editField);
node.focus();
node.setSelectionRange(0, node.value.length);
}
},
if (!prevState.editing && this.state.editing) {
var node = React.findDOMNode(this.refs.editField);
node.focus();
node.setSelectionRange(0, node.value.length);
}
},

handleChange: function (event) {
this.setState({
folder_name: event.target.value,
edited: true
});
},
this.setState({
folder_name: event.target.value,
edited: true
});
},

createFolder: function(folder_name){
createFolder: function(folder_name){
this.setState({
loading: true
}, function(){
Expand All @@ -61,59 +61,59 @@ var RepositoryTableRowFolderCreation = React.createClass({
);

});
},
},

handleSubmit: function (event) {
this.setState({editing: false});
handleSubmit: function (event) {
this.setState({editing: false});

if(this.state.edited == false){
return;
}
if(this.state.edited == false){
return;
}

var folder_name = this.state.folder_name.trim();
var folder_name = this.state.folder_name.trim();

if(folder_name){
this.createFolder(folder_name);
}
},
if(folder_name){
this.createFolder(folder_name);
}
},

handleKeyDown: function (event) {
if (event.which === this.constants.ESCAPE_KEY) {
this.setState({editing: false});
} else if (event.which === this.constants.ENTER_KEY) {
this.handleSubmit(event);
}
},
handleKeyDown: function (event) {
if (event.which === this.constants.ESCAPE_KEY) {
this.setState({editing: false});
} else if (event.which === this.constants.ENTER_KEY) {
this.handleSubmit(event);
}
},

render: function() {

if(this.state.loading)
return (
if(this.state.loading)
return (
<tr>
<td>
<img width="20" height="20" src="/assets/loader.gif" />
</td>
<td>
<img width="20" height="20" src="/assets/loader.gif" />
</td>
</tr>
);
);

if(!this.state.editing)
return (
if(!this.state.editing)
return (
<tr style={{display: 'none'}}></tr>
);
);

return (
return (
<tr>
<td></td>
<td>
<input ref="editField" className="form-control input-sm"
value={this.state.folder_name}
onChange={this.handleChange}
onBlur={this.handleSubmit}
onKeyDown={this.handleKeyDown} />
onChange={this.handleChange}
onBlur={this.handleSubmit}
onKeyDown={this.handleKeyDown} />
</td>
<td></td>
</tr>
);
);
}

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ var RepositoryTableRowFolder = React.createClass({

render: function() {

// var styleRow = { cursor: 'pointer' };
// var styleText = { textDecoration: 'underline'};
// var styleRow = { cursor: 'pointer' };
// var styleText = { textDecoration: 'underline'};

var icon = this.props.folder.checked ? 'fa-check-square-o': 'fa-square-o';

return (
<tr>
return (
<tr>
<td onClick={this.props.onCheckItem}><i className={"fa " + icon}></i></td>
<td>
<i onClick={this.props.onGoIntoFolder} className='fa fa-folder'></i>&nbsp;
<a onClick={this.props.onGoIntoFolder} href="#">{this.props.folder.name}</a>
</td>
<td>
<i onClick={this.props.onGoIntoFolder} className='fa fa-folder'></i>&nbsp;
<a onClick={this.props.onGoIntoFolder} href="#">{this.props.folder.name}</a>
</td>
<td></td>
</tr>
);
</tr>
);
}

})
})
26 changes: 13 additions & 13 deletions app/assets/javascripts/components/repository-table.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var RepositoryTable = React.createClass({
},

componentDidMount: function() {
this.loadFiles();
this.loadFiles();
},

onChangeFolder: function (new_folder, event) {
Expand Down Expand Up @@ -195,8 +195,8 @@ var RepositoryTable = React.createClass({
)
}, this);

var fileRows = this.state.files.map(function(file) {
return <RepositoryTableRowFile
var fileRows = this.state.files.map(function(file) {
return <RepositoryTableRowFile
ref={"file_" + file.key}
key={file.key}
file={file}
Expand All @@ -211,7 +211,7 @@ var RepositoryTable = React.createClass({
var checkedFiles = _.where(this.state.files, {'checked': true});

return (
<div>
<div>
<button type="button" className="btn btn-primary btn-xs"
onClick={this.onTriggerCreateFolder}>
Create Folder
Expand All @@ -229,7 +229,7 @@ var RepositoryTable = React.createClass({
Delete
</button>
{
this.state.deleting &&
this.state.deleting &&
<span>&nbsp;<img width="20" height="20" src="/assets/loader.gif" /></span>
}
&nbsp;
Expand All @@ -255,12 +255,12 @@ var RepositoryTable = React.createClass({
this.state.pasting &&
<img width="20" height="20" src="/assets/loader.gif" />
}
<div>
<div>
<RepositoryTablePath
path={this.state.path}
onChangeFolder={this.onChangeFolder} />
</div>
<table style={{marginBottom: 0}} className="table table-bordered table-hover table-condensed">
<table style={{marginBottom: 0}} className="table table-bordered table-hover table-condensed">
<thead>
<tr>
<th style={{width: '25px', padding:'0 0 5px 2px'}}>
Expand All @@ -273,24 +273,24 @@ var RepositoryTable = React.createClass({
<th style={{width: '10%'}}>Size</th>
</tr>
</thead>
<tbody>
<tbody>
<RepositoryTableRowFolderCreation
ref="create_folder"
path={this.state.path}
create_folder_url={this.props.create_folder_url}
onFolderCreated={this.onFolderCreated}
path_prefix={this.props.path_prefix} />
{folderRows}
{fileRows}
</tbody>
</table>
{fileRows}
</tbody>
</table>
{
!this.state.loading && this.state.files.length == 0 && this.state.folders.length == 0 &&
<span>&nbsp;Emtpy folder</span>
}
{
}
</div>
</div>
)
}
});
});
Loading

0 comments on commit ce3c29f

Please sign in to comment.