Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(Template model): Added description to template #735

Merged
merged 3 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class Template implements DeletedInterface {
@Pattern(regexp="[a-z0-9._-]+")
private String namespace;

String description;

@Valid
@NotEmpty
private List<Task> tasks;
Expand Down Expand Up @@ -95,6 +97,7 @@ public Template toDeleted() {
return new Template(
this.id,
this.namespace,
this.description,
this.tasks,
this.errors,
true
Expand Down
10 changes: 9 additions & 1 deletion ui/src/components/templates/Templates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
>
{{ row.item.id }}
</router-link>
&nbsp;<markdown-tooltip
:id="row.item.namespace + '-' + row.item.id"
:description="row.item.description"
:title="row.item.namespace + '.' + row.item.id"
:modal="true"
/>
</template>
</b-table>
</template>
Expand Down Expand Up @@ -86,6 +92,7 @@
import Kicon from "../Kicon"
import RestoreUrl from "../../mixins/restoreUrl";
import _merge from "lodash/merge";
import MarkdownTooltip from "@/components/layout/MarkdownTooltip";

export default {
mixins: [RouteContext, RestoreUrl, DataTableActions],
Expand All @@ -96,7 +103,8 @@
DataTable,
SearchField,
NamespaceSelect,
Kicon
Kicon,
MarkdownTooltip,
},
data() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private Template createTemplate() {
return Template.builder()
.id(IdUtils.create())
.namespace("kestra.test")
.description("My template description")
.tasks(Arrays.asList(t1, t2)).build();
}

Expand All @@ -52,6 +53,7 @@ void create() {
Template result = client.toBlocking().retrieve(POST("/api/v1/templates", template), Template.class);
Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(createdTemplate.getId(), is(template.getId()));
assertThat(createdTemplate.getDescription(), is("My template description"));
}

@Test
Expand Down Expand Up @@ -95,11 +97,12 @@ void updateTemplate() {
Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(template.getTasks().size(), is(2));
Task t3 = Return.builder().id("task-3").type(Return.class.getName()).format("test").build();
Template updateTemplate = Template.builder().id(template.getId()).namespace(template.getNamespace()).tasks(Arrays.asList(t3)).build();
Template updateTemplate = Template.builder().id(template.getId()).namespace(template.getNamespace()).description("My new template description").tasks(Arrays.asList(t3)).build();
client.toBlocking().retrieve(PUT("/api/v1/templates/" + template.getNamespace() + "/" + template.getId(), updateTemplate), Template.class);
Template updatedTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(updatedTemplate.getTasks().size(), is(1));
assertThat(updatedTemplate.getTasks().get(0).getId(), is("task-3"));
assertThat(updatedTemplate.getDescription(),is("My new template description"));
}

@Test
Expand Down