import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import SnapSettingsCard from '../../../../components/app/flask/snap-settings-card'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import Typography from '../../../../components/ui/typography/typography'; import { TYPOGRAPHY, COLORS, FLEX_DIRECTION, JUSTIFY_CONTENT, ALIGN_ITEMS, } from '../../../../helpers/constants/design-system'; import Box from '../../../../components/ui/box'; import { SNAPS_VIEW_ROUTE } from '../../../../helpers/constants/routes'; import { disableSnap, enableSnap } from '../../../../store/actions'; import { getSnaps } from '../../../../selectors'; const SnapListTab = () => { const t = useI18nContext(); const history = useHistory(); const dispatch = useDispatch(); const snaps = useSelector(getSnaps); const onClick = (snap) => { const route = `${SNAPS_VIEW_ROUTE}/${window.btoa( unescape(encodeURIComponent(snap.id)), )}`; history.push(route); }; const onToggle = (snap) => { if (snap.enabled) { dispatch(disableSnap(snap.id)); } else { dispatch(enableSnap(snap.id)); } }; return (
{Object.entries(snaps).length ? (
{t('expandExperience')} {t('manageSnaps')}
{Object.entries(snaps).map(([key, snap]) => { return ( { onToggle(snap); }} description={snap.manifest.description} url={snap.id} name={snap.manifest.proposedName} status={snap.status} version={snap.version} onClick={() => { onClick(snap); }} /> ); })}
) : ( {t('noSnaps')} )}
); }; export default SnapListTab;