Skip to content

Commit

Permalink
feat(jdbc): hide taskrun menus on jdbc
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jun 17, 2022
1 parent 8a3bae4 commit 2932134
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import javax.annotation.Nullable;

public interface ExecutionRepositoryInterface extends SaveRepositoryInterface<Execution> {
Boolean isTaskRunEnabled();

Optional<Execution> findById(String id);

ArrayListTotal<Execution> findByFlowId(String namespace, String id, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public AbstractExecutionRepository(AbstractJdbcRepository<Execution> jdbcReposit
this.executorStateStorage = executorStateStorage;
}

public Boolean isTaskRunEnabled() {
return false;
}

@Override
public Optional<Execution> findById(String id) {
return jdbcRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public ElasticSearchExecutionRepository(
super(client, elasticSearchIndicesService, modelValidator, executorsUtils, Execution.class);
}

public Boolean isTaskRunEnabled() {
return true;
}

@Override
public Optional<Execution> findById(String id) {
return this.getRequest(INDEX_NAME, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
public class MemoryExecutionRepository implements ExecutionRepositoryInterface {
private final Map<String, Execution> executions = new HashMap<>();

public Boolean isTaskRunEnabled() {
return false;
}

@Override
public ArrayListTotal<Execution> find(Pageable pageable, String query, String namespace, String flowId, ZonedDateTime startDate, ZonedDateTime endDate, List<State.Type> state) {
throw new UnsupportedOperationException();
Expand Down
1 change: 1 addition & 0 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
},
loadGeneralRessources() {
this.$store.dispatch("plugin/icons")
this.$store.dispatch("misc/loadConfigs")
},
grabThemeResources() {
// eslint-disable-next-line no-undef
Expand Down
6 changes: 3 additions & 3 deletions ui/src/override/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>

<span slot="footer">
<span class="version">{{ version ? version.version : '' }}</span>
<span class="version">{{ configs ? configs.version : '' }}</span>
</span>

<span slot="toggle-icon">
Expand Down Expand Up @@ -118,6 +118,7 @@
element: "TaskRunMenuIcon",
class: "menu-icon"
},
hidden: !(this.configs && this.configs.isTaskRunEnabled)
},
{
href: "/logs",
Expand Down Expand Up @@ -195,7 +196,6 @@
},
created() {
this.menu = this.disabledCurrentRoute(this.generateMenu());
this.$store.dispatch("misc/loadVersion")
},
watch: {
$route() {
Expand All @@ -215,7 +215,7 @@
})
},
computed: {
...mapState("misc", ["version"])
...mapState("misc", ["configs"])
}
};
</script>
Expand Down
12 changes: 6 additions & 6 deletions ui/src/stores/miscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import Vue from "vue"
export default {
namespaced: true,
state: {
version: undefined,
configs: undefined,
},

actions: {
loadVersion({commit}) {
return Vue.axios.get("/api/v1/version").then(response => {
commit("setVersion", response.data)
loadConfigs({commit}) {
return Vue.axios.get("/api/v1/configs").then(response => {
commit("setConfigs", response.data)

return response.data;
})
},
},
mutations: {
setVersion(state, version) {
state.version = version
setConfigs(state, configs) {
state.configs = configs
}
},
getters: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.kestra.webserver.controllers;

import io.kestra.core.repositories.ExecutionRepositoryInterface;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.scheduling.TaskExecutors;
import io.micronaut.scheduling.annotation.ExecuteOn;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import lombok.Builder;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import io.kestra.core.utils.VersionProvider;
Expand All @@ -19,21 +21,30 @@ public class MiscController {
@Inject
VersionProvider versionProvider;

@Inject
ExecutionRepositoryInterface executionRepository;

@Get("/ping")
@Hidden
public HttpResponse<?> ping() {
return HttpResponse.ok("pong");
}

@Get("/api/v1/version")
@Get("/api/v1/configs")
@ExecuteOn(TaskExecutors.IO)
@Operation(tags = {"Misc"}, summary = "Get current version")
public Version version() {
return new Version(versionProvider.getVersion());
@Operation(tags = {"Misc"}, summary = "Get current configurations")
public Configuration configuration() {
return Configuration
.builder()
.version(versionProvider.getVersion())
.isTaskRunEnabled(executionRepository.isTaskRunEnabled())
.build();
}

@Value
public static class Version {
@Builder
public static class Configuration {
String version;
Boolean isTaskRunEnabled;
}
}

0 comments on commit 2932134

Please sign in to comment.