[iOS] Admin Dashboard - Allowed Tags Cleanup (#1489)
* Enable if AllowedTags exist instead of just blockedTags * Separation * cleanup --------- Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
This commit is contained in:
parent
8c4fde87f1
commit
a585bbda5f
|
@ -42,6 +42,11 @@ struct EditServerUserAccessTagsView: View {
|
||||||
@State
|
@State
|
||||||
private var error: Error?
|
private var error: Error?
|
||||||
|
|
||||||
|
private var hasTags: Bool {
|
||||||
|
viewModel.user.policy?.blockedTags?.isEmpty == true &&
|
||||||
|
viewModel.user.policy?.allowedTags?.isEmpty == true
|
||||||
|
}
|
||||||
|
|
||||||
private var allowedTags: [TagWithAccess] {
|
private var allowedTags: [TagWithAccess] {
|
||||||
viewModel.user.policy?.allowedTags?
|
viewModel.user.policy?.allowedTags?
|
||||||
.sorted()
|
.sorted()
|
||||||
|
@ -103,18 +108,14 @@ struct EditServerUserAccessTagsView: View {
|
||||||
}
|
}
|
||||||
.navigationBarMenuButton(
|
.navigationBarMenuButton(
|
||||||
isLoading: viewModel.backgroundStates.contains(.refreshing),
|
isLoading: viewModel.backgroundStates.contains(.refreshing),
|
||||||
isHidden: isEditing || (
|
isHidden: isEditing || hasTags
|
||||||
viewModel.user.policy?.blockedTags?.isEmpty == true
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Button(L10n.add, systemImage: "plus") {
|
Button(L10n.add, systemImage: "plus") {
|
||||||
router.route(to: \.userAddAccessTag, viewModel)
|
router.route(to: \.userAddAccessTag, viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viewModel.user.policy?.blockedTags?.isNotEmpty == true {
|
Button(L10n.edit, systemImage: "checkmark.circle") {
|
||||||
Button(L10n.edit, systemImage: "checkmark.circle") {
|
isEditing = true
|
||||||
isEditing = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onReceive(viewModel.events) { event in
|
.onReceive(viewModel.events) { event in
|
||||||
|
@ -179,21 +180,25 @@ struct EditServerUserAccessTagsView: View {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if allowedTags.isNotEmpty {
|
if allowedTags.isNotEmpty {
|
||||||
DisclosureGroup(L10n.allowed) {
|
Section {
|
||||||
ForEach(
|
DisclosureGroup(L10n.allowed) {
|
||||||
allowedTags,
|
ForEach(
|
||||||
id: \.self,
|
allowedTags,
|
||||||
content: makeRow
|
id: \.self,
|
||||||
)
|
content: makeRow
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if blockedTags.isNotEmpty {
|
if blockedTags.isNotEmpty {
|
||||||
DisclosureGroup(L10n.blocked) {
|
Section {
|
||||||
ForEach(
|
DisclosureGroup(L10n.blocked) {
|
||||||
blockedTags,
|
ForEach(
|
||||||
id: \.self,
|
blockedTags,
|
||||||
content: makeRow
|
id: \.self,
|
||||||
)
|
content: makeRow
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,10 +209,10 @@ struct EditServerUserAccessTagsView: View {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var navigationBarSelectView: some View {
|
private var navigationBarSelectView: some View {
|
||||||
let isAllSelected = selectedTags.count == blockedTags.count
|
let isAllSelected = selectedTags.count == blockedTags.count + allowedTags.count
|
||||||
|
|
||||||
Button(isAllSelected ? L10n.removeAll : L10n.selectAll) {
|
Button(isAllSelected ? L10n.removeAll : L10n.selectAll) {
|
||||||
selectedTags = isAllSelected ? [] : Set(blockedTags)
|
selectedTags = isAllSelected ? [] : Set(blockedTags + allowedTags)
|
||||||
}
|
}
|
||||||
.buttonStyle(.toolbarPill)
|
.buttonStyle(.toolbarPill)
|
||||||
.disabled(!isEditing)
|
.disabled(!isEditing)
|
||||||
|
|
Loading…
Reference in New Issue