mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-24 01:15:35 +00:00
Rework
This commit is contained in:
@@ -4,6 +4,7 @@ import io.xpipe.app.comp.BaseRegionBuilder;
|
||||
import io.xpipe.app.comp.RegionBuilder;
|
||||
import io.xpipe.app.comp.SimpleRegionBuilder;
|
||||
import io.xpipe.app.comp.base.*;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.ext.DataStore;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class StoreListChoiceComp<T extends DataStore> extends SimpleRegionBuilde
|
||||
var listBox = new ListBoxViewComp<>(
|
||||
selectedList,
|
||||
selectedList,
|
||||
t -> {
|
||||
t -> {
|
||||
if (t == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ import java.util.UUID;
|
||||
@ToString(callSuper = true)
|
||||
public class MultiIdentityStore extends IdentityStore {
|
||||
|
||||
List<DataStoreEntryRef<IdentityStore>> identities;
|
||||
List<UUID> identities;
|
||||
|
||||
public List<DataStoreEntryRef<IdentityStore>> getAvailableIdentities() {
|
||||
return identities.stream().filter(ref -> ref != null && ref.get().getValidity().isUsable()).toList();
|
||||
return identities.stream().map(uuid -> DataStorage.get().getStoreEntryIfPresent(uuid)).flatMap(Optional::stream)
|
||||
.map(e -> e.<IdentityStore>ref())
|
||||
.filter(ref -> ref != null && ref.get().getValidity().isUsable()).toList();
|
||||
}
|
||||
|
||||
public Optional<DataStoreEntryRef<IdentityStore>> getSelected() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.xpipe.app.secret.SecretStrategyChoiceConfig;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreCategory;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.app.util.DocumentationLink;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleListProperty;
|
||||
@@ -23,6 +24,7 @@ import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -32,17 +34,23 @@ public class MultiIdentityStoreProvider extends IdentityStoreProvider {
|
||||
public GuiDialog guiDialog(DataStoreEntry entry, Property<DataStore> store) {
|
||||
MultiIdentityStore st = (MultiIdentityStore) store.getValue();
|
||||
|
||||
var identities = new SimpleListProperty<>(FXCollections.observableArrayList(st.getIdentities()));
|
||||
var identities = new SimpleListProperty<>(FXCollections.observableArrayList(st.getAvailableIdentities()));
|
||||
|
||||
return new OptionsBuilder()
|
||||
.nameAndDescription("multiIdentityList")
|
||||
.addComp(new StoreListChoiceComp<>(identities, IdentityStore.class,
|
||||
ref -> !(ref.getStore() instanceof MultiIdentityStore) && !identities.contains(ref),
|
||||
StoreViewState.get().getAllIdentitiesCategory()))
|
||||
StoreViewState.get().getAllIdentitiesCategory()), identities)
|
||||
.bind(
|
||||
() -> {
|
||||
var uuids = new LinkedHashSet<UUID>();
|
||||
for (DataStoreEntryRef<IdentityStore> identity : identities) {
|
||||
uuids.add(identity.get().getUuid());
|
||||
}
|
||||
uuids.addAll(st.getIdentities());
|
||||
|
||||
return MultiIdentityStore.builder()
|
||||
.identities(identities)
|
||||
.identities(new ArrayList<>(uuids))
|
||||
.build();
|
||||
},
|
||||
store)
|
||||
|
||||
Reference in New Issue
Block a user