Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update button #4606

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"mocha": "^10.7.3",
"mocha-test-container-support": "0.2.0",
"npm-run-all2": "^7.0.0",
"puppeteer": "^23.6.0",
"puppeteer": "^23.6.1",
"react-svg-loader": "^3.0.3",
"react-test-renderer": "^16.14.0",
"sinon": "^17.0.1",
Expand Down
12 changes: 12 additions & 0 deletions client/src/app/status-bar/StatusBar.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
--status-bar-active-font-color: var(--color-grey-225-10-15);
--status-bar-active-icon-font-color: var(--color-grey-225-10-35);
--status-bar-font-size: var(--font-size-default);
--status-bar-primary-background-color: var(--color-blue-205-100-45);
--status-bar-primary-hover-background-color: var(--color-blue-205-100-40);
}

:local(.StatusBar) {
Expand Down Expand Up @@ -95,4 +97,14 @@
.btn + .btn {
margin-left: 1px;
}

.btn--primary {
background-color: var(--status-bar-primary-background-color);
color: var(--color-white);
}

.btn--primary:hover,
.btn--primary:focus {
background-color: var(--status-bar-primary-hover-background-color);
}
}
2 changes: 1 addition & 1 deletion client/src/plugins/report-feedback/ReportFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ReportFeedback extends PureComponent {

return (
<Fragment>
<Fill slot="status-bar__app" group="9_feedback">
<Fill slot="status-bar__app" group="8_feedback">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change? It moves buttons around (on the status bar).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To accomodate the new Update button

<button
className={ classNames('btn', { 'btn--active': open }, css.ReportFeedback) }
title="Provide Feedback"
Expand Down
4 changes: 2 additions & 2 deletions client/src/plugins/update-checks/NewVersionInfoView.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class NewVersionInfoView extends PureComponent {
latestVersionInfo,
currentVersion,
onClose,
onGoToDownloadPage,
onOpenDownloadUrl,
onOpenPrivacyPreferences,
updateChecksEnabled
} = this.props;
Expand Down Expand Up @@ -95,7 +95,7 @@ class NewVersionInfoView extends PureComponent {
<button className="btn btn-secondary" onClick={ onClose }> { BUTTON_NEGATIVE } </button>
<button
className="btn btn-primary"
onClick={ onGoToDownloadPage }
onClick={ onOpenDownloadUrl }
autoFocus
> { BUTTON_POSITIVE } </button>
</div>
Expand Down
52 changes: 52 additions & 0 deletions client/src/plugins/update-checks/UpdateAvailableOverlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

import React from 'react';

import { Overlay, Section } from '../../shared/ui';

import * as css from './UpdateAvailableOverlay.less';

const OFFSET = { right: 0 };

export function UpdateAvailableOverlay(props) {
return (

Check warning on line 20 in client/src/plugins/update-checks/UpdateAvailableOverlay.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateAvailableOverlay.js#L20

Added line #L20 was not covered by tests
<Overlay id="update-available-overlay"
anchor={ props.anchor }
onClose={ props.onClose }
offset={ OFFSET }>
<UpdateAvailableSection
version={ props.version }
onOpenNewVersionInfoView={ props.onOpenNewVersionInfoView }
onOpenDownloadUrl={ props.onOpenDownloadUrl } />
</Overlay>
);
}

function UpdateAvailableSection(props) {
const {
onOpenDownloadUrl,
onOpenNewVersionInfoView,
version
} = props;

Check warning on line 38 in client/src/plugins/update-checks/UpdateAvailableOverlay.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateAvailableOverlay.js#L38

Added line #L38 was not covered by tests

return (

Check warning on line 40 in client/src/plugins/update-checks/UpdateAvailableOverlay.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateAvailableOverlay.js#L40

Added line #L40 was not covered by tests
<Section className={ css.UpdateAvailableOverlay } maxHeight="500px">
<Section.Header>
Update available
</Section.Header>
<Section.Body>
<p>Camunda Desktop Modeler {version} is available for use.</p>
<a className="links" onClick={ onOpenDownloadUrl }>Update now</a>
<a className="links" onClick={ onOpenNewVersionInfoView }>Learn what&apos;s new</a>
</Section.Body>
</Section>
);
}
9 changes: 9 additions & 0 deletions client/src/plugins/update-checks/UpdateAvailableOverlay.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:local(.UpdateAvailableOverlay) {

.links {
display: block;
padding: 2px;
cursor: pointer;
}
}

94 changes: 73 additions & 21 deletions client/src/plugins/update-checks/UpdateChecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@

import Flags, { DISABLE_REMOTE_INTERACTION, FORCE_UPDATE_CHECKS, UPDATE_SERVER_URL } from '../../util/Flags';

import { Fill } from '../../app/slot-fill';

import Metadata from '../../util/Metadata';

import { UpdateAvailableOverlay } from './UpdateAvailableOverlay';

const log = debug('UpdateChecks');

class NoopComponent extends PureComponent {
Expand All @@ -45,7 +49,6 @@

constructor(props) {
super(props);

if (Flags.get(DISABLE_REMOTE_INTERACTION)) {
return new NoopComponent();
}
Expand All @@ -54,8 +57,12 @@

this.updateChecksAPI = new UpdateChecksAPI(updateServerUrl);

this.updateAvailableButtonRef = React.createRef(null);

this.state = {
showModal: false
newVersionInfoViewOpen: false,
updateAvailable: false,
updateAvailableOverlayOpen: false
};
}

Expand All @@ -72,7 +79,6 @@
subscribe('updateChecks.execute', async () => {

const updateCheckInfo = await config.get(UPDATE_CHECKS_CONFIG_KEY) || {};

self.checkLatestVersion({
...updateCheckInfo,
stagedRollout: false,
Expand Down Expand Up @@ -212,7 +218,10 @@
return this.checkSkipped('not-due');
}

return this.checkLatestVersion(updateCheckInfo);
return this.checkLatestVersion({
...updateCheckInfo,
latestVersion: `v${Metadata.data.version}`
});
}

async handleUpdateCheckSuccess(update, silentCheck = true) {
Expand Down Expand Up @@ -254,19 +263,24 @@

this.setState({
currentVersion,
updateAvailable : true,
latestVersionInfo: {
latestVersion,
downloadURL,
releases
},
updateChecksEnabled,
showModal: true
});

if (!silentCheck) {
this.setState({
newVersionInfoViewOpen: true
});
}

}

async checkLatestVersion(updateCheckInfo, silentCheck = true) {

log('Checking for update');

const {
Expand Down Expand Up @@ -316,13 +330,31 @@
return Math.abs(Date.now() - previousTime) >= TWENTY_FOUR_HOURS_MS;
}

onClose = () => {
this.setState({
showModal: false
});
openNewVersionInfoView = () => {
this.setState({ newVersionInfoViewOpen: true });

Check warning on line 334 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L334

Added line #L334 was not covered by tests
};

onGoToDownloadPage = () => {
closeNewVersionInfoView = () => {
this.setState({ newVersionInfoViewOpen: false });

Check warning on line 338 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L338

Added line #L338 was not covered by tests
};

toggleUpdateAvailableOverlay = () => {
if (this.state.updateAvailableOverlayOpen) {
this.closeUpdateAvailableOverlay();

Check warning on line 343 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L342-L343

Added lines #L342 - L343 were not covered by tests
} else {
this.openUpdateAvailableOverlay();

Check warning on line 345 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L345

Added line #L345 was not covered by tests
}
};

openUpdateAvailableOverlay = () => {
this.setState({ updateAvailableOverlayOpen: true });

Check warning on line 350 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L350

Added line #L350 was not covered by tests
};

closeUpdateAvailableOverlay = () => {
this.setState({ updateAvailableOverlayOpen: false });

Check warning on line 354 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L354

Added line #L354 was not covered by tests
};

onOpenDownloadUrl = () => {
const {
latestVersionInfo
} = this.state;
Expand All @@ -332,30 +364,50 @@
} = this.props;

_getGlobal('backend').send('external:open-url', { url: latestVersionInfo.downloadURL });
this.onClose();

this.closeNewVersionInfoView();

Check warning on line 368 in client/src/plugins/update-checks/UpdateChecks.js

View check run for this annotation

Codecov / codecov/patch

client/src/plugins/update-checks/UpdateChecks.js#L368

Added line #L368 was not covered by tests
};

render() {
const {
showModal,
newVersionInfoViewOpen,
latestVersionInfo,
currentVersion,
updateChecksEnabled
updateChecksEnabled,
updateAvailableOverlayOpen,
updateAvailable
} = this.state;

return (
<React.Fragment>
{showModal && (
<NewVersionInfoView
onClose={ this.onClose }
onGoToDownloadPage={ this.onGoToDownloadPage }
{
updateAvailable && <Fill slot="status-bar__app" group="9_update_checks">
<button
className="btn btn--primary"
title="Toggle update info"
onClick={ this.toggleUpdateAvailableOverlay }
ref={ this.updateAvailableButtonRef }>Update</button>
</Fill>
}
{
updateAvailableOverlayOpen && <UpdateAvailableOverlay
anchor={ this.updateAvailableButtonRef.current }
onOpenNewVersionInfoView={ this.openNewVersionInfoView }
onOpenDownloadUrl={ this.onOpenDownloadUrl }
onClose={ this.closeUpdateAvailableOverlay }
version={ latestVersionInfo.latestVersion } />
}
{
newVersionInfoViewOpen && <NewVersionInfoView
onClose={ this.closeNewVersionInfoView }
onOpenDownloadUrl={ this.onOpenDownloadUrl }
onOpenPrivacyPreferences={ this.openPrivacyPreferences }
latestVersionInfo={ latestVersionInfo }
updateChecksEnabled={ updateChecksEnabled }
currentVersion={ currentVersion }
/>
)}
currentVersion={ currentVersion } />
}
</React.Fragment>

);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ describe('<NewVersionInfoView>', function() {

it('should go to download page', function() {

const onGoToDownloadPageSpy = spy();
const onOpenDownloadUrlSpy = spy();

const component = shallow(
<NewVersionInfoView latestVersionInfo={ {} } onGoToDownloadPage={ onGoToDownloadPageSpy } />
<NewVersionInfoView latestVersionInfo={ {} } onOpenDownloadUrl={ onOpenDownloadUrlSpy } />
);

const positiveButton = component.find('.btn-primary');

positiveButton.simulate('click');

expect(onGoToDownloadPageSpy).to.have.been.called;
expect(onOpenDownloadUrlSpy).to.have.been.called;
});


Expand Down
Loading