Skip to content

Commit 168b01a

Browse files
committed
have a manual update button
Signed-off-by: Vikalp Rusia <53312141+VikalpRusia@users.noreply.github.com>
1 parent 3b172c6 commit 168b01a

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

pkg/rancher-desktop/components/UpdateStatus.vue

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
<div>
33
<div class="version">
44
<version />
5-
<rd-checkbox
6-
v-if="updatePossible"
7-
v-model="updatesEnabled"
8-
class="updatesEnabled"
9-
label="Check for updates automatically"
10-
:is-locked="autoUpdateLocked"
11-
/>
5+
<div v-if="updatePossible" class="check-updates">
6+
<rd-checkbox
7+
v-model="updatesEnabled"
8+
class="updatesEnabled"
9+
label="Check for updates automatically"
10+
:is-locked="autoUpdateLocked"
11+
/>
12+
<button
13+
class="btn role-secondary"
14+
@click="manuallyCheckUpdate"
15+
>
16+
<span v-if="isUpdateErrored">Retry Update</span>
17+
<span v-else>Check for Updates</span>
18+
</button>
19+
</div>
1220
</div>
1321
<card
1422
v-if="hasUpdate"
@@ -142,6 +150,10 @@ class UpdateStatus extends UpdateStatusProps {
142150
return this.updatesEnabled && !!this.updateState?.available;
143151
}
144152
153+
get isUpdateErrored() {
154+
return this.updateState?.error;
155+
}
156+
145157
get updateReady() {
146158
return this.hasUpdate && !!this.updateState?.downloaded && !this.updateState?.error;
147159
}
@@ -200,6 +212,10 @@ class UpdateStatus extends UpdateStatusProps {
200212
this.$emit('apply');
201213
}
202214
215+
manuallyCheckUpdate() {
216+
this.$emit('check-for-updates');
217+
}
218+
203219
get autoUpdateLocked() {
204220
return this.isAutoUpdateLocked;
205221
}
@@ -211,7 +227,8 @@ export default UpdateStatus;
211227
<style lang="scss" scoped>
212228
.version {
213229
display: flex;
214-
justify-content: space-between
230+
justify-content: space-between;
231+
align-items: center;
215232
}
216233
.update-notification {
217234
font-weight: 900;
@@ -223,6 +240,12 @@ export default UpdateStatus;
223240
margin-left: 2em;
224241
margin-right: 1em;
225242
}
243+
244+
.check-updates {
245+
display: flex;
246+
gap: 10px;
247+
align-items: center;
248+
}
226249
</style>
227250

228251
<style lang="scss">

pkg/rancher-desktop/main/update/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ Electron.ipcMain.on('update-apply', () => {
7272
autoUpdater.quitAndInstall();
7373
});
7474

75+
Electron.ipcMain.on('check-for-updates', () => {
76+
console.error('working');
77+
triggerUpdateCheck();
78+
});
79+
7580
function isLonghornUpdateInfo(info: UpdateInfo | LonghornUpdateInfo): info is LonghornUpdateInfo {
7681
return (info as LonghornUpdateInfo).nextUpdateTime !== undefined;
7782
}

pkg/rancher-desktop/pages/General.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:is-auto-update-locked="autoUpdateLocked"
2121
@enabled="onUpdateEnabled"
2222
@apply="onUpdateApply"
23+
@check-for-updates="onUpdateCheck"
2324
/>
2425
<hr>
2526
<telemetry-opt-in
@@ -100,6 +101,10 @@ export default {
100101
onUpdateState(event, state) {
101102
this.$data.updateState = state;
102103
},
104+
onUpdateCheck() {
105+
console.log('till here');
106+
ipcRenderer.send('check-for-updates');
107+
},
103108
updateTelemetry(value) {
104109
ipcRenderer.invoke('settings-write', { application: { telemetry: { enabled: value } } });
105110
},

pkg/rancher-desktop/typings/electron-ipc.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface IpcMainEvents {
3232
'update-state': () => void;
3333
// Quit and apply the update.
3434
'update-apply': () => void;
35+
'check-for-updates': () => void;
3536
// #endregion
3637

3738
// #region main/containerEvents

0 commit comments

Comments
 (0)