Skip to content

Commit

Permalink
Merge pull request #315 from ExiRain/#89-Rest-delete-SLOT
Browse files Browse the repository at this point in the history
#89 Rest service to delete SLOT
  • Loading branch information
Kristjan259 authored Dec 5, 2023
2 parents 4f71dc3 + 0fdf5c1 commit e8d1762
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
26 changes: 17 additions & 9 deletions DSL/Ruuter.private/POST/rasa/slots/delete.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
assign_values:
assign:
parameters: ${incoming.body}
slot: ${incoming.body.slotName}
next: getDomainFile

getDomainFile:
Expand All @@ -13,7 +13,7 @@ getDomainFile:

validateSlots:
switch:
- condition: ${domainData.response.body.response.slots[parameters.slot_name] != null}
- condition: ${domainData.response.body.response.slots[slot] != null && Object.keys(domainData.response.body.response.slots).includes(slot)}
next: formSlots
next: returnSlotIsMissing

Expand All @@ -24,12 +24,12 @@ formSlots:
headers:
cookie: ${incoming.headers.cookie}
body:
slot: ${parameters.slot_name}
slot: ${slot}
result: formSlots

validateFormSlots:
switch:
- condition: ${formSlots.response.body.response.forms.length == 0}
- condition: ${formSlots.response.body.response.data.forms.length == 0}
next: ruleSlots
next: returnSlotHasDependencyToForms

Expand All @@ -40,13 +40,13 @@ ruleSlots:
headers:
cookie: ${incoming.headers.cookie}
body:
slot: ${parameters.slot_name}
slot: ${slot}
type: "slots"
result: ruleSlots

validateRuleSlots:
switch:
- condition: ${ruleSlots.response.body.response.rules.length == 0}
- condition: ${ruleSlots.response.body.response.data.rules.length == 0}
next: storiesSlots
next: returnSlotHasDependencyToRules

Expand All @@ -57,13 +57,13 @@ storiesSlots:
headers:
cookie: ${incoming.headers.cookie}
body:
slot: ${parameters.slot_name}
slot: ${slot}
type: "slots"
result: storiesSlots

validateStoriesSlots:
switch:
- condition: ${storiesSlots.response.body.response.stories.length == 0}
- condition: ${storiesSlots.response.body.response.data.stories.length == 0}
next: deleteKey
next: returnSlotHasDependencyToStories

Expand All @@ -73,7 +73,7 @@ deleteKey:
url: "[#TRAINING_DMAPPER]:[#TRAINING_DMAPPER_PORT]/merge/remove-key"
body:
object: ${domainData.response.body.response.slots}
key: ${parameters.slot_name}
key: ${slot}
result: keyDeletedData

convertJsonToYaml:
Expand Down Expand Up @@ -107,6 +107,14 @@ saveDomainFile:
file_path: ${fileLocations.response.body.response.domain_location}
content: ${domainYaml.response.body.json}
result: fileResult

updateOpenSearch:
call: http.post
args:
url: "[#TRAINING_PIPELINE]:[#TRAINING_PIPELINE_PORT]/bulk/domain"
body:
input: ${domainYaml.response.body.json}
result: updateSearchResult
next: returnSuccess

returnSuccess:
Expand Down
3 changes: 2 additions & 1 deletion GUI/src/pages/Training/Slots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const Slots: FC = () => {
const queryClient = useQueryClient();
const [filter, setFilter] = useState('');
const [deletableSlot, setDeletableSlot] = useState<string | number | null>(null);
const { data: slots } = useQuery<Slot[]>({
const { data: slots,refetch } = useQuery<Slot[]>({
queryKey: ['slots'],
});

const deleteSlotMutation = useMutation({
mutationFn: ({ id }: { id: string | number }) => deleteSlot(id),
onSuccess: async () => {
await queryClient.invalidateQueries(['slots']);
refetch()
toast.open({
type: 'success',
title: t('global.notification'),
Expand Down
4 changes: 2 additions & 2 deletions GUI/src/services/slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function editSlot(id: string | number, formData: SlotEditDTO) {
return data;
}

export async function deleteSlot(id: string | number) {
const { data } = await api.delete<void>(`slots/${id}`);
export async function deleteSlot(slot: string | number) {
const { data } = await api.post<void>(`slots/delete`, {slotName: slot});
return data;
}

0 comments on commit e8d1762

Please sign in to comment.