-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use'template' icons for tray when macOS
- Loading branch information
1 parent
62bfec0
commit a258115
Showing
1 changed file
with
27 additions
and
4 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import fs from 'fs'; | ||
import pth from 'path'; | ||
import os from 'os'; | ||
|
||
import Electron from 'electron'; | ||
import yaml from 'yaml'; | ||
|
@@ -51,8 +52,30 @@ export class Tray { | |
|
||
protected kubernetesState = State.STOPPED; | ||
|
||
private isMacOs = () => { | ||
return os.platform() === 'darwin'; | ||
} | ||
|
||
private trayIconsMacOs = { | ||
stopped: 'icons/[email protected]', | ||
starting: 'icons/[email protected]', | ||
started: 'icons/[email protected]', | ||
stopping: 'icons/[email protected]', | ||
error: 'icons/[email protected]' | ||
} | ||
|
||
private trayIcons = { | ||
stopped: '', | ||
starting: 'icons/logo-square-bw.png', | ||
started: 'icons/logo-square.png', | ||
stopping: '', | ||
error: 'icons/logo-square-red.png' | ||
} | ||
|
||
private trayIconSet = this.isMacOs() ? this.trayIconsMacOs : this.trayIcons | ||
|
||
constructor() { | ||
this.trayMenu = new Electron.Tray(resources.get('icons/logo-square-bw.png')); | ||
this.trayMenu = new Electron.Tray(resources.get(this.trayIconSet.starting)); | ||
this.trayMenu.setToolTip('Rancher Desktop'); | ||
|
||
// Discover k8s contexts | ||
|
@@ -159,18 +182,18 @@ export class Tray { | |
}; | ||
|
||
let icon = resources.get('icons/kubernetes-icon-black.png'); | ||
let logo = resources.get('icons/logo-square-bw.png'); | ||
let logo = resources.get(this.trayIconSet.starting); | ||
|
||
if (this.kubernetesState === State.STARTED) { | ||
icon = resources.get('/icons/kubernetes-icon-color.png'); | ||
logo = resources.get('/icons/logo-square.png'); | ||
logo = resources.get(this.trayIconSet.started); | ||
// Update the contexts as a new kubernetes context will be added | ||
this.updateContexts(); | ||
} else if (this.kubernetesState === State.ERROR) { | ||
// For licensing reasons, we cannot just tint the Kubernetes logo. | ||
// Here we're using an icon from GitHub's octicons set. | ||
icon = resources.get('/icons/issue-opened-16.png'); | ||
logo = resources.get('/icons/logo-square-red.png'); | ||
logo = resources.get(this.trayIconSet.error); | ||
} | ||
|
||
const stateMenu = this.contextMenuItems.find(item => item.id === 'state'); | ||
|