mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Rework connection sharing
This commit is contained in:
parent
42f83e331a
commit
6df9169e38
5 changed files with 35 additions and 12 deletions
|
@ -122,8 +122,8 @@ public interface DataStoreProvider {
|
|||
|
||||
default void storageInit() throws Exception {}
|
||||
|
||||
default boolean isShareable() {
|
||||
return false;
|
||||
default boolean isShareable(DataStoreEntry entry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default String summaryString(StoreEntryWrapper wrapper) {
|
||||
|
|
|
@ -161,6 +161,38 @@ public abstract class DataStorage {
|
|||
public abstract void save();
|
||||
|
||||
public abstract boolean supportsSharing();
|
||||
public boolean shouldShare(DataStoreCategory entry) {
|
||||
if (!entry.canShare()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataStoreCategory c = entry;
|
||||
do {
|
||||
if (!c.shouldShareChildren()) {
|
||||
return false;
|
||||
}
|
||||
} while ((c = DataStorage.get()
|
||||
.getStoreCategoryIfPresent(c.getParentCategory())
|
||||
.orElse(null))
|
||||
!= null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldShare(DataStoreEntry entry) {
|
||||
if (!shouldShare(DataStorage.get()
|
||||
.getStoreCategoryIfPresent(entry.getCategoryUuid())
|
||||
.orElseThrow())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataStoreEntry c = entry;
|
||||
do {
|
||||
if (!c.getProvider().isShareable(c)) {
|
||||
return false;
|
||||
}
|
||||
} while ((c = DataStorage.get().getDisplayParent(c).orElse(null)) != null);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void refreshValidities(boolean makeValid) {
|
||||
var changed = new AtomicBoolean(false);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ShareStoreAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||
return o.get().getProvider().isShareable();
|
||||
return o.get().getProvider().isShareable(o.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,10 +24,6 @@ import java.util.List;
|
|||
|
||||
public class ScriptGroupStoreProvider implements DataStoreProvider {
|
||||
|
||||
public boolean isShareable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comp<?> customEntryComp(StoreSection sec, boolean preferLarge) {
|
||||
ScriptGroupStore s = sec.getWrapper().getEntry().getStore().asNeeded();
|
||||
|
|
|
@ -89,11 +89,6 @@ public class SimpleScriptStoreProvider implements DataStoreProvider {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShareable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStoreEntry getDisplayParent(DataStoreEntry store) {
|
||||
SimpleScriptStore st = store.getStore().asNeeded();
|
||||
|
|
Loading…
Reference in a new issue