mirror of
https://github.com/xpipe-io/xpipe.git
synced 2025-04-17 09:43:37 +00:00
Script hub improvements
This commit is contained in:
parent
dd542d6758
commit
da8caa54e2
16 changed files with 87 additions and 14 deletions
|
@ -153,8 +153,7 @@ public class StoreEntryWrapper {
|
|||
summary.setValue(null);
|
||||
} else {
|
||||
try {
|
||||
summary.setValue(
|
||||
entry.getProvider() != null ? entry.getProvider().summaryString(this) : null);
|
||||
summary.setValue(entry.getProvider() != null ? entry.getProvider().summaryString(this) : null);
|
||||
} catch (Exception ex) {
|
||||
// Summary creation might fail or have a bug
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
.store-entry-grid .icon:hover {
|
||||
-fx-background-color: -color-bg-inset;
|
||||
-fx-background-radius: 5px;
|
||||
}
|
||||
|
||||
.root.nord .store-entry-grid .icon {
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package io.xpipe.ext.base.script;
|
||||
|
||||
import io.xpipe.app.comp.store.StoreCreationComp;
|
||||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.app.util.FileOpener;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SimpleScriptQuickEditAction implements ActionProvider {
|
||||
@Override
|
||||
public DefaultDataStoreCallSite<?> getDefaultDataStoreCallSite() {
|
||||
|
@ -30,6 +34,16 @@ public class SimpleScriptQuickEditAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
var predefined = DataStorage.get().getStoreCategoryIfPresent(ref.get().getCategoryUuid())
|
||||
.map(category -> category.getUuid().equals(DataStorage.PREDEFINED_SCRIPTS_CATEGORY_UUID))
|
||||
.orElse(false) &&
|
||||
Arrays.stream(PredefinedScriptStore.values())
|
||||
.anyMatch(predefinedScriptStore -> predefinedScriptStore.getName().equals(ref.get().getName()));
|
||||
if (predefined) {
|
||||
StoreCreationComp.showEdit(ref.get());
|
||||
return;
|
||||
}
|
||||
|
||||
var script = ref.getStore();
|
||||
var dialect = script.getMinimumDialect();
|
||||
var ext = dialect.getScriptFileEnding();
|
||||
|
|
|
@ -4,7 +4,6 @@ import io.xpipe.app.comp.base.IntegratedTextAreaComp;
|
|||
import io.xpipe.app.comp.base.ListSelectorComp;
|
||||
import io.xpipe.app.comp.base.SystemStateComp;
|
||||
import io.xpipe.app.comp.store.StoreEntryWrapper;
|
||||
import io.xpipe.app.comp.store.StoreSection;
|
||||
import io.xpipe.app.comp.store.StoreViewState;
|
||||
import io.xpipe.app.core.AppExtensionManager;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
|
@ -16,27 +15,25 @@ import io.xpipe.app.fxcomps.Comp;
|
|||
import io.xpipe.app.fxcomps.impl.DataStoreChoiceComp;
|
||||
import io.xpipe.app.fxcomps.impl.DataStoreListChoiceComp;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.util.DataStoreFormatter;
|
||||
import io.xpipe.app.util.MarkdownBuilder;
|
||||
import io.xpipe.app.util.OptionsBuilder;
|
||||
import io.xpipe.app.util.Validator;
|
||||
import io.xpipe.core.process.ShellDialect;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.util.Identifiers;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleListProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, DataStoreProvider {
|
||||
|
||||
|
@ -210,13 +207,25 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
|||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> informationString(StoreSection section) {
|
||||
SimpleScriptStore scriptStore =
|
||||
section.getWrapper().getEntry().getStore().asNeeded();
|
||||
return new SimpleStringProperty((scriptStore.getMinimumDialect() != null
|
||||
? scriptStore.getMinimumDialect().getDisplayName() + " "
|
||||
: "")
|
||||
+ " snippet");
|
||||
public boolean alwaysShowSummary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String summaryString(StoreEntryWrapper wrapper) {
|
||||
SimpleScriptStore st = wrapper.getEntry().getStore().asNeeded();
|
||||
var init = st.isInitScript() ? AppI18n.get("init") : null;
|
||||
var file = st.isRunnableScript() ? AppI18n.get("file") : null;
|
||||
var shell = st.isRunnableScript() ? AppI18n.get("shell") : null;
|
||||
var runnable = st.isRunnableScript() ? AppI18n.get("hub") : null;
|
||||
var type = st.getMinimumDialect() != null ? st.getMinimumDialect().getDisplayName() + " " + AppI18n.get("script") : null;
|
||||
var suffix = String.join(" / ", Stream.of(init, shell, file, runnable).filter(s -> s != null).toList());
|
||||
if (!suffix.isEmpty()) {
|
||||
suffix = "(" + suffix + ")";
|
||||
} else {
|
||||
suffix = null;
|
||||
}
|
||||
return DataStoreFormatter.join(type, suffix);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
|
|
@ -174,3 +174,7 @@ openHttp=Åben HTTP-tjeneste
|
|||
openHttps=Åben HTTPS-tjeneste
|
||||
noScriptsAvailable=Ingen tilgængelige scripts
|
||||
changeIcon=Skift ikon
|
||||
init=Indlæg
|
||||
shell=Skal
|
||||
hub=Hub
|
||||
script=script
|
||||
|
|
|
@ -165,3 +165,7 @@ openHttp=Offener HTTP-Dienst
|
|||
openHttps=HTTPS-Dienst öffnen
|
||||
noScriptsAvailable=Keine Skripte verfügbar
|
||||
changeIcon=Symbol ändern
|
||||
init=Init
|
||||
shell=Shell
|
||||
hub=Hub
|
||||
script=skript
|
||||
|
|
|
@ -163,5 +163,11 @@ openHttp=Open HTTP service
|
|||
openHttps=Open HTTPS service
|
||||
noScriptsAvailable=No scripts available
|
||||
changeIcon=Change icon
|
||||
init=Init
|
||||
shell=Shell
|
||||
hub=Hub
|
||||
#context: Computer script
|
||||
#force
|
||||
script=script
|
||||
|
||||
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Servicio HTTP abierto
|
|||
openHttps=Abrir servicio HTTPS
|
||||
noScriptsAvailable=No hay guiones disponibles
|
||||
changeIcon=Cambiar icono
|
||||
init=Init
|
||||
shell=Shell
|
||||
hub=Hub
|
||||
script=script
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Service HTTP ouvert
|
|||
openHttps=Service HTTPS ouvert
|
||||
noScriptsAvailable=Pas de scripts disponibles
|
||||
changeIcon=Changer d'icône
|
||||
init=Init
|
||||
shell=Coquille
|
||||
hub=Hub
|
||||
script=script
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Servizio HTTP aperto
|
|||
openHttps=Servizio HTTPS aperto
|
||||
noScriptsAvailable=Non sono disponibili script
|
||||
changeIcon=Cambia icona
|
||||
init=Init
|
||||
shell=Conchiglia
|
||||
hub=Hub
|
||||
script=script
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=オープンHTTPサービス
|
|||
openHttps=HTTPSサービスを開く
|
||||
noScriptsAvailable=スクリプトはない
|
||||
changeIcon=アイコンの変更
|
||||
init=イニシャル
|
||||
shell=シェル
|
||||
hub=ハブ
|
||||
script=スクリプト
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Open HTTP service
|
|||
openHttps=Open HTTPS service
|
||||
noScriptsAvailable=Geen scripts beschikbaar
|
||||
changeIcon=Pictogram wijzigen
|
||||
init=Init
|
||||
shell=Shell
|
||||
hub=Hub
|
||||
script=script
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Abre o serviço HTTP
|
|||
openHttps=Abre o serviço HTTPS
|
||||
noScriptsAvailable=Não há scripts disponíveis
|
||||
changeIcon=Altera o ícone
|
||||
init=Init
|
||||
shell=Concha
|
||||
hub=Hub
|
||||
script=guião
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Открытый HTTP-сервис
|
|||
openHttps=Открытая служба HTTPS
|
||||
noScriptsAvailable=Нет доступных скриптов
|
||||
changeIcon=Значок изменения
|
||||
init=Init
|
||||
shell=Shell
|
||||
hub=Хаб
|
||||
script=скрипт
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=Açık HTTP hizmeti
|
|||
openHttps=HTTPS hizmetini açın
|
||||
noScriptsAvailable=Mevcut senaryo yok
|
||||
changeIcon=Simge değiştir
|
||||
init=Başlangıç
|
||||
shell=Kabuk
|
||||
hub=Hub
|
||||
script=senaryo
|
||||
|
|
|
@ -163,3 +163,7 @@ openHttp=开放式 HTTP 服务
|
|||
openHttps=打开 HTTPS 服务
|
||||
noScriptsAvailable=无脚本可用
|
||||
changeIcon=更改图标
|
||||
init=启动
|
||||
shell=外壳
|
||||
hub=枢纽
|
||||
script=脚本
|
||||
|
|
Loading…
Add table
Reference in a new issue