mirror of https://github.com/halo-dev/halo
Merge pull request #6661 from guqing/refactor/setting-config-update
feat: support JSON-based retrieval and update for theme and plugin configspull/6703/head^2
commit
a4c906706f
|
@ -2871,7 +2871,7 @@
|
|||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": {
|
||||
"get": {
|
||||
"description": "Fetch configMap of plugin by configured configMapName.",
|
||||
"description": "Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0",
|
||||
"operationId": "fetchPluginConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -2900,7 +2900,8 @@
|
|||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of plugin setting.",
|
||||
"deprecated": true,
|
||||
"description": "Update the configMap of plugin setting, it is deprecated since 2.20.0",
|
||||
"operationId": "updatePluginConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -2939,6 +2940,70 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config": {
|
||||
"get": {
|
||||
"description": "Fetch converted json config of plugin by configured configMapName.",
|
||||
"operationId": "fetchPluginJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"content": {
|
||||
"*/*": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "default response"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"PluginV1alpha1Console"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the config of plugin setting.",
|
||||
"operationId": "updatePluginJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"204": {
|
||||
"content": {},
|
||||
"description": "No Content"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"PluginV1alpha1Console"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": {
|
||||
"put": {
|
||||
"description": "Change the running state of a plugin by name.",
|
||||
|
@ -4545,7 +4610,8 @@
|
|||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/config": {
|
||||
"get": {
|
||||
"description": "Fetch configMap of theme by configured configMapName.",
|
||||
"deprecated": true,
|
||||
"description": "Fetch configMap of theme by configured configMapName. It is deprecated.",
|
||||
"operationId": "fetchThemeConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -4574,7 +4640,8 @@
|
|||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of theme setting.",
|
||||
"deprecated": true,
|
||||
"description": "Update the configMap of theme setting. It is deprecated.",
|
||||
"operationId": "updateThemeConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -4637,6 +4704,70 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config": {
|
||||
"get": {
|
||||
"description": "Fetch converted json config of theme by configured configMapName.",
|
||||
"operationId": "fetchThemeJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"content": {
|
||||
"*/*": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "default response"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ThemeV1alpha1Console"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of theme setting.",
|
||||
"operationId": "updateThemeJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"204": {
|
||||
"content": {},
|
||||
"description": "No Content"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ThemeV1alpha1Console"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": {
|
||||
"put": {
|
||||
"description": "Reload theme setting.",
|
||||
|
|
|
@ -738,7 +738,7 @@
|
|||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": {
|
||||
"get": {
|
||||
"description": "Fetch configMap of plugin by configured configMapName.",
|
||||
"description": "Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0",
|
||||
"operationId": "fetchPluginConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -767,7 +767,8 @@
|
|||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of plugin setting.",
|
||||
"deprecated": true,
|
||||
"description": "Update the configMap of plugin setting, it is deprecated since 2.20.0",
|
||||
"operationId": "updatePluginConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -806,6 +807,70 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config": {
|
||||
"get": {
|
||||
"description": "Fetch converted json config of plugin by configured configMapName.",
|
||||
"operationId": "fetchPluginJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"content": {
|
||||
"*/*": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "default response"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"PluginV1alpha1Console"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the config of plugin setting.",
|
||||
"operationId": "updatePluginJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"204": {
|
||||
"content": {},
|
||||
"description": "No Content"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"PluginV1alpha1Console"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": {
|
||||
"put": {
|
||||
"description": "Change the running state of a plugin by name.",
|
||||
|
@ -2412,7 +2477,8 @@
|
|||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/config": {
|
||||
"get": {
|
||||
"description": "Fetch configMap of theme by configured configMapName.",
|
||||
"deprecated": true,
|
||||
"description": "Fetch configMap of theme by configured configMapName. It is deprecated.",
|
||||
"operationId": "fetchThemeConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -2441,7 +2507,8 @@
|
|||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of theme setting.",
|
||||
"deprecated": true,
|
||||
"description": "Update the configMap of theme setting. It is deprecated.",
|
||||
"operationId": "updateThemeConfig",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -2504,6 +2571,70 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config": {
|
||||
"get": {
|
||||
"description": "Fetch converted json config of theme by configured configMapName.",
|
||||
"operationId": "fetchThemeJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"content": {
|
||||
"*/*": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "default response"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ThemeV1alpha1Console"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the configMap of theme setting.",
|
||||
"operationId": "updateThemeJsonConfig",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"204": {
|
||||
"content": {},
|
||||
"description": "No Content"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ThemeV1alpha1Console"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": {
|
||||
"put": {
|
||||
"description": "Reload theme setting.",
|
||||
|
|
|
@ -17,6 +17,7 @@ import static run.halo.app.extension.index.query.QueryFactory.or;
|
|||
import static run.halo.app.extension.router.QueryParamBuildUtil.sortParameter;
|
||||
import static run.halo.app.infra.utils.FileUtils.deleteFileSilently;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -41,6 +42,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
|||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.http.codec.multipart.FormFieldPart;
|
||||
|
@ -61,6 +63,7 @@ import reactor.util.retry.Retry;
|
|||
import run.halo.app.core.extension.Plugin;
|
||||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.core.extension.endpoint.CustomEndpoint;
|
||||
import run.halo.app.core.user.service.SettingConfigService;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
import run.halo.app.extension.ListOptions;
|
||||
import run.halo.app.extension.ReactiveExtensionClient;
|
||||
|
@ -81,6 +84,8 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
|
||||
private final ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher;
|
||||
|
||||
private final SettingConfigService settingConfigService;
|
||||
|
||||
private final WebProperties webProperties;
|
||||
|
||||
private final Scheduler scheduler = Schedulers.boundedElastic();
|
||||
|
@ -92,10 +97,12 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
public PluginEndpoint(ReactiveExtensionClient client,
|
||||
PluginService pluginService,
|
||||
ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher,
|
||||
SettingConfigService settingConfigService,
|
||||
WebProperties webProperties) {
|
||||
this.client = client;
|
||||
this.pluginService = pluginService;
|
||||
this.reactiveUrlDataBufferFetcher = reactiveUrlDataBufferFetcher;
|
||||
this.settingConfigService = settingConfigService;
|
||||
this.webProperties = webProperties;
|
||||
}
|
||||
|
||||
|
@ -158,9 +165,9 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
.content(contentBuilder().mediaType(MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.schema(schemaBuilder().implementation(InstallRequest.class))))
|
||||
)
|
||||
.PUT("plugins/{name}/config", this::updatePluginConfig,
|
||||
builder -> builder.operationId("updatePluginConfig")
|
||||
.description("Update the configMap of plugin setting.")
|
||||
.PUT("plugins/{name}/json-config", this::updatePluginJsonConfig,
|
||||
builder -> builder.operationId("updatePluginJsonConfig")
|
||||
.description("Update the config of plugin setting.")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
|
@ -168,6 +175,26 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
.required(true)
|
||||
.implementation(String.class)
|
||||
)
|
||||
.requestBody(requestBodyBuilder()
|
||||
.required(true)
|
||||
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.schema(schemaBuilder().implementation(ObjectNode.class))))
|
||||
.response(responseBuilder()
|
||||
.responseCode(String.valueOf(HttpStatus.NO_CONTENT.value()))
|
||||
.implementation(Void.class))
|
||||
)
|
||||
.PUT("plugins/{name}/config", this::updatePluginConfig,
|
||||
builder -> builder.operationId("updatePluginConfig")
|
||||
.description(
|
||||
"Update the configMap of plugin setting, it is deprecated since 2.20.0")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
.required(true)
|
||||
.implementation(String.class)
|
||||
)
|
||||
.deprecated(true)
|
||||
.requestBody(requestBodyBuilder()
|
||||
.required(true)
|
||||
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
|
||||
|
@ -244,7 +271,9 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
)
|
||||
.GET("plugins/{name}/config", this::fetchPluginConfig,
|
||||
builder -> builder.operationId("fetchPluginConfig")
|
||||
.description("Fetch configMap of plugin by configured configMapName.")
|
||||
.description(
|
||||
"Fetch configMap of plugin by configured configMapName. it is deprecated "
|
||||
+ "since 2.20.0")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
|
@ -255,6 +284,20 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
.response(responseBuilder()
|
||||
.implementation(ConfigMap.class))
|
||||
)
|
||||
.GET("plugins/{name}/json-config", this::fetchPluginJsonConfig,
|
||||
builder -> builder.operationId("fetchPluginJsonConfig")
|
||||
.description(
|
||||
"Fetch converted json config of plugin by configured configMapName.")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
.required(true)
|
||||
.implementation(String.class)
|
||||
)
|
||||
.response(responseBuilder()
|
||||
.implementation(ObjectNode.class))
|
||||
)
|
||||
.GET("plugin-presets", this::listPresets,
|
||||
builder -> builder.operationId("ListPluginPresets")
|
||||
.description("List all plugin presets in the system.")
|
||||
|
@ -276,6 +319,35 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
|
|||
.build();
|
||||
}
|
||||
|
||||
private Mono<ServerResponse> fetchPluginJsonConfig(ServerRequest request) {
|
||||
final var name = request.pathVariable("name");
|
||||
return client.fetch(Plugin.class, name)
|
||||
.mapNotNull(plugin -> plugin.getSpec().getConfigMapName())
|
||||
.flatMap(settingConfigService::fetchConfig)
|
||||
.flatMap(json -> ServerResponse.ok().bodyValue(json));
|
||||
}
|
||||
|
||||
private Mono<ServerResponse> updatePluginJsonConfig(ServerRequest request) {
|
||||
final var pluginName = request.pathVariable("name");
|
||||
return client.fetch(Plugin.class, pluginName)
|
||||
.doOnNext(plugin -> {
|
||||
String configMapName = plugin.getSpec().getConfigMapName();
|
||||
if (!StringUtils.hasText(configMapName)) {
|
||||
throw new ServerWebInputException(
|
||||
"Unable to complete the request because the plugin configMapName is blank");
|
||||
}
|
||||
})
|
||||
.flatMap(plugin -> {
|
||||
final String configMapName = plugin.getSpec().getConfigMapName();
|
||||
return request.bodyToMono(ObjectNode.class)
|
||||
.switchIfEmpty(
|
||||
Mono.error(new ServerWebInputException("Required request body is missing")))
|
||||
.flatMap(configMapJsonData ->
|
||||
settingConfigService.upsertConfig(configMapName, configMapJsonData));
|
||||
})
|
||||
.then(ServerResponse.noContent().build());
|
||||
}
|
||||
|
||||
Mono<ServerResponse> changePluginRunningState(ServerRequest request) {
|
||||
final var name = request.pathVariable("name");
|
||||
return request.bodyToMono(RunningStateRequest.class)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package run.halo.app.core.user.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import reactor.core.publisher.Mono;
|
||||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
|
||||
/**
|
||||
* {@link Setting} related {@link ConfigMap} service.
|
||||
*
|
||||
* @author guqing
|
||||
* @since 2.20.0
|
||||
*/
|
||||
public interface SettingConfigService {
|
||||
|
||||
Mono<Void> upsertConfig(String configMapName, ObjectNode configJsonData);
|
||||
|
||||
Mono<ObjectNode> fetchConfig(String configMapName);
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package run.halo.app.core.user.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import java.time.Duration;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.util.retry.Retry;
|
||||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.core.user.service.SettingConfigService;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
import run.halo.app.extension.Metadata;
|
||||
import run.halo.app.extension.ReactiveExtensionClient;
|
||||
import run.halo.app.infra.utils.SettingUtils;
|
||||
|
||||
/**
|
||||
* {@link Setting} related {@link ConfigMap} service implementation.
|
||||
*
|
||||
* @author guqing
|
||||
* @since 2.20.0
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SettingConfigServiceImpl implements SettingConfigService {
|
||||
private final ReactiveExtensionClient client;
|
||||
|
||||
@Override
|
||||
public Mono<Void> upsertConfig(String configMapName, ObjectNode configJsonData) {
|
||||
Assert.notNull(configMapName, "Config map name must not be null");
|
||||
Assert.notNull(configJsonData, "Config json data must not be null");
|
||||
var data = SettingUtils.settingConfigJsonToMap(configJsonData);
|
||||
return Mono.defer(() -> client.fetch(ConfigMap.class, configMapName)
|
||||
.flatMap(persisted -> {
|
||||
persisted.setData(data);
|
||||
return client.update(persisted);
|
||||
}))
|
||||
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
|
||||
.filter(OptimisticLockingFailureException.class::isInstance)
|
||||
)
|
||||
.switchIfEmpty(Mono.defer(() -> {
|
||||
var configMap = new ConfigMap();
|
||||
configMap.setMetadata(new Metadata());
|
||||
configMap.getMetadata().setName(configMapName);
|
||||
configMap.setData(data);
|
||||
return client.create(configMap);
|
||||
}))
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<ObjectNode> fetchConfig(String configMapName) {
|
||||
return client.fetch(ConfigMap.class, configMapName)
|
||||
.map(SettingUtils::settingConfigToJson);
|
||||
}
|
||||
}
|
|
@ -127,7 +127,30 @@ public class SettingUtils {
|
|||
}
|
||||
}
|
||||
|
||||
JsonNode mapToJsonNode(Map<String, String> map) {
|
||||
/**
|
||||
* Convert {@link Setting} related configMap data to JsonNode.
|
||||
*
|
||||
* @param configMap {@link ConfigMap} instance
|
||||
* @return JsonNode
|
||||
*/
|
||||
public static ObjectNode settingConfigToJson(ConfigMap configMap) {
|
||||
if (configMap.getData() == null) {
|
||||
return JsonNodeFactory.instance.objectNode();
|
||||
}
|
||||
return mapToJsonNode(configMap.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the result of {@link #settingConfigToJson(ConfigMap)} in reverse to Map.
|
||||
*
|
||||
* @param node JsonNode object
|
||||
* @return {@link ConfigMap#getData()}
|
||||
*/
|
||||
public static Map<String, String> settingConfigJsonToMap(ObjectNode node) {
|
||||
return jsonNodeToStringMap(node);
|
||||
}
|
||||
|
||||
ObjectNode mapToJsonNode(Map<String, String> map) {
|
||||
ObjectNode objectNode = JsonNodeFactory.instance.objectNode();
|
||||
map.forEach((k, v) -> {
|
||||
if (isJson(v)) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import static org.springdoc.core.fn.builders.schema.Builder.schemaBuilder;
|
|||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||
import static org.springframework.web.reactive.function.server.RequestPredicates.contentType;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.net.URI;
|
||||
|
@ -38,6 +39,7 @@ import reactor.util.retry.Retry;
|
|||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.core.extension.Theme;
|
||||
import run.halo.app.core.extension.endpoint.CustomEndpoint;
|
||||
import run.halo.app.core.user.service.SettingConfigService;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
import run.halo.app.extension.ListResult;
|
||||
import run.halo.app.extension.ReactiveExtensionClient;
|
||||
|
@ -75,6 +77,8 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
|
||||
private final ReactiveUrlDataBufferFetcher urlDataBufferFetcher;
|
||||
|
||||
private final SettingConfigService settingConfigService;
|
||||
|
||||
@Override
|
||||
public RouterFunction<ServerResponse> endpoint() {
|
||||
var tag = "ThemeV1alpha1Console";
|
||||
|
@ -163,8 +167,9 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
)
|
||||
.PUT("themes/{name}/config", this::updateThemeConfig,
|
||||
builder -> builder.operationId("updateThemeConfig")
|
||||
.description("Update the configMap of theme setting.")
|
||||
.description("Update the configMap of theme setting. It is deprecated.")
|
||||
.tag(tag)
|
||||
.deprecated(true)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
|
@ -178,6 +183,24 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
.response(responseBuilder()
|
||||
.implementation(ConfigMap.class))
|
||||
)
|
||||
.PUT("themes/{name}/json-config", this::updateThemeJsonConfig,
|
||||
builder -> builder.operationId("updateThemeJsonConfig")
|
||||
.description("Update the configMap of theme setting.")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
.required(true)
|
||||
.implementation(String.class)
|
||||
)
|
||||
.requestBody(requestBodyBuilder()
|
||||
.required(true)
|
||||
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.schema(schemaBuilder().implementation(ObjectNode.class))))
|
||||
.response(responseBuilder()
|
||||
.responseCode(String.valueOf(NO_CONTENT.value()))
|
||||
.implementation(Void.class))
|
||||
)
|
||||
.PUT("themes/{name}/activation", this::activateTheme,
|
||||
builder -> builder.operationId("activateTheme")
|
||||
.description("Activate a theme by name.")
|
||||
|
@ -237,8 +260,10 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
)
|
||||
.GET("themes/{name}/config", this::fetchThemeConfig,
|
||||
builder -> builder.operationId("fetchThemeConfig")
|
||||
.description("Fetch configMap of theme by configured configMapName.")
|
||||
.description(
|
||||
"Fetch configMap of theme by configured configMapName. It is deprecated.")
|
||||
.tag(tag)
|
||||
.deprecated(true)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
|
@ -248,9 +273,52 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
.response(responseBuilder()
|
||||
.implementation(ConfigMap.class))
|
||||
)
|
||||
.GET("themes/{name}/json-config", this::fetchThemeJsonConfig,
|
||||
builder -> builder.operationId("fetchThemeJsonConfig")
|
||||
.description(
|
||||
"Fetch converted json config of theme by configured configMapName.")
|
||||
.tag(tag)
|
||||
.parameter(parameterBuilder()
|
||||
.name("name")
|
||||
.in(ParameterIn.PATH)
|
||||
.required(true)
|
||||
.implementation(String.class)
|
||||
)
|
||||
.response(responseBuilder()
|
||||
.implementation(ObjectNode.class))
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Mono<ServerResponse> fetchThemeJsonConfig(ServerRequest request) {
|
||||
return themeNameInPathVariableOrActivated(request)
|
||||
.flatMap(themeName -> client.fetch(Theme.class, themeName))
|
||||
.mapNotNull(theme -> theme.getSpec().getConfigMapName())
|
||||
.flatMap(settingConfigService::fetchConfig)
|
||||
.flatMap(json -> ServerResponse.ok().bodyValue(json));
|
||||
}
|
||||
|
||||
private Mono<ServerResponse> updateThemeJsonConfig(ServerRequest request) {
|
||||
final var themeName = request.pathVariable("name");
|
||||
return client.fetch(Theme.class, themeName)
|
||||
.doOnNext(theme -> {
|
||||
String configMapName = theme.getSpec().getConfigMapName();
|
||||
if (StringUtils.isBlank(configMapName)) {
|
||||
throw new ServerWebInputException(
|
||||
"Unable to complete the request because the theme configMapName is blank.");
|
||||
}
|
||||
})
|
||||
.flatMap(theme -> {
|
||||
final var configMapName = theme.getSpec().getConfigMapName();
|
||||
return request.bodyToMono(ObjectNode.class)
|
||||
.switchIfEmpty(
|
||||
Mono.error(new ServerWebInputException("Required request body is missing")))
|
||||
.flatMap(configJsonData ->
|
||||
settingConfigService.upsertConfig(configMapName, configJsonData));
|
||||
})
|
||||
.then(ServerResponse.noContent().build());
|
||||
}
|
||||
|
||||
private Mono<ServerResponse> invalidateCache(ServerRequest request) {
|
||||
final var name = request.pathVariable("name");
|
||||
return client.get(Theme.class, name)
|
||||
|
@ -308,6 +376,7 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
.flatMap(activatedTheme -> ServerResponse.ok().bodyValue(activatedTheme));
|
||||
}
|
||||
|
||||
@Deprecated(since = "2.20.0", forRemoval = true)
|
||||
private Mono<ServerResponse> updateThemeConfig(ServerRequest request) {
|
||||
final var themeName = request.pathVariable("name");
|
||||
return client.fetch(Theme.class, themeName)
|
||||
|
@ -345,6 +414,7 @@ public class ThemeEndpoint implements CustomEndpoint {
|
|||
.flatMap(configMap -> ServerResponse.ok().bodyValue(configMap));
|
||||
}
|
||||
|
||||
@Deprecated(since = "2.20.0", forRemoval = true)
|
||||
private Mono<ServerResponse> fetchThemeConfig(ServerRequest request) {
|
||||
return themeNameInPathVariableOrActivated(request)
|
||||
.flatMap(themeName -> client.fetch(Theme.class, themeName))
|
||||
|
|
|
@ -16,8 +16,8 @@ rules:
|
|||
resources: [ "plugins" ]
|
||||
verbs: [ "create", "patch", "update", "delete", "deletecollection" ]
|
||||
- apiGroups: [ "api.console.halo.run" ]
|
||||
resources: [ "plugins/upgrade", "plugins/resetconfig", "plugins/config", "plugins/reload",
|
||||
"plugins/install-from-uri", "plugins/upgrade-from-uri", "plugins/plugin-state" ]
|
||||
resources: [ "plugins/upgrade", "plugins/resetconfig", "plugins/config", "plugins/json-config",
|
||||
"plugins/reload", "plugins/install-from-uri", "plugins/upgrade-from-uri", "plugins/plugin-state" ]
|
||||
verbs: [ "*" ]
|
||||
- apiGroups: [ "api.console.halo.run" ]
|
||||
resources: [ "plugin-presets" ]
|
||||
|
@ -41,5 +41,5 @@ rules:
|
|||
resources: [ "plugins" ]
|
||||
verbs: [ "get", "list" ]
|
||||
- apiGroups: [ "api.console.halo.run" ]
|
||||
resources: [ "plugins", "plugins/setting", "plugins/config" ]
|
||||
resources: [ "plugins", "plugins/setting", "plugins/config", "plugins/json-config" ]
|
||||
verbs: [ "get", "list" ]
|
||||
|
|
|
@ -15,8 +15,8 @@ rules:
|
|||
resources: [ "themes" ]
|
||||
verbs: [ "*" ]
|
||||
- apiGroups: [ "api.console.halo.run" ]
|
||||
resources: [ "themes", "themes/reload", "themes/resetconfig", "themes/config", "themes/activation",
|
||||
"themes/install-from-uri", "themes/upgrade-from-uri", "themes/invalidate-cache" ]
|
||||
resources: [ "themes", "themes/reload", "themes/resetconfig", "themes/config", "themes/json-config",
|
||||
"themes/activation", "themes/install-from-uri", "themes/upgrade-from-uri", "themes/invalidate-cache" ]
|
||||
verbs: [ "*" ]
|
||||
- nonResourceURLs: [ "/apis/api.console.halo.run/themes/install" ]
|
||||
verbs: [ "create" ]
|
||||
|
@ -37,6 +37,6 @@ rules:
|
|||
resources: [ "themes" ]
|
||||
verbs: [ "get", "list" ]
|
||||
- apiGroups: [ "api.console.halo.run" ]
|
||||
resources: [ "themes", "themes/activation", "themes/setting", "themes/config" ]
|
||||
resources: [ "themes", "themes/activation", "themes/setting", "themes/config", "themes/json-config" ]
|
||||
verbs: [ "get", "list" ]
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -44,6 +45,7 @@ import org.springframework.web.server.ServerWebInputException;
|
|||
import reactor.core.publisher.Mono;
|
||||
import run.halo.app.core.extension.Plugin;
|
||||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.core.user.service.SettingConfigService;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
import run.halo.app.extension.ListOptions;
|
||||
import run.halo.app.extension.ListResult;
|
||||
|
@ -67,6 +69,9 @@ class PluginEndpointTest {
|
|||
@Mock
|
||||
PluginService pluginService;
|
||||
|
||||
@Mock
|
||||
SettingConfigService settingConfigService;
|
||||
|
||||
@Spy
|
||||
WebProperties webProperties = new WebProperties();
|
||||
|
||||
|
@ -278,6 +283,22 @@ class PluginEndpointTest {
|
|||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateJsonConfigTest() {
|
||||
Plugin plugin = createPlugin("fake-plugin");
|
||||
plugin.getSpec().setConfigMapName("fake-config-map");
|
||||
|
||||
when(client.fetch(eq(Plugin.class), eq("fake-plugin"))).thenReturn(Mono.just(plugin));
|
||||
when(settingConfigService.upsertConfig(eq("fake-config-map"), any()))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
webClient.put()
|
||||
.uri("/plugins/fake-plugin/json-config")
|
||||
.body(Mono.just(Map.of()), Map.class)
|
||||
.exchange()
|
||||
.expectStatus().is2xxSuccessful();
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
@ -325,6 +346,23 @@ class PluginEndpointTest {
|
|||
verify(client).fetch(eq(ConfigMap.class), eq("fake-config"));
|
||||
verify(client).fetch(eq(Plugin.class), eq("fake"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fetchJsonConfig() {
|
||||
Plugin plugin = createPlugin("fake");
|
||||
plugin.getSpec().setConfigMapName("fake-config");
|
||||
|
||||
when(settingConfigService.fetchConfig(eq("fake-config")))
|
||||
.thenReturn(Mono.empty());
|
||||
when(client.fetch(eq(Plugin.class), eq("fake"))).thenReturn(Mono.just(plugin));
|
||||
webClient.get()
|
||||
.uri("/plugins/fake/json-config")
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
|
||||
verify(settingConfigService).fetchConfig(eq("fake-config"));
|
||||
verify(client).fetch(eq(Plugin.class), eq("fake"));
|
||||
}
|
||||
}
|
||||
|
||||
Plugin createPlugin(String name) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
|
@ -33,6 +34,7 @@ import org.springframework.web.server.ServerWebInputException;
|
|||
import reactor.core.publisher.Mono;
|
||||
import run.halo.app.core.extension.Setting;
|
||||
import run.halo.app.core.extension.Theme;
|
||||
import run.halo.app.core.user.service.SettingConfigService;
|
||||
import run.halo.app.extension.ConfigMap;
|
||||
import run.halo.app.extension.Metadata;
|
||||
import run.halo.app.extension.ReactiveExtensionClient;
|
||||
|
@ -70,6 +72,9 @@ class ThemeEndpointTest {
|
|||
@Mock
|
||||
private ReactiveUrlDataBufferFetcher urlDataBufferFetcher;
|
||||
|
||||
@Mock
|
||||
private SettingConfigService settingConfigService;
|
||||
|
||||
@InjectMocks
|
||||
ThemeEndpoint themeEndpoint;
|
||||
|
||||
|
@ -299,8 +304,25 @@ class ThemeEndpointTest {
|
|||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateJsonConfigTest() {
|
||||
Theme theme = new Theme();
|
||||
theme.setMetadata(new Metadata());
|
||||
theme.setSpec(new Theme.ThemeSpec());
|
||||
theme.getSpec().setConfigMapName("fake-config-map");
|
||||
|
||||
when(client.fetch(eq(Theme.class), eq("fake-theme"))).thenReturn(Mono.just(theme));
|
||||
when(settingConfigService.upsertConfig(eq("fake-config-map"), any()))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
webTestClient.put()
|
||||
.uri("/themes/fake-theme/json-config")
|
||||
.body(Mono.just(Map.of()), Map.class)
|
||||
.exchange()
|
||||
.expectStatus().is2xxSuccessful();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void fetchActivatedTheme() {
|
||||
|
@ -361,4 +383,24 @@ class ThemeEndpointTest {
|
|||
verify(client).fetch(eq(ConfigMap.class), eq("fake-config"));
|
||||
verify(client).fetch(eq(Theme.class), eq("fake"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fetchThemeJsonConfigTest() {
|
||||
Theme theme = new Theme();
|
||||
theme.setMetadata(new Metadata());
|
||||
theme.getMetadata().setName("fake");
|
||||
theme.setSpec(new Theme.ThemeSpec());
|
||||
theme.getSpec().setConfigMapName("fake-config");
|
||||
|
||||
when(settingConfigService.fetchConfig(eq("fake-config"))).thenReturn(Mono.empty());
|
||||
|
||||
when(client.fetch(eq(Theme.class), eq("fake"))).thenReturn(Mono.just(theme));
|
||||
webTestClient.get()
|
||||
.uri("/themes/fake/json-config")
|
||||
.exchange()
|
||||
.expectStatus().isOk();
|
||||
|
||||
verify(settingConfigService).fetchConfig(eq("fake-config"));
|
||||
verify(client).fetch(eq(Theme.class), eq("fake"));
|
||||
}
|
||||
}
|
|
@ -1,19 +1,13 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
import { computed, inject, ref, toRaw } from "vue";
|
||||
|
||||
// components
|
||||
import { Toast, VButton } from "@halo-dev/components";
|
||||
|
||||
// types
|
||||
import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client";
|
||||
import type { Ref } from "vue";
|
||||
|
||||
// hooks
|
||||
import StickyBlock from "@/components/sticky-block/StickyBlock.vue";
|
||||
import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
||||
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
|
||||
import type { Setting, Theme } from "@halo-dev/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { Toast, VButton } from "@halo-dev/components";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { cloneDeep, set } from "lodash-es";
|
||||
import type { Ref } from "vue";
|
||||
import { computed, inject, ref, toRaw } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -26,10 +20,10 @@ const setting = inject<Ref<Setting | undefined>>("setting", ref());
|
|||
|
||||
const saving = ref(false);
|
||||
|
||||
const { data: configMap, suspense } = useQuery<ConfigMap>({
|
||||
queryKey: ["theme-configMap", selectedTheme],
|
||||
const { data: configMapData, suspense } = useQuery({
|
||||
queryKey: ["core:theme:configMap:data", selectedTheme],
|
||||
queryFn: async () => {
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeJsonConfig({
|
||||
name: selectedTheme?.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
@ -39,30 +33,37 @@ const { data: configMap, suspense } = useQuery<ConfigMap>({
|
|||
}),
|
||||
});
|
||||
|
||||
const { configMapFormData, formSchema, convertToSave } = useSettingFormConvert(
|
||||
setting,
|
||||
configMap,
|
||||
group
|
||||
);
|
||||
const currentConfigMapGroupData = computed(() => {
|
||||
return configMapData.value?.[group.value];
|
||||
});
|
||||
|
||||
const handleSaveConfigMap = async () => {
|
||||
const formSchema = computed(() => {
|
||||
if (!setting.value) {
|
||||
return;
|
||||
}
|
||||
const { forms } = setting.value.spec;
|
||||
return forms.find((item) => item.group === group?.value)?.formSchema as (
|
||||
| FormKitSchemaCondition
|
||||
| FormKitSchemaNode
|
||||
)[];
|
||||
});
|
||||
|
||||
const handleSaveConfigMap = async (data: object) => {
|
||||
saving.value = true;
|
||||
|
||||
const configMapToUpdate = convertToSave();
|
||||
|
||||
if (!configMapToUpdate || !selectedTheme?.value) {
|
||||
if (!selectedTheme?.value) {
|
||||
saving.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await consoleApiClient.theme.theme.updateThemeConfig({
|
||||
await consoleApiClient.theme.theme.updateThemeJsonConfig({
|
||||
name: selectedTheme?.value?.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
body: set(cloneDeep(configMapData.value) || {}, group.value, data),
|
||||
});
|
||||
|
||||
Toast.success(t("core.common.toast.save_success"));
|
||||
|
||||
queryClient.invalidateQueries({ queryKey: ["theme-configMap"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["core:theme:configMap:data"] });
|
||||
|
||||
saving.value = false;
|
||||
};
|
||||
|
@ -73,18 +74,16 @@ await suspense();
|
|||
<Transition mode="out-in" name="fade">
|
||||
<div class="p-4">
|
||||
<FormKit
|
||||
v-if="group && formSchema && configMapFormData?.[group]"
|
||||
v-if="group && formSchema && currentConfigMapGroupData"
|
||||
:id="group"
|
||||
v-model="configMapFormData[group]"
|
||||
:value="currentConfigMapGroupData || {}"
|
||||
:name="group"
|
||||
:actions="false"
|
||||
:preserve="true"
|
||||
type="form"
|
||||
@submit="handleSaveConfigMap"
|
||||
>
|
||||
<FormKitSchema
|
||||
:schema="toRaw(formSchema)"
|
||||
:data="configMapFormData[group]"
|
||||
:data="toRaw(currentConfigMapGroupData)"
|
||||
/>
|
||||
</FormKit>
|
||||
<StickyBlock
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<script lang="ts" setup>
|
||||
import StickyBlock from "@/components/sticky-block/StickyBlock.vue";
|
||||
import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
||||
import type { ConfigMap, Plugin, Setting } from "@halo-dev/api-client";
|
||||
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
|
||||
import type { Plugin, Setting } from "@halo-dev/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { Toast, VButton } from "@halo-dev/components";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { cloneDeep, set } from "lodash-es";
|
||||
import { computed, inject, ref, toRaw, type Ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
|
@ -16,12 +17,14 @@ const plugin = inject<Ref<Plugin | undefined>>("plugin");
|
|||
const setting = inject<Ref<Setting | undefined>>("setting", ref());
|
||||
const saving = ref(false);
|
||||
|
||||
const { data: configMap } = useQuery<ConfigMap>({
|
||||
queryKey: ["plugin-configMap", plugin],
|
||||
const { data: configMapData } = useQuery({
|
||||
queryKey: ["core:plugin:configMap:data", plugin],
|
||||
queryFn: async () => {
|
||||
const { data } = await consoleApiClient.plugin.plugin.fetchPluginConfig({
|
||||
name: plugin?.value?.metadata.name as string,
|
||||
});
|
||||
const { data } = await consoleApiClient.plugin.plugin.fetchPluginJsonConfig(
|
||||
{
|
||||
name: plugin?.value?.metadata.name as string,
|
||||
}
|
||||
);
|
||||
return data;
|
||||
},
|
||||
enabled: computed(() => {
|
||||
|
@ -29,28 +32,37 @@ const { data: configMap } = useQuery<ConfigMap>({
|
|||
}),
|
||||
});
|
||||
|
||||
const { configMapFormData, formSchema, convertToSave } = useSettingFormConvert(
|
||||
setting,
|
||||
configMap,
|
||||
group
|
||||
);
|
||||
const currentConfigMapGroupData = computed(() => {
|
||||
return configMapData.value?.[group.value];
|
||||
});
|
||||
|
||||
const handleSaveConfigMap = async () => {
|
||||
const formSchema = computed(() => {
|
||||
if (!setting.value) {
|
||||
return;
|
||||
}
|
||||
const { forms } = setting.value.spec;
|
||||
return forms.find((item) => item.group === group?.value)?.formSchema as (
|
||||
| FormKitSchemaCondition
|
||||
| FormKitSchemaNode
|
||||
)[];
|
||||
});
|
||||
|
||||
const handleSaveConfigMap = async (data: object) => {
|
||||
saving.value = true;
|
||||
const configMapToUpdate = convertToSave();
|
||||
if (!configMapToUpdate || !plugin?.value) {
|
||||
|
||||
if (!plugin?.value) {
|
||||
saving.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await consoleApiClient.plugin.plugin.updatePluginConfig({
|
||||
await consoleApiClient.plugin.plugin.updatePluginJsonConfig({
|
||||
name: plugin.value.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
body: set(cloneDeep(configMapData.value) || {}, group.value, data),
|
||||
});
|
||||
|
||||
Toast.success(t("core.common.toast.save_success"));
|
||||
|
||||
queryClient.invalidateQueries({ queryKey: ["plugin-configMap"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["core:plugin:configMap:data"] });
|
||||
|
||||
saving.value = false;
|
||||
};
|
||||
|
@ -60,18 +72,16 @@ const handleSaveConfigMap = async () => {
|
|||
<div class="rounded-b-base bg-white p-4">
|
||||
<div>
|
||||
<FormKit
|
||||
v-if="group && formSchema && configMapFormData?.[group]"
|
||||
v-if="group && formSchema && currentConfigMapGroupData"
|
||||
:id="group"
|
||||
v-model="configMapFormData[group]"
|
||||
:value="currentConfigMapGroupData"
|
||||
:name="group"
|
||||
:actions="false"
|
||||
:preserve="true"
|
||||
type="form"
|
||||
@submit="handleSaveConfigMap"
|
||||
>
|
||||
<FormKitSchema
|
||||
:schema="toRaw(formSchema)"
|
||||
:data="configMapFormData[group]"
|
||||
:data="toRaw(currentConfigMapGroupData)"
|
||||
/>
|
||||
</FormKit>
|
||||
</div>
|
||||
|
|
|
@ -163,7 +163,7 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
|
|||
};
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of plugin by configured configMapName.
|
||||
* Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
|
@ -194,6 +194,47 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
|
|||
|
||||
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of plugin by configured configMapName.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchPluginJsonConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'name' is not null or undefined
|
||||
assertParamExists('fetchPluginJsonConfig', 'name', name)
|
||||
const localVarPath = `/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config`
|
||||
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication basicAuth required
|
||||
// http basic authentication required
|
||||
setBasicAuthToObject(localVarRequestOptions, configuration)
|
||||
|
||||
// authentication bearerAuth required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
|
@ -535,10 +576,11 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
|
|||
};
|
||||
},
|
||||
/**
|
||||
* Update the configMap of plugin setting.
|
||||
* Update the configMap of plugin setting, it is deprecated since 2.20.0
|
||||
* @param {string} name
|
||||
* @param {ConfigMap} configMap
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updatePluginConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
|
@ -581,6 +623,53 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
|
|||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Update the config of plugin setting.
|
||||
* @param {string} name
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updatePluginJsonConfig: async (name: string, body: object, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'name' is not null or undefined
|
||||
assertParamExists('updatePluginJsonConfig', 'name', name)
|
||||
// verify required parameter 'body' is not null or undefined
|
||||
assertParamExists('updatePluginJsonConfig', 'body', body)
|
||||
const localVarPath = `/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config`
|
||||
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication basicAuth required
|
||||
// http basic authentication required
|
||||
setBasicAuthToObject(localVarRequestOptions, configuration)
|
||||
|
||||
// authentication bearerAuth required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Upgrade a plugin by uploading a Jar file
|
||||
* @param {string} name
|
||||
|
@ -734,7 +823,7 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
|
|||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of plugin by configured configMapName.
|
||||
* Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
|
@ -745,6 +834,18 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
|
|||
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.fetchPluginConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of plugin by configured configMapName.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async fetchPluginJsonConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchPluginJsonConfig(name, options);
|
||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.fetchPluginJsonConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch setting of plugin.
|
||||
* @param {string} name
|
||||
|
@ -837,10 +938,11 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
|
|||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Update the configMap of plugin setting.
|
||||
* Update the configMap of plugin setting, it is deprecated since 2.20.0
|
||||
* @param {string} name
|
||||
* @param {ConfigMap} configMap
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async updatePluginConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
|
||||
|
@ -849,6 +951,19 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
|
|||
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.updatePluginConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Update the config of plugin setting.
|
||||
* @param {string} name
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async updatePluginJsonConfig(name: string, body: object, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.updatePluginJsonConfig(name, body, options);
|
||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.updatePluginJsonConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Upgrade a plugin by uploading a Jar file
|
||||
* @param {string} name
|
||||
|
@ -913,7 +1028,7 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
|
|||
return localVarFp.fetchJsBundle(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of plugin by configured configMapName.
|
||||
* Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
|
@ -921,6 +1036,15 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
|
|||
fetchPluginConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
|
||||
return localVarFp.fetchPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of plugin by configured configMapName.
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchPluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<object> {
|
||||
return localVarFp.fetchPluginJsonConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch setting of plugin.
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters.
|
||||
|
@ -984,14 +1108,24 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
|
|||
return localVarFp.resetPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Update the configMap of plugin setting.
|
||||
* Update the configMap of plugin setting, it is deprecated since 2.20.0
|
||||
* @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updatePluginConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
|
||||
return localVarFp.updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Update the config of plugin setting.
|
||||
* @param {PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updatePluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
|
||||
return localVarFp.updatePluginJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Upgrade a plugin by uploading a Jar file
|
||||
* @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters.
|
||||
|
@ -1048,6 +1182,20 @@ export interface PluginV1alpha1ConsoleApiFetchPluginConfigRequest {
|
|||
readonly name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for fetchPluginJsonConfig operation in PluginV1alpha1ConsoleApi.
|
||||
* @export
|
||||
* @interface PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest
|
||||
*/
|
||||
export interface PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof PluginV1alpha1ConsoleApiFetchPluginJsonConfig
|
||||
*/
|
||||
readonly name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for fetchPluginSetting operation in PluginV1alpha1ConsoleApi.
|
||||
* @export
|
||||
|
@ -1209,6 +1357,27 @@ export interface PluginV1alpha1ConsoleApiUpdatePluginConfigRequest {
|
|||
readonly configMap: ConfigMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for updatePluginJsonConfig operation in PluginV1alpha1ConsoleApi.
|
||||
* @export
|
||||
* @interface PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest
|
||||
*/
|
||||
export interface PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof PluginV1alpha1ConsoleApiUpdatePluginJsonConfig
|
||||
*/
|
||||
readonly name: string
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {object}
|
||||
* @memberof PluginV1alpha1ConsoleApiUpdatePluginJsonConfig
|
||||
*/
|
||||
readonly body: object
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for upgradePlugin operation in PluginV1alpha1ConsoleApi.
|
||||
* @export
|
||||
|
@ -1304,7 +1473,7 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetch configMap of plugin by configured configMapName.
|
||||
* Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
|
@ -1314,6 +1483,17 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
|
|||
return PluginV1alpha1ConsoleApiFp(this.configuration).fetchPluginConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch converted json config of plugin by configured configMapName.
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof PluginV1alpha1ConsoleApi
|
||||
*/
|
||||
public fetchPluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest, options?: RawAxiosRequestConfig) {
|
||||
return PluginV1alpha1ConsoleApiFp(this.configuration).fetchPluginJsonConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch setting of plugin.
|
||||
* @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters.
|
||||
|
@ -1391,9 +1571,10 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the configMap of plugin setting.
|
||||
* Update the configMap of plugin setting, it is deprecated since 2.20.0
|
||||
* @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
* @memberof PluginV1alpha1ConsoleApi
|
||||
*/
|
||||
|
@ -1401,6 +1582,17 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
|
|||
return PluginV1alpha1ConsoleApiFp(this.configuration).updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the config of plugin setting.
|
||||
* @param {PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof PluginV1alpha1ConsoleApi
|
||||
*/
|
||||
public updatePluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest, options?: RawAxiosRequestConfig) {
|
||||
return PluginV1alpha1ConsoleApiFp(this.configuration).updatePluginJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade a plugin by uploading a Jar file
|
||||
* @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters.
|
||||
|
|
|
@ -118,9 +118,10 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
|
|||
};
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of theme by configured configMapName.
|
||||
* Fetch configMap of theme by configured configMapName. It is deprecated.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchThemeConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
|
@ -149,6 +150,47 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
|
|||
|
||||
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of theme by configured configMapName.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchThemeJsonConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'name' is not null or undefined
|
||||
assertParamExists('fetchThemeJsonConfig', 'name', name)
|
||||
const localVarPath = `/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config`
|
||||
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication basicAuth required
|
||||
// http basic authentication required
|
||||
setBasicAuthToObject(localVarRequestOptions, configuration)
|
||||
|
||||
// authentication bearerAuth required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
|
@ -465,10 +507,11 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
|
|||
};
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* Update the configMap of theme setting. It is deprecated.
|
||||
* @param {string} name
|
||||
* @param {ConfigMap} configMap
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateThemeConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
|
@ -511,6 +554,53 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
|
|||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* @param {string} name
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateThemeJsonConfig: async (name: string, body: object, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'name' is not null or undefined
|
||||
assertParamExists('updateThemeJsonConfig', 'name', name)
|
||||
// verify required parameter 'body' is not null or undefined
|
||||
assertParamExists('updateThemeJsonConfig', 'body', body)
|
||||
const localVarPath = `/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config`
|
||||
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication basicAuth required
|
||||
// http basic authentication required
|
||||
setBasicAuthToObject(localVarRequestOptions, configuration)
|
||||
|
||||
// authentication bearerAuth required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Upgrade theme
|
||||
* @param {string} name
|
||||
|
@ -644,9 +734,10 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
|
|||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of theme by configured configMapName.
|
||||
* Fetch configMap of theme by configured configMapName. It is deprecated.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async fetchThemeConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
|
||||
|
@ -655,6 +746,18 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
|
|||
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.fetchThemeConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of theme by configured configMapName.
|
||||
* @param {string} name
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async fetchThemeJsonConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchThemeJsonConfig(name, options);
|
||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.fetchThemeJsonConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Fetch setting of theme.
|
||||
* @param {string} name
|
||||
|
@ -743,10 +846,11 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
|
|||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* Update the configMap of theme setting. It is deprecated.
|
||||
* @param {string} name
|
||||
* @param {ConfigMap} configMap
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async updateThemeConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
|
||||
|
@ -755,6 +859,19 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
|
|||
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.updateThemeConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* @param {string} name
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async updateThemeJsonConfig(name: string, body: object, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.updateThemeJsonConfig(name, body, options);
|
||||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.updateThemeJsonConfig']?.[localVarOperationServerIndex]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
* Upgrade theme
|
||||
* @param {string} name
|
||||
|
@ -809,14 +926,24 @@ export const ThemeV1alpha1ConsoleApiFactory = function (configuration?: Configur
|
|||
return localVarFp.fetchActivatedTheme(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch configMap of theme by configured configMapName.
|
||||
* Fetch configMap of theme by configured configMapName. It is deprecated.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
|
||||
return localVarFp.fetchThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch converted json config of theme by configured configMapName.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
fetchThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<object> {
|
||||
return localVarFp.fetchThemeJsonConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Fetch setting of theme.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters.
|
||||
|
@ -880,14 +1007,24 @@ export const ThemeV1alpha1ConsoleApiFactory = function (configuration?: Configur
|
|||
return localVarFp.resetThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* Update the configMap of theme setting. It is deprecated.
|
||||
* @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
|
||||
return localVarFp.updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* @param {ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
|
||||
return localVarFp.updateThemeJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
* Upgrade theme
|
||||
* @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters.
|
||||
|
@ -937,6 +1074,20 @@ export interface ThemeV1alpha1ConsoleApiFetchThemeConfigRequest {
|
|||
readonly name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for fetchThemeJsonConfig operation in ThemeV1alpha1ConsoleApi.
|
||||
* @export
|
||||
* @interface ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest
|
||||
*/
|
||||
export interface ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof ThemeV1alpha1ConsoleApiFetchThemeJsonConfig
|
||||
*/
|
||||
readonly name: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for fetchThemeSetting operation in ThemeV1alpha1ConsoleApi.
|
||||
* @export
|
||||
|
@ -1070,6 +1221,27 @@ export interface ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest {
|
|||
readonly configMap: ConfigMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for updateThemeJsonConfig operation in ThemeV1alpha1ConsoleApi.
|
||||
* @export
|
||||
* @interface ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest
|
||||
*/
|
||||
export interface ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof ThemeV1alpha1ConsoleApiUpdateThemeJsonConfig
|
||||
*/
|
||||
readonly name: string
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {object}
|
||||
* @memberof ThemeV1alpha1ConsoleApiUpdateThemeJsonConfig
|
||||
*/
|
||||
readonly body: object
|
||||
}
|
||||
|
||||
/**
|
||||
* Request parameters for upgradeTheme operation in ThemeV1alpha1ConsoleApi.
|
||||
* @export
|
||||
|
@ -1141,9 +1313,10 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetch configMap of theme by configured configMapName.
|
||||
* Fetch configMap of theme by configured configMapName. It is deprecated.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
* @memberof ThemeV1alpha1ConsoleApi
|
||||
*/
|
||||
|
@ -1151,6 +1324,17 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
|
|||
return ThemeV1alpha1ConsoleApiFp(this.configuration).fetchThemeConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch converted json config of theme by configured configMapName.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof ThemeV1alpha1ConsoleApi
|
||||
*/
|
||||
public fetchThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest, options?: RawAxiosRequestConfig) {
|
||||
return ThemeV1alpha1ConsoleApiFp(this.configuration).fetchThemeJsonConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch setting of theme.
|
||||
* @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters.
|
||||
|
@ -1228,9 +1412,10 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* Update the configMap of theme setting. It is deprecated.
|
||||
* @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @deprecated
|
||||
* @throws {RequiredError}
|
||||
* @memberof ThemeV1alpha1ConsoleApi
|
||||
*/
|
||||
|
@ -1238,6 +1423,17 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
|
|||
return ThemeV1alpha1ConsoleApiFp(this.configuration).updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the configMap of theme setting.
|
||||
* @param {ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest} requestParameters Request parameters.
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof ThemeV1alpha1ConsoleApi
|
||||
*/
|
||||
public updateThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest, options?: RawAxiosRequestConfig) {
|
||||
return ThemeV1alpha1ConsoleApiFp(this.configuration).updateThemeJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade theme
|
||||
* @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters.
|
||||
|
|
Loading…
Reference in New Issue