diff --git a/frontend/app/components/Client/Sites/Sites.js b/frontend/app/components/Client/Sites/Sites.js index 5a6791191..18eb82e6f 100644 --- a/frontend/app/components/Client/Sites/Sites.js +++ b/frontend/app/components/Client/Sites/Sites.js @@ -15,9 +15,9 @@ import SiteSearch from './SiteSearch'; import AddProjectButton from './AddProjectButton'; const STATUS_MESSAGE_MAP = { - [ RED ]: ' There seems to be an issue (please verify your installation)', - [ YELLOW ]: 'We\'re collecting data from time to time (perhaps low traffic)', - [ GREEN ]: 'All good!', + [RED]: ' There seems to be an issue (please verify your installation)', + [YELLOW]: "We're collecting data from time to time (perhaps low traffic)", + [GREEN]: 'All good!', }; const BLOCKED_IPS = 'BLOCKED_IPS'; @@ -26,202 +26,184 @@ const NONE = 'NONE'; const NEW_SITE_FORM = 'NEW_SITE_FORM'; const GDPR_FORM = 'GDPR_FORM'; -@connect(state => ({ - site: state.getIn([ 'site', 'instance' ]), - sites: state.getIn([ 'site', 'list' ]), - loading: state.getIn([ 'site', 'loading' ]), - user: state.getIn([ 'user', 'account' ]), - account: state.getIn([ 'user', 'account' ]), -}), { - init, - remove, - fetchGDPR -}) +@connect( + (state) => ({ + site: state.getIn(['site', 'instance']), + sites: state.getIn(['site', 'list']), + loading: state.getIn(['site', 'loading']), + user: state.getIn(['user', 'account']), + account: state.getIn(['user', 'account']), + }), + { + init, + remove, + fetchGDPR, + } +) @withPageTitle('Projects - OpenReplay Preferences') class Sites extends React.PureComponent { - state = { - showTrackingCode: false, - modalContent: NONE, - detailContent: NONE, - searchQuery: '', - }; + state = { + showTrackingCode: false, + modalContent: NONE, + detailContent: NONE, + searchQuery: '', + }; - toggleBlockedIp = () => { - this.setState({ - detailContent: this.state.detailContent === BLOCKED_IPS ? NONE : BLOCKED_IPS, - }); - }; + toggleBlockedIp = () => { + this.setState({ + detailContent: this.state.detailContent === BLOCKED_IPS ? NONE : BLOCKED_IPS, + }); + }; - closeModal = () => this.setState({ modalContent: NONE, detailContent: NONE }); + closeModal = () => this.setState({ modalContent: NONE, detailContent: NONE }); - edit = site => { - this.props.init(site) - this.setState({ modalContent: NEW_SITE_FORM }); - } + edit = (site) => { + this.props.init(site); + this.setState({ modalContent: NEW_SITE_FORM }); + }; - remove = async (site) => { - if (await confirm({ - header: 'Projects', - confirmation: `Are you sure you want to delete this Project? We won't be able to record anymore sessions.` - })) { - this.props.remove(site.id); + remove = async (site) => { + if ( + await confirm({ + header: 'Projects', + confirmation: `Are you sure you want to delete this Project? We won't be able to record anymore sessions.`, + }) + ) { + this.props.remove(site.id); + } + }; + + showGDPRForm = (site) => { + this.props.init(site); + this.setState({ modalContent: GDPR_FORM }); + }; + + showNewSiteForm = () => { + this.props.init(); + this.setState({ modalContent: NEW_SITE_FORM }); + }; + + showTrackingCode = (site) => { + this.props.init(site); + this.setState({ showTrackingCode: true }); + }; + + getModalTitle() { + switch (this.state.modalContent) { + case NEW_SITE_FORM: + return this.props.site.exists() ? 'Update Project' : 'New Project'; + case GDPR_FORM: + return 'Project Settings'; + default: + return ''; + } } - }; - showGDPRForm = (site) => { - this.props.init(site); - this.setState({ modalContent: GDPR_FORM }); - }; - - showNewSiteForm = () => { - this.props.init(); - this.setState({ modalContent: NEW_SITE_FORM }); - }; - - showTrackingCode = (site) => { - this.props.init(site); - this.setState({ showTrackingCode: true }); - }; - - getModalTitle() { - switch (this.state.modalContent) { - case NEW_SITE_FORM: - return this.props.site.exists() ? 'Update Project' : 'New Project'; - case GDPR_FORM: - return 'Project Settings'; - default: - return ''; + renderModalContent() { + switch (this.state.modalContent) { + case NEW_SITE_FORM: + return ; + case GDPR_FORM: + return ; + default: + return null; + } } - } - renderModalContent() { - switch (this.state.modalContent) { - case NEW_SITE_FORM: - return ; - case GDPR_FORM: - return - default: - return null; + renderModalDetailContent() { + switch (this.state.detailContent) { + case BLOCKED_IPS: + return ; + default: + return null; + } } - } - renderModalDetailContent() { - switch (this.state.detailContent) { - case BLOCKED_IPS: - return ; - default: - return null; - } - } + render() { + const { loading, sites, site, user, account } = this.props; + const { modalContent, showTrackingCode } = this.state; + const isAdmin = user.admin || user.superAdmin; + const filteredSites = sites.filter((site) => site.name.toLowerCase().includes(this.state.searchQuery.toLowerCase())); - render() { - const { loading, sites, site, user, account } = this.props; - const { modalContent, showTrackingCode } = this.state; - const isAdmin = user.admin || user.superAdmin; - const canAddSites = isAdmin && account.limits.projects && account.limits.projects.remaining !== 0; - const canDeleteSites = sites.size > 1 && isAdmin; - const filteredSites = sites.filter(site => site.name.toLowerCase().includes(this.state.searchQuery.toLowerCase())); + return ( + + this.setState({ showTrackingCode: false })} + site={site} + /> + + + + Projects} + actionButton={} + /> - return ( - - this.setState({ showTrackingCode: false }) } - site={ site } - /> - - - - {/* { 'Projects' } */} - Projects} - actionButton={( - - )} - /> - - - - - this.setState({ searchQuery: value })} /> - - - - - - Name - Key - - - - { - filteredSites.map(_site => ( - // - - - - - - - - - { _site.host } + + + this.setState({ searchQuery: value })} /> - - {_site.projectKey} + + + + Name + Key + + + {filteredSites.map((_site) => ( + + + + + + + + + {_site.host} + + + + {_site.projectKey} + + + + this.showTrackingCode(_site)}> + {'Installation'} + + + + isAdmin && this.edit(_site)} + data-clickable + > + + + + + + ))} - {/* - { _site.host } - {_site.projectKey} - */} - - this.showTrackingCode(_site) }>{ 'Installation' } - {/* canDeleteSites && this.remove(_site) } - > - - */} - isAdmin && this.edit(_site) } - data-clickable - > - - - {/* this.showGDPRForm(_site) } > */} - - - // - )) - } - - - - ); - } + + + ); + } } export default Sites;