forked from superdesk/superdesk-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDESK-5220] Modal to show Highcharts license (superdesk#127)
* [SDESK-5220] Modal to show Highcharts license * Add client_config to server * Add config instructions to README * Update eslint package and config * Fix behave test * Improve highcharts client config structure
- Loading branch information
1 parent
ddfb09c
commit f2e76fc
Showing
13 changed files
with
309 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,63 @@ | ||
module.exports = require('superdesk-code-style'); | ||
const sharedConfigs = require('superdesk-code-style'); | ||
|
||
module.exports = Object.assign({}, sharedConfigs, { | ||
rules: Object.assign(sharedConfigs.rules, { | ||
'no-nested-ternary': 0, | ||
'no-unused-vars': 0, // marks typescript interfaces as unused vars | ||
'no-undef': 0, // marks interface properties as usages of undeclared variables | ||
|
||
// field names from back-end use camel-case for naming. | ||
// I'm not convinced it's worth using a bracket notation only to satisfy a lint rule | ||
'camelcase': 0, | ||
|
||
// doesn't make sense with many properties | ||
// 10 may use shorthand and one may be inline or reference differently named variable | ||
'object-shorthand': 0, | ||
|
||
// can make functions harder to read; forces into rewriting the function to insert a debugger | ||
'arrow-body-style': 0, | ||
|
||
// leaving up to developers. I prefer to quote external strings like css names, | ||
// but keep internal properties unquoted unless required | ||
'quote-props': 0, | ||
|
||
'newline-per-chained-call': ["error", {"ignoreChainWithDepth": 3}], | ||
}), | ||
parser: '@typescript-eslint/parser', | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
rules: { | ||
'react/prop-types': 0, // interfaces are used in TypeScript files | ||
'no-unused-vars': 0, | ||
'no-undef': 0, | ||
'comma-dangle': 0, | ||
'camelcase': 0, | ||
'object-shorthand': 0, | ||
'arrow-body-style': 0, | ||
'newline-per-chained-call': 0, | ||
'quote-props': 0, | ||
'arrow-body-style': 0, | ||
'max-len': 0, // handled by tslint | ||
|
||
"comma-dangle": ["error", { | ||
"arrays": "always-multiline", | ||
"objects": "always-multiline", | ||
"imports": "always-multiline", | ||
"exports": "always-multiline", | ||
"functions": "always-multiline" | ||
}], | ||
|
||
|
||
// allow calling hasOwnProperty | ||
"no-prototype-builtins": 0, | ||
}, | ||
}, | ||
{ | ||
files: ['*.d.ts'], | ||
rules: { | ||
'spaced-comment': 0, | ||
}, | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* eslint-disable react/no-multi-comp */ | ||
|
||
import React from 'react'; | ||
|
||
import {appConfig} from 'appConfig'; | ||
|
||
import hc from 'highcharts'; | ||
|
||
import {IAnalyticsConfig} from '../interfaces'; | ||
import {superdeskApi} from '../superdeskApi'; | ||
|
||
interface IProps { | ||
closeModal(): void | ||
} | ||
|
||
class HighchartsLicenseModal extends React.PureComponent<IProps> { | ||
render() { | ||
const { | ||
Modal, | ||
ModalBody, | ||
ModalFooter, | ||
} = superdeskApi.components; | ||
const gettext = superdeskApi.localization.gettext; | ||
const config: IAnalyticsConfig = appConfig as IAnalyticsConfig; | ||
const highchartsVersionLink = `https://www.highcharts.com/blog/changelog/#highcharts-v${hc.version}`; | ||
const license = config.highcharts?.license ?? {}; | ||
const licenseType = license.type ?? gettext('OEM'); | ||
|
||
return ( | ||
<Modal> | ||
<div className="modal__header modal__header--about"> | ||
<button className="modal__close pull-right" onClick={this.props.closeModal}> | ||
<i className="icon-close-small" /> | ||
</button> | ||
<h2 style={{color: 'white'}}>{gettext('Highcharts {{licenseType}} License', {licenseType})}</h2> | ||
</div> | ||
<ModalBody> | ||
<div> | ||
<p>{gettext('The use of Highcharts is provided under a license with the following details:')}</p> | ||
</div> | ||
<div> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td>{gettext('License Type')}:</td> | ||
<td>{licenseType}</td> | ||
</tr> | ||
{license.licensee && ( | ||
<tr> | ||
<td>{gettext('Licensee:')}</td> | ||
<td>{license.licensee}</td> | ||
</tr> | ||
)} | ||
{license.contact && ( | ||
<tr> | ||
<td>{gettext('Licensee Contact:')}</td> | ||
<td> | ||
<a href={`mailto:${license.contact}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
{license.contact} | ||
</a> | ||
</td> | ||
</tr> | ||
)} | ||
{license.id && ( | ||
<tr> | ||
<td>{gettext('License ID:')}</td> | ||
<td>{license.id}</td> | ||
</tr> | ||
)} | ||
{license.customer_id && ( | ||
<tr> | ||
<td>{gettext('Customer Installation No.:')}</td> | ||
<td>{license.customer_id}</td> | ||
</tr> | ||
)} | ||
{license.expiry && ( | ||
<tr> | ||
<td>{gettext('Expiry Date:')}</td> | ||
<td>{license.expiry}</td> | ||
</tr> | ||
)} | ||
<tr> | ||
<td>{gettext('Installed Version:')}</td> | ||
<td> | ||
<a href={highchartsVersionLink} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
v{hc.version} | ||
</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</ModalBody> | ||
<ModalFooter> | ||
<button className="btn btn--primary" onClick={this.props.closeModal} > | ||
{gettext('Close')} | ||
</button> | ||
</ModalFooter> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
function showHighchartsModal(): void { | ||
superdeskApi.ui.showModal(HighchartsLicenseModal); | ||
} | ||
|
||
export class HighchartsLicense extends React.PureComponent { | ||
render() { | ||
return ( | ||
<button className="btn btn--success btn--icon-only btn--hollow" | ||
data-sd-tooltip="Highcharts License" | ||
data-flow="left" | ||
onClick={showHighchartsModal} | ||
> | ||
<i className="icon-info-sign" /> | ||
</button> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {HighchartsLicense} from './HighchartsLicense'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {ISuperdeskGlobalConfig} from 'superdesk-api'; | ||
|
||
export interface IAnalyticsConfig extends ISuperdeskGlobalConfig { | ||
highcharts?: { | ||
license?: { | ||
id?: string; | ||
type?: string; | ||
licensee?: string; | ||
contact?: string; | ||
customer_id?: string; | ||
expiry?: string; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {ISuperdesk} from 'superdesk-api'; | ||
|
||
// will be set asynchronously on planning module start | ||
// members can't be accessed in root module scope synchronously | ||
|
||
// DO NOT USE OUTSIDE .ts OR .tsx FILES | ||
// because it would make it harder to find and update usages when API changes | ||
|
||
export const superdeskApi = {} as ISuperdesk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path='../../node_modules/superdesk-core/scripts/core/superdesk-api.d.ts' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.