Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.0 KB
Raw Blame
import { DropdownOption, Property } from '@activepieces/pieces-framework';
import { ContentfulAuth, makeClient } from '../common';
import { isEmpty } from '@activepieces/pieces-framework';

const Locale = Property.Dropdown({
  auth: ContentfulAuth,
  displayName: 'Content Locale',
  required: true,
  refreshers: [],
  options: async ({ auth }) => {
    if (isEmpty(auth) || !auth) {
      return {
        disabled: true,
        options: [],
        placeholder: 'Please connect your account',
      };
    }
    const { client } = makeClient(auth);
    try {
      const response = await client.locale.getMany({});
      const options: DropdownOption<string>[] = response.items.map(
        (locale) => ({ label: locale.name, value: locale.code })
      );
      return {
        disabled: false,
        options,
      };
    } catch (e) {
      console.debug(e);
      return {
        disabled: true,
        options: [],
        placeholder: 'Please check your Contentful connection settings',
      };
    }
  },
});

export default Locale;