jellyflood/Swiftfin/Views/AdminDashboardView/ServerUsers/ServerUserSettings/ServerUserPermissionsView/ServerUserPermissionsView.swift
Joe Kribs 0025422634
[iOS & tvOS] Upgrade SDK to 10.10 (#1463)
* Buildable!

* Update file names.

* Default sort to sort name NOT name.

* SessionInfoDto vs SessionInfo

* Targetting

* Fix many invalid `ItemSortBy` existing. Will need to revisit later to see which can still be used!

* ExtraTypes Patch.

* Move from Binding to OnChange. Tested and Working.

* Update README.md

Update README to use 10.10.6. Bumped up from 10.8.13

* Update to Main on https://github.com/jellyfin/jellyfin-sdk-swift.git

* Now using https://github.com/jellyfin/jellyfin-sdk-swift.git again!

* Paths.getUserViews() userId moved to parameters

* Fix ViewModels where -Dto suffixes were removed by https://github.com/jellyfin/Swiftfin/pull/1465 auto-merge.

* SupportedCaseIterable

* tvOS supportedCases fixes for build issue.

* cleanup

* update API to 0.5.1 and correct VideoRangeTypes.

* Remove deviceProfile.responseProfiles = videoPlayer.responseProfiles

* Second to last adjustment:
Resolved: // TODO: 10.10 - Filter to only valid SortBy's for each BaseItemKind.
Last outstanding item: // TODO: 10.10 - What should authenticationProviderID & passwordResetProviderID be?

* Trailers itemID must precede userID

* Force User Policy to exist.

---------

Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
2025-04-06 23:42:47 -04:00

117 lines
3.0 KiB
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//
import Combine
import Defaults
import JellyfinAPI
import SwiftUI
struct ServerUserPermissionsView: View {
// MARK: - Observed & Environment Objects
@EnvironmentObject
private var router: BasicNavigationViewCoordinator.Router
@ObservedObject
var viewModel: ServerUserAdminViewModel
// MARK: - Policy Variable
@State
private var tempPolicy: UserPolicy
// MARK: - Error State
@State
private var error: Error?
// MARK: - Initializer
init(viewModel: ServerUserAdminViewModel) {
self._viewModel = ObservedObject(wrappedValue: viewModel)
guard let policy = viewModel.user.policy else {
preconditionFailure("User policy cannot be empty.")
}
self.tempPolicy = policy
}
// MARK: - Body
var body: some View {
contentView
.navigationTitle(L10n.permissions)
.navigationBarTitleDisplayMode(.inline)
.navigationBarCloseButton {
router.dismissCoordinator()
}
.topBarTrailing {
if viewModel.backgroundStates.contains(.updating) {
ProgressView()
}
Button(L10n.save) {
if tempPolicy != viewModel.user.policy {
viewModel.send(.updatePolicy(tempPolicy))
}
}
.buttonStyle(.toolbarPill)
.disabled(viewModel.user.policy == tempPolicy)
}
.onReceive(viewModel.events) { event in
switch event {
case let .error(eventError):
UIDevice.feedback(.error)
error = eventError
case .updated:
UIDevice.feedback(.success)
router.dismissCoordinator()
}
}
.errorMessage($error)
}
// MARK: - Content View
@ViewBuilder
var contentView: some View {
switch viewModel.state {
case let .error(error):
ErrorView(error: error)
case .initial:
ErrorView(error: JellyfinAPIError(L10n.loadingUserFailed))
default:
permissionsListView
}
}
// MARK: - Permissions List View
@ViewBuilder
var permissionsListView: some View {
List {
StatusSection(policy: $tempPolicy)
ManagementSection(policy: $tempPolicy)
MediaPlaybackSection(policy: $tempPolicy)
ExternalAccessSection(policy: $tempPolicy)
SyncPlaySection(policy: $tempPolicy)
RemoteControlSection(policy: $tempPolicy)
PermissionSection(policy: $tempPolicy)
SessionsSection(policy: $tempPolicy)
}
}
}