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

custom sidebar item #1214

Open
wants to merge 6 commits into
base: Munki6dev
Choose a base branch
from
Open

Conversation

SteveKueng
Copy link
Contributor

we use Munki in combination with Intune.
To make it easier for users, I would like to integrate the company portal web directly into Munki.
As a possible solution I have built a custom sidebar item.
The title, icon and link of the custom sidebar item can be configured via ManagedInstalls.plist

ManagedInstalls.plist:
{
AppleSoftwareUpdatesOnly = 0;
CustonSidebarItem = {
icon = desktopcomputer;
link = "https://portal.manage.microsoft.com/devices";
title = "My Devices";
};
FollowHTTPRedirects = none;
IgnoreMiddleware = 0;
IgnoreSystemProxies = 0;
InstallAppleSoftwareUpdates = 0;
LastCheckDate = "2024-04-01 14:56:58 +0000";
LastCheckResult = 0;
LogFile = "/Library/Managed Installs/Logs/ManagedSoftwareUpdate.log";
LogToSyslog = 0;
LoggingLevel = 1;
ManagedInstallDir = "/Library/Managed Installs";
OldestUpdateDays = 0;
PendingUpdateCount = 0;
UseClientCertificate = 0;
}

defaults write /Library/Preferences/ManagedInstalls.plist CustonSidebarItem 'titleMy Deviceicondesktopcomputerlinkhttps://portal.manage.microsoft.com/devices'

SCR-20240401-pxyq

@@ -292,6 +294,15 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe

func loadInitialView() {
// Called by app delegate from applicationDidFinishLaunching:

// add custom link if nessesary
if let CustonSidebarItem = pref("CustonSidebarItem") as? Dictionary<String, String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to change the name to "CustomSidebarItem" in all occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must have missed it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's "CustonSidebarItem" pretty much everywhere, and should be "CustomSidebarItem".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OMG... you're right... I've been working on it for too long...

@@ -1070,7 +1088,8 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe
decisionHandler(.cancel)
return
}
if scheme == "mailto" || scheme == "http" || scheme == "https" {

if scheme == "mailto" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this then change the behavior for http/https links from other contexts, like in item descriptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure yet.
I'm still testing when and how this part triggers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Custom links that don't have target="_blank" would go though this code path, I'd think (Links in client customization, like the footer, the banners, and the (former) sidebar-now-link-strip)

@@ -1670,6 +1701,16 @@ extension MainWindowController: NSOutlineViewDelegate {
}
if let imageView = view?.imgView {
imageView.image = NSImage(named: NSImage.Name(icon))?.tint(color: .secondaryLabelColor)
if #available(macOS 11.0, *) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean if an admin has a custom sidebar item and the user is running < macOS 11?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SF symbol only works with macOS 11.0 and above. Therefore the restriction. With older systems no symbol is displayed.
That could definitely be solved a little better

Copy link
Contributor

@gregneagle gregneagle Apr 1, 2024

Choose a reason for hiding this comment

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

Or just declare no support for custom sidebar items on macOS < 11. (So no item(s) at all -- not weird broken items without icons)

@gregneagle
Copy link
Contributor

I like the general idea. I have a few questions and comments, some of which are above. As for the icon, what values are legal, and where is the icon sourced? This will need good documentation, and I expect people might want to provide a custom icon as well. I wonder if this (instead of being in preferences) might better "live" in the other customization resources for MSC.app...

@gregneagle
Copy link
Contributor

Once the door has been opened to custom sidebar items, I can see admins wanting multiple such items. Could this be easily implemented in a way that either supports multiple items now, or could be easily extended in the future? (This again maybe pushes the config into the custom client resources instead of ManagedInstalls preferences)

@SteveKueng
Copy link
Contributor Author

SF Symbols are currently used. These are integrated in the OS and can be specified in the configuration. https://developer.apple.com/sf-symbols/ (icon name is the SF symbol name)
I was thinking of using images specified by the admin, but that's challenging with light and dark mode...
The downside of SF symbol is that it only works from 11.0. Therefore the restriction. With older systems no symbol is displayed.

I have already thought about several links. They should be easy to implement.
You could simply specify an array and then display it.
I can only think of one section that is a bit more difficult to set dynamically.

@SteveKueng
Copy link
Contributor Author

Once the door has been opened to custom sidebar items, I can see admins wanting multiple such items. Could this be easily implemented in a way that either supports multiple items now, or could be easily extended in the future? (This again maybe pushes the config into the custom client resources instead of ManagedInstalls preferences)

How do you mean the configuration in a custom client resource? With a separate config?

@gregneagle
Copy link
Contributor

gregneagle commented Apr 1, 2024

How do you mean the configuration in a custom client resource? With a separate config?

Yes, in a new file in the client customization archive (https://github.com/munki/munki/wiki/Client-Customization)

It just seems to me that we already have a method to do some MSC customizations. This is a new MSC customization, and one can argue it should be defined in the same "place" as the other customizations

@SteveKueng
Copy link
Contributor Author

SteveKueng commented Apr 1, 2024

I have left it in the ManagedInstalls.plist for now.
One advantage of this is that you can work with MDM variables in the URLs, e.g. deviceid.

the customisation now includes an array with objects

defaults write /Library/Preferences/ManagedInstalls.plist CustomSidebarItems '
<array>
    <dict>
        <key>title</key>
        <string>My Device</string>
        <key>icon</key>
        <string>desktopcomputer</string>
        <key>link</key>
        <string>https://portal.manage.microsoft.com/devices/c319a32f-6f50-48c1-b1ca-953b42178648</string>
    </dict>
    <dict>
        <key>title</key>
        <string>All Devices</string>
        <key>icon</key>
        <string>macbook.and.iphone</string>
        <key>link</key>
        <string>https://portal.manage.microsoft.com/devices</string>
    </dict>
    <dict>
        <key>title</key>
        <string>Helpdesk</string>
        <key>icon</key>
        <string>questionmark.circle</string>
        <key>link</key>
        <string>https://portal.manage.microsoft.com/helpdesk</string>
    </dict>
    <dict>
        <key>title</key>
        <string>My Homepage</string>
        <key>icon</key>
        <string>book.pages</string>
        <key>link</key>
        <string>https://umb.ch</string>
    </dict>
</array>'


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants