-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #577 from rak-phillip/bugfix/236-macos-tray-icons
Add new tray icons for macOS
- Loading branch information
Showing
6 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 readonly trayIconsMacOs = { | ||
stopped: 'icons/[email protected]', | ||
starting: 'icons/[email protected]', | ||
started: 'icons/[email protected]', | ||
stopping: 'icons/[email protected]', | ||
error: 'icons/[email protected]' | ||
} | ||
|
||
private readonly trayIcons = { | ||
stopped: '', | ||
starting: 'icons/logo-square-bw.png', | ||
started: 'icons/logo-square.png', | ||
stopping: '', | ||
error: 'icons/logo-square-red.png' | ||
} | ||
|
||
private readonly 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'); | ||
|