1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/addons/index.jsx
Ivar Conradi Østhus f669f96d49 wip: frontend should understand rbac permissions (#269)
* chore: update changelog

* 4.0.0-alpha.4

* wip: frontend should understand rbac permissions

* move all feature components to hasAccess

* fix: remove all change permissions

* fix all the tests

* fix all the tests x2

* fix snapshot for node 12

* fine tune perms a bit

* refactor: rewrite to ts

* refactor: use admin constant

* fix: import

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2021-04-20 19:13:31 +02:00

31 lines
924 B
JavaScript

import { connect } from 'react-redux';
import AddonsListComponent from './AddonList';
import { fetchAddons, removeAddon, updateAddon } from '../../store/addons/actions';
const mapStateToProps = state => {
const list = state.addons.toJS();
return {
addons: list.addons,
providers: list.providers,
};
};
const mapDispatchToProps = dispatch => ({
removeAddon: addon => {
// eslint-disable-next-line no-alert
if (window.confirm('Are you sure you want to remove this addon?')) {
removeAddon(addon)(dispatch);
}
},
fetchAddons: () => fetchAddons()(dispatch),
toggleAddon: addon => {
const updatedAddon = { ...addon, enabled: !addon.enabled };
return updateAddon(updatedAddon)(dispatch);
},
});
const AddonsListContainer = connect(mapStateToProps, mapDispatchToProps)(AddonsListComponent);
export default AddonsListContainer;