-
Notifications
You must be signed in to change notification settings - Fork 997
fix(tray): simplify disconnected account menu #10461
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
|
|
||
| #pragma once | ||
|
|
||
| #import <Cocoa/Cocoa.h> | ||
|
|
||
| #import "ncaccountrow.h" | ||
|
|
||
|
|
@@ -29,6 +29,8 @@ | |
| - (void)openActivitiesForIndex:(int)index; | ||
| /** @brief Closes the popups and reveals the given account's local folder (or file provider domain) in Finder. */ | ||
| - (void)openLocalFolderForIndex:(int)index; | ||
| /** @brief Closes the popups and starts the sign-in flow for the given account. */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For disconnected but not signed-out accounts, such as network, maintenance, or configuration failures, AGENTS.md reference: AGENTS.md:L83-L87 Useful? React with 👍 / 👎. |
||
| - (void)reconnectForIndex:(int)index; | ||
| /** @brief Closes the popups and opens the Assistant window for the given account. */ | ||
| - (void)openAssistantForIndex:(int)index; | ||
| /** @brief Closes the popups and opens the Search window for the given account. */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: GPL-2.0-or-later | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <array> | ||
| #include <span> | ||
|
|
||
| namespace OCC { | ||
|
|
||
| /** | ||
| * @brief Defines which account-menu content is relevant for the connection state. | ||
| */ | ||
| class TrayAccountMenuPolicy | ||
| { | ||
| public: | ||
| /** @brief Semantic entries used by the disconnected account menu. */ | ||
| enum class Entry { | ||
| LocalFolder, | ||
| Separator, | ||
| Reconnect, | ||
| }; | ||
|
|
||
| /** @brief Account operation selected for the reconnect action. */ | ||
| enum class ReconnectMode { | ||
| None, | ||
| SignIn, | ||
| RetryConnection, | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Creates the menu policy for an account. | ||
| * @param canReconnect Whether the account supports signing in, which excludes public shares. | ||
| */ | ||
| explicit constexpr TrayAccountMenuPolicy(const bool isConnected, const bool canReconnect) | ||
| : _isConnected(isConnected) | ||
| , _canReconnect(canReconnect) | ||
| { | ||
| } | ||
|
|
||
| /** @brief Whether server-backed account sections should be shown. */ | ||
|
Check warning on line 43 in src/gui/tray/trayaccountmenupolicy.h
|
||
| [[nodiscard]] constexpr bool showConnectedSections() const | ||
| { | ||
| return _isConnected; | ||
| } | ||
|
|
||
| /** @brief Ordered entries to show instead of server-backed sections. */ | ||
|
Check warning on line 49 in src/gui/tray/trayaccountmenupolicy.h
|
||
| [[nodiscard]] constexpr std::span<const Entry> disconnectedEntries() const | ||
| { | ||
| if (_isConnected) { | ||
| return {}; | ||
| } | ||
| if (_canReconnect) { | ||
| return disconnectedReconnectEntries; | ||
| } | ||
| return disconnectedEntriesWithoutReconnect; | ||
| } | ||
|
|
||
| /** @brief Whether opening the menu should request fresh server-backed previews. */ | ||
| [[nodiscard]] constexpr bool fetchActivityPreview() const | ||
| { | ||
| return _isConnected; | ||
| } | ||
|
|
||
| /** @brief Selects the account operation behind the reconnect menu action. */ | ||
| [[nodiscard]] static constexpr ReconnectMode reconnectMode( | ||
| const bool isConnected, | ||
| const bool isSignedOut, | ||
| const bool canReconnect) | ||
| { | ||
| if (isConnected || !canReconnect) { | ||
| return ReconnectMode::None; | ||
| } | ||
| return isSignedOut | ||
| ? ReconnectMode::SignIn | ||
| : ReconnectMode::RetryConnection; | ||
| } | ||
|
|
||
| private: | ||
| static constexpr std::array disconnectedReconnectEntries{ | ||
| Entry::LocalFolder, | ||
| Entry::Separator, | ||
| Entry::Reconnect, | ||
| }; | ||
| static constexpr std::array disconnectedEntriesWithoutReconnect{ | ||
| Entry::LocalFolder, | ||
| }; | ||
|
|
||
| bool _isConnected; | ||
| bool _canReconnect; | ||
| }; | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.