From c535543922a7e15dbfe0a1e40f846cb89b6cedcc Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Tue, 14 Jan 2020 18:27:47 +0100 Subject: [PATCH] Convert featured-project.jsx to typescript Change-type: patch --- .../featured-project/featured-project.jsx | 57 ------------------- .../featured-project/featured-project.tsx | 57 +++++++++++++++++++ lib/gui/app/pages/main/MainPage.tsx | 2 +- 3 files changed, 58 insertions(+), 58 deletions(-) delete mode 100644 lib/gui/app/components/featured-project/featured-project.jsx create mode 100644 lib/gui/app/components/featured-project/featured-project.tsx diff --git a/lib/gui/app/components/featured-project/featured-project.jsx b/lib/gui/app/components/featured-project/featured-project.jsx deleted file mode 100644 index 24bfd6a6..00000000 --- a/lib/gui/app/components/featured-project/featured-project.jsx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 balena.io - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict' - -const React = require('react') -const propTypes = require('prop-types') -const SafeWebview = require('../safe-webview/safe-webview.jsx') -const settings = require('../../models/settings') -const analytics = require('../../modules/analytics') - -class FeaturedProject extends React.Component { - constructor (props) { - super(props) - - this.state = { - endpoint: null - } - } - - componentDidMount () { - return settings.load() - .then(() => { - const endpoint = settings.get('featuredProjectEndpoint') || 'https://assets.balena.io/etcher-featured/index.html' - this.setState({ endpoint }) - }) - .catch(analytics.logException) - } - - render () { - return (this.state.endpoint) ? ( - - - ) : null - } -} - -FeaturedProject.propTypes = { - onWebviewShow: propTypes.func -} - -module.exports = FeaturedProject diff --git a/lib/gui/app/components/featured-project/featured-project.tsx b/lib/gui/app/components/featured-project/featured-project.tsx new file mode 100644 index 00000000..f24c7531 --- /dev/null +++ b/lib/gui/app/components/featured-project/featured-project.tsx @@ -0,0 +1,57 @@ +/* + * Copyright 2016 balena.io + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; + +import * as settings from '../../models/settings'; +import * as analytics from '../../modules/analytics'; +import * as SafeWebview from '../safe-webview/safe-webview.jsx'; + +interface FeaturedProjectProps { + onWebviewShow: (isWebviewShowing: boolean) => void; +} + +interface FeaturedProjectState { + endpoint: string | null; +} + +export class FeaturedProject extends React.Component< + FeaturedProjectProps, + FeaturedProjectState +> { + constructor(props: FeaturedProjectProps) { + super(props); + this.state = { endpoint: null }; + } + + public async componentDidMount() { + try { + await settings.load(); + const endpoint = + settings.get('featuredProjectEndpoint') || + 'https://assets.balena.io/etcher-featured/index.html'; + this.setState({ endpoint }); + } catch (error) { + analytics.logException(error); + } + } + + public render() { + return this.state.endpoint ? ( + + ) : null; + } +} diff --git a/lib/gui/app/pages/main/MainPage.tsx b/lib/gui/app/pages/main/MainPage.tsx index e7e028f0..ea7cc8f4 100644 --- a/lib/gui/app/pages/main/MainPage.tsx +++ b/lib/gui/app/pages/main/MainPage.tsx @@ -20,7 +20,7 @@ import * as path from 'path'; import * as React from 'react'; import { Button } from 'rendition'; -import * as FeaturedProject from '../../components/featured-project/featured-project'; +import { FeaturedProject } from '../../components/featured-project/featured-project'; import FinishPage from '../../components/finish/finish'; import * as ImageSelector from '../../components/image-selector/image-selector'; import * as ReducedFlashingInfos from '../../components/reduced-flashing-infos/reduced-flashing-infos';