mirror of
https://github.com/getredash/redash.git
synced 2026-03-21 16:00:09 -04:00
* Initial React Rendering with useDashboard
* Make sure widgets refresh + useCallback
* Rename collectFilters and add refreshRate
* Fix error updates not being rendered
* Only render widget bottom when queryResults exists
* Cleanup
* Add useCallback to refreshDashboard
* Make sure Promise.all have all promises done
* Start migrating Dashoard to React
- initial rendering
- some actions
- temporary updated less file
* Fullscreen handler added
* Separate refreshRateHandler hook
* Add a few tooltips
* Separate DashboardControl and normalize btn width
* Share Button
* Fix serach params not updating
* Enumerate More Options
* Toggle Publish options
* Archive Dashboard
* Parameters + Filters
* Prepare Manage Permissions
* Start to create edit mode
* Add Edit Mode functionalities
* Use previous state when updating dashboard
* Mobile adjustments
* PermissionsEditorDialog + Dashboard page title
* Update Dashboard spec
* Fix other specs
* Break dashboard.less
* Hide publish button on mobile
* Angular Cleaning
* Keep edit state when changing resolution
* Bug fix: Dashboard Level Filters not updating
* Remove prepareWidgetsForDashboard
* Revert "Remove prepareWidgetsForDashboard"
This reverts commit b434f03da1.
* Avoid saving layout changes out of editing mode
* Apply policy for enabled refresh rates
* Disable loadDashboard deps
* Restyled by prettier (#4459)
* Update title when dashboard name updates
Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import React from "react";
|
|
import PropTypes from "prop-types";
|
|
import { react2angular } from "react2angular";
|
|
import { $rootScope } from "@/services/ng";
|
|
|
|
export class FavoritesControl extends React.Component {
|
|
static 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, // eslint-disable-line react/no-unused-prop-types
|
|
};
|
|
|
|
static defaultProps = {
|
|
onChange: () => {},
|
|
forceUpdate: "",
|
|
};
|
|
|
|
toggleItem(event, item, callback) {
|
|
const action = item.is_favorite ? item.$unfavorite.bind(item) : item.$favorite.bind(item);
|
|
const savedIsFavorite = item.is_favorite;
|
|
|
|
action().then(() => {
|
|
item.is_favorite = !savedIsFavorite;
|
|
this.forceUpdate();
|
|
$rootScope.$broadcast("reloadFavorites");
|
|
callback();
|
|
});
|
|
}
|
|
|
|
render() {
|
|
const { item, onChange } = this.props;
|
|
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
|
|
title={title}
|
|
className="favorites-control btn-favourite"
|
|
onClick={event => this.toggleItem(event, item, onChange)}>
|
|
<i className={icon} aria-hidden="true" />
|
|
</a>
|
|
);
|
|
}
|
|
}
|
|
|
|
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;
|