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

some improvements #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
375 changes: 217 additions & 158 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,161 +1,220 @@
import { defineInterface } from '@directus/extensions-sdk';
import InterfaceComponent from './interface.vue';
import { defineInterface } from "@directus/extensions-sdk";
import InterfaceComponent from "./interface.vue";

export default defineInterface({
id: 'api-trigger',
name: 'API Trigger',
icon: 'sync',
description: 'Display a button to trigger custom APIs',
component: InterfaceComponent,
hideLabel: true,
hideLoader: true,
types: ['alias'],
localTypes: ['presentation'],
group: 'presentation',
options: ({ collection }) => [
{
field: 'layout',
name: 'Layout',
type: 'string',
schema: {
default_value: 'vertical',
},
meta: {
interface: 'select-dropdown',
options: {
choices: [
{ text: 'Horizontal', value: 'horizontal' },
{ text: 'Vertical', value: 'vertical' },
],
},
},
},
{
field: 'triggers',
name: 'Triggers',
type: 'json',
meta: {
interface: 'list',
options: {
fields: [
{
field: 'label',
name: 'Label',
type: 'string',
meta: {
width: 'half',
interface: 'input',
},
},
{
field: 'size',
name: 'Size',
type: 'string',
schema: {
default_value: '',
},
meta: {
width: 'half',
interface: 'select-dropdown',
options: {
choices: [
{ text: 'x-small', value: 'x-small' },
{ text: 'small', value: 'small' },
{ text: 'default', value: '' },
{ text: 'large', value: 'large' },
{ text: 'x-large', value: 'x-large' },
],
},
},
},
{
field: 'type',
name: 'Type',
type: 'string',
schema: {
default_value: 'normal',
},
meta: {
width: 'half',
interface: 'select-dropdown',
default_value: 'normal',
options: {
choices: [
{ text: 'Primary', value: 'primary' },
{ text: 'Normal', value: 'normal' },
{ text: 'Info', value: 'info' },
{ text: 'Success', value: 'success' },
{ text: 'Warning', value: 'warning' },
{ text: 'Danger', value: 'danger' },
],
},
},
},
{
field: 'icon',
name: 'Icon',
type: 'string',
meta: {
width: 'half',
interface: 'select-icon',
},
},
{
field: 'url',
name: 'URL',
type: 'string',
meta: {
width: 'full',
interface: 'input',
},
},
{
field: 'method',
name: 'Method',
type: 'string',
schema: {
default_value: 'GET',
},
meta: {
interface: 'select-dropdown',
width: 'half',
options: {
choices: [
{ text: 'GET', value: 'GET' },
{ text: 'POST', value: 'POST' },
{ text: 'PUT', value: 'PUT' },
{ text: 'PATCH', value: 'PATCH' },
{ text: 'DELETE', value: 'DELETE' },
],
},
},
},
{
field: 'reload',
name: 'Reload',
type: 'boolean',
schema: {
default_value: false,
},
meta: {
interface: 'boolean',
width: 'half',
},
},
{
field: 'disabledConditions',
name: 'Disabled Conditions',
type: 'json',
meta: {
interface: 'system-filter',
options: {
collectionName: collection,
},
},
},
],
},
},
},
],
id: "api-trigger",
name: "API Trigger",
icon: "sync",
description: "Display a button to trigger custom APIs",
component: InterfaceComponent,
hideLabel: true,
hideLoader: true,
types: ["alias"],
localTypes: ["presentation"],
group: "presentation",
options: ({ collection }) => [
{
field: "layout",
name: "Layout",
type: "string",
schema: {
default_value: "vertical",
},
meta: {
interface: "select-dropdown",
options: {
choices: [
{
text: "Horizontal",
value: "horizontal",
},
{
text: "Vertical",
value: "vertical",
},
],
},
},
},
{
field: "triggers",
name: "Triggers",
type: "json",
meta: {
interface: "list",
options: {
fields: [
{
field: "label",
name: "Label",
type: "string",
meta: {
width: "half",
interface: "input",
},
},
{
field: "size",
name: "Size",
type: "string",
schema: {
default_value: "",
},
meta: {
width: "half",
interface: "select-dropdown",
options: {
choices: [
{
text: "x-small",
value: "x-small",
},
{
text: "small",
value: "small",
},
{
text: "default",
value: "",
},
{
text: "large",
value: "large",
},
{
text: "x-large",
value: "x-large",
},
],
},
},
},
{
field: "type",
name: "Type",
type: "string",
schema: {
default_value: "normal",
},
meta: {
width: "half",
interface: "select-dropdown",
default_value: "normal",
options: {
choices: [
{
text: "Primary",
value: "primary",
},
{
text: "Normal",
value: "normal",
},
{
text: "Info",
value: "info",
},
{
text: "Success",
value: "success",
},
{
text: "Warning",
value: "warning",
},
{
text: "Danger",
value: "danger",
},
],
},
},
},
{
field: "icon",
name: "Icon",
type: "string",
meta: {
width: "half",
interface: "select-icon",
},
},
{
field: "url",
name: "URL",
type: "string",
meta: {
width: "full",
interface: "system-display-template",
options: {
collectionName: collection,
font: "monospace",
placeholder: "/items/collection/{{ id }}",
},
},
},
{
field: "method",
name: "Method",
type: "string",
schema: {
default_value: "GET",
},
meta: {
interface: "select-dropdown",
width: "half",
options: {
choices: [
{
text: "GET",
value: "GET",
},
{
text: "POST",
value: "POST",
},
{
text: "PUT",
value: "PUT",
},
{
text: "PATCH",
value: "PATCH",
},
{
text: "DELETE",
value: "DELETE",
},
],
},
},
},
{
field: "reload",
name: "Reload",
type: "boolean",
schema: {
default_value: false,
},
meta: {
interface: "boolean",
width: "half",
},
},
{
field: "disabledConditions",
name: "Disabled Conditions",
type: "json",
meta: {
interface: "system-filter",
options: {
collectionName: collection,
},
},
},
],
},
},
},
],
});
Loading