66 class =" action"
77 :class =" [trigger.type]"
88 :loading =" loadings[index].value"
9+ :disabled =" disableds[index]"
910 :secondary =" trigger.type !== 'primary'"
1011 v-bind =" { [trigger.size]: true }"
1112 @click =" onClick(trigger.method, parsedUrls[index], index)"
1920<script lang="ts">
2021import { computed , defineComponent , inject , PropType , ref } from ' vue' ;
2122import { useApi , useStores } from ' @directus/extensions-sdk' ;
23+ import { Filter } from ' @directus/shared/types' ;
2224import { render } from ' micromustache' ;
25+ import { checkConditions } from ' ./check-conditions' ;
2326
2427type Trigger = {
2528 label: string ;
@@ -28,6 +31,7 @@ type Trigger = {
2831 icon: string ;
2932 url: string ;
3033 method: string ;
34+ disabledConditions: Filter ;
3135};
3236
3337export default defineComponent ({
@@ -48,10 +52,13 @@ export default defineComponent({
4852
4953 const values = inject (' values' , ref <Record <string , any >>({}));
5054 const parsedUrls = computed (() => props .triggers .map ((trigger ) => render (trigger .url ?? ' ' , values .value )));
55+ const disableds = computed (() => props .triggers .map ((trigger ) => (
56+ trigger .disabledConditions && checkConditions (values .value , trigger .disabledConditions )),
57+ ));
5158
5259 const loadings = props .triggers .map (() => ref (false ));
5360
54- return { loadings , parsedUrls , onClick };
61+ return { loadings , parsedUrls , disableds , onClick };
5562
5663 async function onClick(method : string , url : string , index : number ) {
5764 const loading = loadings [index ];
0 commit comments