Просмотр исходного кода

Merge pull request #363 from smiclea/licence-expired

Don't show expiration info if licence is expired
Dorin Paslaru 7 лет назад
Родитель
Сommit
e28bd076cf
1 измененных файлов с 17 добавлено и 6 удалено
  1. 17 6
      src/components/organisms/Licence/Licence.jsx

+ 17 - 6
src/components/organisms/Licence/Licence.jsx

@@ -14,7 +14,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 // @flow
 // @flow
 
 
-import React from 'react'
+import * as React from 'react'
 import { observer } from 'mobx-react'
 import { observer } from 'mobx-react'
 import styled, { css } from 'styled-components'
 import styled, { css } from 'styled-components'
 import moment from 'moment'
 import moment from 'moment'
@@ -247,6 +247,21 @@ class LicenceC extends React.Component<Props, State> {
     )
     )
   }
   }
 
 
+  renderLicenceStatusText(info: Licence): React.Node {
+    let currentPeriod = moment(info.currentPeriodEnd)
+    let days = currentPeriod.diff(new Date(), 'days')
+    if (days < 0) {
+      return 'Please contact Cloudbase Solutions with you Appliance ID in order to obtain a Coriolis® licence'
+    }
+    return (
+      <LicenceRowDescription>
+        Coriolis® Licence is active until&nbsp;
+        {currentPeriod.format('DD MMM YYYY')}
+        &nbsp;({days} days from now).
+      </LicenceRowDescription>
+    )
+  }
+
   renderLicenceInfo(info: Licence) {
   renderLicenceInfo(info: Licence) {
     return (
     return (
       <LicenceInfoWrapper>
       <LicenceInfoWrapper>
@@ -259,11 +274,7 @@ class LicenceC extends React.Component<Props, State> {
                 onClick={() => { this.handleAddLicenceClick() }}
                 onClick={() => { this.handleAddLicenceClick() }}
               >Add Licence</LicenceLink>
               >Add Licence</LicenceLink>
             </LicenceRowLabel>
             </LicenceRowLabel>
-            <LicenceRowDescription>
-              Coriolis® Licence is active until&nbsp;
-              {moment(info.currentPeriodEnd).format('DD MMM YYYY')}
-              &nbsp;({moment(info.currentPeriodEnd).diff(new Date(), 'days')} days from now).
-            </LicenceRowDescription>
+            {this.renderLicenceStatusText(info)}
           </LicenceRowContent>
           </LicenceRowContent>
         </LicenceRow>
         </LicenceRow>
         <LicenceRow>
         <LicenceRow>