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(ui): add the ability to remove tasks and other items #6902

Merged
merged 1 commit into from
Jan 23, 2025
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
24 changes: 23 additions & 1 deletion ui/src/components/code/components/collapse/Collapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:key="elementIndex"
:section="item.title"
:element
@remove-element="removeElement(item.title, elementIndex)"
/>
</template>

Expand All @@ -26,18 +27,21 @@
</template>

<script setup lang="ts">
import {PropType, ref} from "vue";
import {nextTick, PropType, ref} from "vue";

import {CollapseItem} from "../../utils/types";

import Creation from "./buttons/Creation.vue";
import Element from "./Element.vue";

const emits = defineEmits(["remove"]);

const props = defineProps({
items: {
type: Array as PropType<CollapseItem[]>,
required: true,
},
flow: {type: String, default: undefined},
creation: {type: Boolean, default: false},
});
const expanded = ref<CollapseItem["title"][]>([]);
Expand All @@ -47,6 +51,24 @@
if (item.elements?.length) expanded.value.push(item.title);
});
}

import YamlUtils from "../../../../utils/yamlUtils";
const removeElement = (title: string, index: number) => {
props.items.forEach((item) => {
if (item.title === title) {
nextTick(() => {
const ID = item.elements?.[index].id;

item.elements?.splice(index, 1);
emits(
"remove",
YamlUtils.deleteTask(props.flow, ID, title.toUpperCase()),
);
expanded.value = expanded.value.filter((v) => v !== title);
});
}
});
};
</script>

<style scoped lang="scss">
Expand Down
11 changes: 11 additions & 0 deletions ui/src/components/code/components/collapse/Element.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@
<div class="flex-grow-1 label">
{{ props.element.id }}
</div>

<el-button
@click.prevent.stop="emits('removeElement')"
:icon="DeleteOutline"
size="small"
class="border-0"
/>
</div>
</template>

<script setup lang="ts">
import {computed} from "vue";

import {DeleteOutline} from "../../utils/icons";

import TaskIcon from "@kestra-io/ui-libs/src/components/misc/TaskIcon.vue";

const emits = defineEmits(["removeElement"]);

const props = defineProps({
section: {type: String, required: true},
element: {type: Object, required: true},
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/code/segments/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

<hr class="m-0 mt-3">

<Collapse :items="sections" creation />
<Collapse
:items="sections"
creation
:flow
@remove="(yaml) => emits('updateTask', yaml)"
/>
</template>

<Task
Expand Down
Loading