diff --git a/console/package-lock.json b/console/package-lock.json index f47d342f028b2..cb57bed7337a7 100644 --- a/console/package-lock.json +++ b/console/package-lock.json @@ -1,5 +1,5 @@ { - "name": "hasura-console", + "name": "graphql-engine-console", "version": "0.1.0", "lockfileVersion": 1, "requires": true, diff --git a/console/src/components/Common/localStorageManager.js b/console/src/components/Common/localStorageManager.js new file mode 100644 index 0000000000000..d4ffedc2dbfa7 --- /dev/null +++ b/console/src/components/Common/localStorageManager.js @@ -0,0 +1,22 @@ +const loveConsentState = 'console:loveIcon'; +const defaultState = { + isDismissed: false, +}; + +const setLoveConsentState = stateData => { + window.localStorage.setItem(loveConsentState, JSON.stringify(stateData)); +}; + +const getLoveConsentState = stateData => { + const s = window.localStorage.getItem( + loveConsentState, + JSON.stringify(stateData) + ); + if (s) { + return JSON.parse(s); + } + window.localStorage.setItem(loveConsentState, JSON.stringify(defaultState)); + return defaultState; +}; + +export { getLoveConsentState, setLoveConsentState }; diff --git a/console/src/components/Main/Discord.svg b/console/src/components/Main/Discord.svg new file mode 100644 index 0000000000000..76cbf85f4b7f2 --- /dev/null +++ b/console/src/components/Main/Discord.svg @@ -0,0 +1,36 @@ + + + + + + Discord + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + diff --git a/console/src/components/Main/Github.svg b/console/src/components/Main/Github.svg new file mode 100644 index 0000000000000..e301aa556722c --- /dev/null +++ b/console/src/components/Main/Github.svg @@ -0,0 +1,23 @@ + + + + Github + Created with Sketch. + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/console/src/components/Main/Main.js b/console/src/components/Main/Main.js index c9bf6654236b8..9863d3e94917c 100644 --- a/console/src/components/Main/Main.js +++ b/console/src/components/Main/Main.js @@ -11,16 +11,27 @@ import './NotificationOverrides.css'; const semver = require('semver'); +import { + getLoveConsentState, + setLoveConsentState, +} from '../Common/localStorageManager'; + class Main extends React.Component { constructor(props) { super(props); this.state = { showBannerNotification: false, - showEvents: false + showEvents: false, }; + + this.state.loveConsentState = getLoveConsentState(); + this.handleBodyClick = this.handleBodyClick.bind(this); } componentDidMount() { const { dispatch } = this.props; + document + .querySelector('body') + .addEventListener('click', this.handleBodyClick); dispatch(loadServerVersion()).then(() => { dispatch(checkServerUpdates()).then(() => { let isUpdateAvailable = false; @@ -49,6 +60,30 @@ class Main extends React.Component { }); }); } + handleBodyClick(e) { + const heartDropDownOpen = document.querySelectorAll( + '#dropdown_wrapper.open' + ); + if ( + !document.getElementById('dropdown_wrapper').contains(e.target) && + heartDropDownOpen.length !== 0 + ) { + document.getElementById('dropdown_wrapper').classList.remove('open'); + } + } + handleDropdownToggle() { + document.getElementById('dropdown_wrapper').classList.toggle('open'); + } + closeLoveIcon() { + const s = { + isDismissed: true, + }; + setLoveConsentState(s); + this.setState({ + ...this.state, + loveConsentState: { ...getLoveConsentState() }, + }); + } closeUpdateBanner() { const { latestServerVersion } = this.props; window.localStorage.setItem( @@ -70,6 +105,10 @@ class Main extends React.Component { const styles = require('./Main.scss'); const appPrefix = ''; const logo = require('./logo.svg'); + const github = require('./Github.svg'); + const discord = require('./Discord.svg'); + const mail = require('./mail.svg'); + const pixHeart = require('./pix-heart.svg'); const currentLocation = location.pathname; const currentActiveBlock = currentLocation.split('/')[1]; @@ -89,18 +128,18 @@ class Main extends React.Component { let accessKeyHtml = null; if (globals.accessKey === '' || globals.accessKey === null) { accessKeyHtml = ( - - - - - + + + ); } @@ -122,7 +161,7 @@ class Main extends React.Component {
-