Yarn workspaces
Summary: 1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code 2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later. Reviewed By: jknoxville Differential Revision: D20535782 fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
676d7bbd24
commit
863f89351e
117
desktop/app/src/chrome/UpdateIndicator.tsx
Normal file
117
desktop/app/src/chrome/UpdateIndicator.tsx
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {LauncherMsg} from '../reducers/application';
|
||||
import {colors, FlexRow, Glyph, styled} from 'flipper';
|
||||
import Tooltip from '../ui/components/Tooltip';
|
||||
import isProduction from '../utils/isProduction';
|
||||
import {
|
||||
checkForUpdate,
|
||||
VersionCheckResult,
|
||||
} from '../utils/publicVersionChecker';
|
||||
import {reportPlatformFailures} from '../utils/metrics';
|
||||
import React from 'react';
|
||||
import {shell} from 'electron';
|
||||
import config from '../utils/processConfig';
|
||||
|
||||
const Container = styled(FlexRow)({
|
||||
alignItems: 'center',
|
||||
marginLeft: 4,
|
||||
});
|
||||
|
||||
type Props = {
|
||||
launcherMsg: LauncherMsg;
|
||||
version: string;
|
||||
};
|
||||
|
||||
type State = {
|
||||
versionCheckResult: VersionCheckResult;
|
||||
};
|
||||
|
||||
function getSeverityColor(severity: 'warning' | 'error'): string {
|
||||
switch (severity) {
|
||||
case 'warning':
|
||||
return colors.light30;
|
||||
case 'error':
|
||||
return colors.cherry;
|
||||
}
|
||||
}
|
||||
|
||||
export default class UpdateIndicator extends React.PureComponent<Props, State> {
|
||||
state = {
|
||||
versionCheckResult: {kind: 'up-to-date'} as VersionCheckResult,
|
||||
};
|
||||
|
||||
renderMessage(): React.ReactNode {
|
||||
if (this.props.launcherMsg.message.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<span title={this.props.launcherMsg.message}>
|
||||
<Glyph
|
||||
color={getSeverityColor(this.props.launcherMsg.severity)}
|
||||
name="caution-triangle"
|
||||
/>
|
||||
</span>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
renderUpdateIndicator(): React.ReactNode {
|
||||
const result = this.state.versionCheckResult;
|
||||
if (result.kind !== 'update-available') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const container = (
|
||||
<Container>
|
||||
<span onClick={() => shell.openExternal(result.url)}>
|
||||
<Glyph
|
||||
color={getSeverityColor(this.props.launcherMsg.severity)}
|
||||
name="caution-triangle"
|
||||
/>
|
||||
</span>
|
||||
</Container>
|
||||
);
|
||||
return (
|
||||
<Tooltip
|
||||
options={{position: 'toLeft'}}
|
||||
title={`Update to Flipper v${result.version} available. Click to download.`}
|
||||
children={container}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (isProduction() && config().launcherEnabled) {
|
||||
reportPlatformFailures(
|
||||
checkForUpdate(this.props.version).then(res => {
|
||||
if (res.kind === 'error') {
|
||||
console.warn('Version check failure: ', res.msg);
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
this.setState({versionCheckResult: res});
|
||||
}),
|
||||
'publicVersionCheck',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
return (
|
||||
<>
|
||||
{this.renderMessage()}
|
||||
{this.renderUpdateIndicator()}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user