-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'fork/master' into user-edit
- Loading branch information
Showing
116 changed files
with
1,338 additions
and
993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
engines: | ||
version: "2" | ||
checks: | ||
complex-logic: | ||
enabled: false | ||
file-lines: | ||
enabled: false | ||
method-complexity: | ||
enabled: false | ||
method-count: | ||
enabled: false | ||
method-lines: | ||
config: | ||
threshold: 100 | ||
nested-control-flow: | ||
enabled: false | ||
identical-code: | ||
enabled: false | ||
plugins: | ||
pep8: | ||
enabled: true | ||
eslint: | ||
enabled: true | ||
channel: "eslint-3" | ||
channel: "eslint-5" | ||
config: | ||
config: client/.eslintrc.js | ||
checks: | ||
import/no-unresolved: | ||
enabled: false | ||
ratings: | ||
paths: | ||
- "redash/**/*.py" | ||
- "client/**/*.js" | ||
exclude_paths: | ||
- tests/**/*.py | ||
- migrations/**/*.py | ||
- old_migrations/**/*.py | ||
- setup/**/* | ||
- bin/**/* | ||
|
||
no-multiple-empty-lines: # TODO: Enable | ||
enabled: false | ||
exclude_patterns: | ||
- "tests/**/*.py" | ||
- "migrations/**/*.py" | ||
- "setup/**/*" | ||
- "bin/**/*" | ||
- "**/node_modules/" | ||
- "client/dist/" | ||
- "**/*.pyc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,3 @@ export default function init(ngModule) { | |
} | ||
|
||
init.init = true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { react2angular } from 'react2angular'; | ||
import { $rootScope } from '@/services/ng'; | ||
|
||
function toggleItem(event, item, callback) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
|
||
const action = item.is_favorite ? item.$unfavorite.bind(item) : item.$favorite.bind(item); | ||
const savedIsFavorite = item.is_favorite; | ||
|
||
action().then(() => { | ||
item.is_favorite = !savedIsFavorite; | ||
$rootScope.$broadcast('reloadFavorites'); | ||
callback(); | ||
}); | ||
} | ||
|
||
export function FavoritesControl({ item, onChange }) { | ||
const icon = item.is_favorite ? 'fa fa-star' : 'fa fa-star-o'; | ||
const title = item.is_favorite ? 'Remove from favorites' : 'Add to favorites'; | ||
return ( | ||
<a | ||
href="javascript:void(0)" | ||
title={title} | ||
className="btn-favourite" | ||
onClick={event => toggleItem(event, item, onChange)} | ||
> | ||
<i className={icon} aria-hidden="true" /> | ||
</a> | ||
); | ||
} | ||
|
||
FavoritesControl.propTypes = { | ||
item: PropTypes.shape({ | ||
is_favorite: PropTypes.bool.isRequired, | ||
}).isRequired, | ||
onChange: PropTypes.func, | ||
// Force component update when `item` changes. | ||
// Remove this when `react2angular` will finally go to hell | ||
forceUpdate: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types | ||
}; | ||
|
||
FavoritesControl.defaultProps = { | ||
onChange: () => {}, | ||
}; | ||
|
||
export default function init(ngModule) { | ||
ngModule.component('favoritesControlImpl', react2angular(FavoritesControl)); | ||
ngModule.component('favoritesControl', { | ||
template: ` | ||
<favorites-control-impl | ||
ng-if="$ctrl.item" | ||
item="$ctrl.item" | ||
on-change="$ctrl.onChange" | ||
force-update="$ctrl.forceUpdateTag" | ||
></favorites-control-impl> | ||
`, | ||
bindings: { | ||
item: '=', | ||
}, | ||
controller($scope) { | ||
// See comment for FavoritesControl.propTypes.forceUpdate | ||
this.forceUpdateTag = 'force' + Date.now(); | ||
$scope.$on('reloadFavorites', () => { | ||
this.forceUpdateTag = 'force' + Date.now(); | ||
}); | ||
|
||
this.onChange = () => { | ||
$scope.$applyAsync(); | ||
}; | ||
}, | ||
}); | ||
} | ||
|
||
init.init = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.