refactor: Anbieterliste der Sync-Einstellungen als Modell
`SyncSettingsModel` (src/whiteboard/view/sync_settings_model.gd) baut die Anbieterliste aus der Build-Konfiguration: Google Drive nur mit OAuth-Zugangsdaten, Dropbox immer (damit ein Entwickler-Build die fehlende Konfiguration zeigt statt einer leeren Liste). Der Controller füllt sein Dropdown nur noch daraus. Test für die drei Fälle (nur Dropbox, mit Google, ohne Zugangsdaten) und die Suche per Id. Controller: 8.154 -> 8.142 Zeilen. Suite grün. Kein eigener Dialog-Schnitt an dieser Stelle: Der Sync-Dialog enthält Sync und Hub zusammen und hängt an Threads; eine Szene ohne verschobenes Verhalten wäre nur eine Existenzprüfung.
This commit is contained in:
parent
94ec11ad87
commit
5161869ec2
6 changed files with 82 additions and 22 deletions
|
|
@ -5690,25 +5690,13 @@ func _open_sync_settings_dialog() -> void:
|
|||
func _ensure_sync_provider_items() -> void:
|
||||
if sync_provider_option.item_count > 0:
|
||||
return
|
||||
var app := SyncAppConfig.load_config()
|
||||
var has_dropbox := SyncAppConfig.is_configured("dropbox", app)
|
||||
var has_google := SyncAppConfig.is_configured("google_drive", app)
|
||||
if not has_dropbox:
|
||||
# Developer build without app credentials: show Dropbox so the
|
||||
# missing configuration is visible instead of an empty dropdown.
|
||||
has_dropbox = true
|
||||
if has_dropbox:
|
||||
sync_provider_option.add_item("Dropbox", 0)
|
||||
sync_provider_option.set_item_metadata(
|
||||
sync_provider_option.item_count - 1,
|
||||
"dropbox"
|
||||
)
|
||||
if has_google:
|
||||
sync_provider_option.add_item("Google Drive", 1)
|
||||
sync_provider_option.set_item_metadata(
|
||||
sync_provider_option.item_count - 1,
|
||||
"google_drive"
|
||||
)
|
||||
var items := SyncSettingsModel.provider_items(
|
||||
SyncAppConfig.load_config()
|
||||
)
|
||||
for index: int in range(items.size()):
|
||||
var item: Dictionary = items[index]
|
||||
sync_provider_option.add_item(str(item["label"]), index)
|
||||
sync_provider_option.set_item_metadata(index, str(item["value"]))
|
||||
|
||||
|
||||
func _apply_sync_provider_to_ui(provider: String) -> void:
|
||||
|
|
|
|||
33
rinkplanner/src/whiteboard/view/sync_settings_model.gd
Normal file
33
rinkplanner/src/whiteboard/view/sync_settings_model.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class_name SyncSettingsModel
|
||||
extends RefCounted
|
||||
|
||||
## Content of the sync provider dropdown.
|
||||
##
|
||||
## Pure: the app configuration goes in, the list of selectable providers comes
|
||||
## out. Google Drive only appears when the build carries OAuth credentials;
|
||||
## Dropbox always appears, even without credentials, so a developer build shows
|
||||
## the missing configuration instead of an empty dropdown.
|
||||
|
||||
const PROVIDERS := [
|
||||
{"id": "dropbox", "label": "Dropbox", "always": true},
|
||||
{"id": "google_drive", "label": "Google Drive", "always": false},
|
||||
]
|
||||
|
||||
|
||||
## Returns `[{"label": String, "value": String}]`.
|
||||
static func provider_items(app: Dictionary) -> Array[Dictionary]:
|
||||
var items: Array[Dictionary] = []
|
||||
for provider: Dictionary in PROVIDERS:
|
||||
var id := str(provider["id"])
|
||||
if not bool(provider["always"]) and not SyncAppConfig.is_configured(id, app):
|
||||
continue
|
||||
items.append({"label": str(provider["label"]), "value": id})
|
||||
return items
|
||||
|
||||
|
||||
## Index of [param provider] in a list built by [method provider_items], or -1.
|
||||
static func index_of(items: Array, provider: String) -> int:
|
||||
for index: int in range(items.size()):
|
||||
if str((items[index] as Dictionary).get("value", "")) == provider:
|
||||
return index
|
||||
return -1
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dycuog2mepmfp
|
||||
|
|
@ -813,6 +813,30 @@ func _test_controller_wiring() -> void:
|
|||
"die Sync-Zusammenfassung nennt Gewinner und Konfliktarchiv"
|
||||
)
|
||||
|
||||
# SyncSettingsModel: Anbieterliste hängt an der Build-Konfiguration.
|
||||
var only_dropbox := SyncSettingsModel.provider_items({"dropbox_app_key": "key"})
|
||||
_check(
|
||||
only_dropbox.size() == 1
|
||||
and str(only_dropbox[0]["value"]) == "dropbox",
|
||||
"without Google credentials only Dropbox is offered"
|
||||
)
|
||||
var with_google := SyncSettingsModel.provider_items(
|
||||
{
|
||||
"dropbox_app_key": "key",
|
||||
"google_client_id": "id",
|
||||
"google_client_secret": "secret",
|
||||
}
|
||||
)
|
||||
_check(with_google.size() == 2, "Google Drive appears when configured")
|
||||
_check(
|
||||
SyncSettingsModel.index_of(with_google, "google_drive") == 1,
|
||||
"the provider list is searchable by id"
|
||||
)
|
||||
_check(
|
||||
SyncSettingsModel.provider_items({}).size() == 1,
|
||||
"Dropbox stays visible without credentials"
|
||||
)
|
||||
|
||||
# "Küren verwalten": rows expose open/delete, the music stay-check works.
|
||||
controller.sync_settings_dialog.hide()
|
||||
DirAccess.make_dir_recursive_absolute(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue