AboutModal.jsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. Copyright (C) 2019 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. // @flow
  15. import React from 'react'
  16. import { observer } from 'mobx-react'
  17. import styled from 'styled-components'
  18. import logger from '../../../utils/ApiLogger'
  19. import Modal from '../../molecules/Modal/Modal'
  20. import LicenceComponent from '../../organisms/Licence'
  21. import Palette from '../../styleUtils/Palette'
  22. import StyleProps from '../../styleUtils/StyleProps'
  23. import licenceStore from '../../../stores/LicenceStore'
  24. import logoImage from './images/coriolis-logo.svg'
  25. const Wrapper = styled.div`
  26. display: flex;
  27. flex-direction: column;
  28. align-items: center;
  29. justify-content: center;
  30. padding: 60px 0 32px 0;
  31. position: relative;
  32. height: 100%;
  33. min-height: 0;
  34. `
  35. const Gradient = styled.div`
  36. position: absolute;
  37. height: 100%;
  38. max-height: 230px;
  39. top: 0;
  40. width: 100%;
  41. background: linear-gradient(#A7B0CA, #FFFFFF);
  42. `
  43. const Content = styled.div`
  44. z-index: 1;
  45. display: flex;
  46. flex-direction: column;
  47. align-items: center;
  48. width: 100%;
  49. height: 100%;
  50. min-height: 0;
  51. `
  52. const AboutContentWrapper = styled.div``
  53. const Logo = styled.div`
  54. width: 362px;
  55. ${StyleProps.exactHeight('71px')}
  56. background: url('${logoImage}') center no-repeat;
  57. `
  58. const Text = styled.div`
  59. margin: 48px 0;
  60. color: ${Palette.grayscale[5]};
  61. font-size: 12px;
  62. `
  63. const TextLine = styled.div`
  64. display: flex;
  65. justify-content: center;
  66. margin-left: -6px;
  67. margin-top: 8px;
  68. &:first-child {
  69. margin-top: 0;
  70. }
  71. span, a {
  72. margin-left: 6px;
  73. }
  74. `
  75. const LinkMock = styled.span`
  76. text-decoration: underline;
  77. cursor: pointer;
  78. `
  79. type Props = {
  80. onRequestClose: () => void,
  81. }
  82. type State = {
  83. licenceAddMode: boolean,
  84. }
  85. @observer
  86. class AboutModal extends React.Component<Props, State> {
  87. state = {
  88. licenceAddMode: false,
  89. }
  90. componentWillMount() {
  91. licenceStore.loadVersion()
  92. licenceStore.loadLicenceInfo()
  93. }
  94. async handleAddLicence(licence: string) {
  95. await licenceStore.addLicence(licence)
  96. licenceStore.loadLicenceInfo()
  97. this.setState({ licenceAddMode: false })
  98. }
  99. render() {
  100. return (
  101. <Modal
  102. title="About"
  103. isOpen
  104. onRequestClose={() => { this.props.onRequestClose() }}
  105. >
  106. <Wrapper>
  107. {!this.state.licenceAddMode ? <Gradient /> : null}
  108. <Content>
  109. {!this.state.licenceAddMode ? (
  110. <AboutContentWrapper>
  111. <Logo />
  112. <Text>
  113. <TextLine>
  114. <LinkMock onClick={() => { logger.download() }} >Download Web UI Log</LinkMock>
  115. </TextLine>
  116. <TextLine>
  117. © {new Date().getFullYear()} Cloudbase Solutions. All Rights Reserved.
  118. </TextLine>
  119. </Text>
  120. </AboutContentWrapper>
  121. ) : null}
  122. <LicenceComponent
  123. licenceInfo={licenceStore.licenceInfo}
  124. loadingLicenceInfo={licenceStore.loadingLicenceInfo}
  125. onRequestClose={this.props.onRequestClose}
  126. addMode={this.state.licenceAddMode}
  127. onAddModeChange={licenceAddMode => { this.setState({ licenceAddMode }) }}
  128. onAddLicence={licence => { this.handleAddLicence(licence) }}
  129. addingLicence={licenceStore.addingLicence}
  130. />
  131. </Content>
  132. </Wrapper>
  133. </Modal>
  134. )
  135. }
  136. }
  137. export default AboutModal