{"size": 1131, "ext": "js", "max_stars_repo_path": "src/components/EnabledButton.js", "max_stars_repo_name": "adi-g15/bandwidth-hero", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/EnabledButton.js", "max_issues_repo_name": "adi-g15/bandwidth-hero", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/EnabledButton.js", "max_forks_repo_name": "adi-g15/bandwidth-hero", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.34375, "max_line_length": 127, "alphanum_fraction": 0.6198054819}
import React from 'react'
import { Segment, Button, Checkbox, Label } from 'semantic-ui-react'
import parseUrl from '../utils/parseUrl'

export default function EnabledButton({ enabledAll, allSitesChanged, enabledHosts, currentUrl, onSiteDisable, onSiteEnable }) {
  const { schema, hostname } = parseUrl(currentUrl)

  if (/^https?:/i.test(schema)) {
    return (
      <Segment attached>
        { (!enabledHosts.includes(hostname)) ? (
          <Button content="Enable on this site" onClick={onSiteEnable} basic positive fluid />
        ) : (<Button content="Disable on this site" onClick={onSiteDisable} basic negative fluid />)
        }
      </Segment>
    );
  } else {
    return null;
    // TODO - Implement a Enable Everywhere function
    // return (
    //   <Segment.Group horizontal>
    //     <Segment className="center_element">
    //       <Checkbox checked={enabledAll} onChange={(_) => allSitesChanged()} slider />
    //     </Segment>
    //     <Segment>
    //       <Label>{enabledAll ? "Enabled Everywhere" : "Use Enable List"}</Label>
    //     </Segment>
    //   </Segment.Group>
    // );
  }
}
