0.0.65 • Published 1 year ago

@bigbinary/neeto-rules v0.0.65

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@bigbinary/neeto-rules

neetoRules is the library that manages automation rules across neeto products.

Installation

yarn add @bigbinary/neeto-rules

neetoRules has a few peer dependencies that are required for the proper functioning of the package. Install all the peer dependencies using the below command:

yarn add @bigbinary/neetoui @bigbinary/neeto-icons ramda@^0.28.0 classnames@^2.3.1

Usage

<NeetoRulesForm data={initialProps}>
  {({ formattedValues, values, ...formikBag }) => (
    <>
      <InputField name="name" data={initialProps} />
      <TextareaField name="description" data={initialProps} />
      <SelectField name="projectId" data={initialProps} />
      <Events name="events" data={initialProps} />
      <RadioField name="performer" data={initialProps} />
      <Card title="Conditions">
        <Conditions name="conditions" data={initialProps} />
      </Card>
      <ConditionGroups name="conditionGroups" data={initialProps} />
      <Actions name="actions" data={initialProps} />
    </>
  )}
</NeetoRulesForm>

NeetoRules API

Prop NameDescription
dataObject { [fieldName] : FieldProps } FieldProps
childrenchildren?: React.ReactNode ({ formattedValues, ...props: FormikProps<Values>}) => ReactNode
classNameTo provide external classnames to Form component. string
handleSubmit(values: Values, formikBag: FormikBag) => void FormikBag
handleCancelCallback on clicking Form cancel button.

Field Props

PropDescription
nameName of the field string
labelTo specify the text to be displayed above the field. string
typeType of the field. Supported Field Types string
valueDefault value of the Field. It can be string or array based on the field type.
componentPropsComponent specific props. Component Props
options[{ label: "", value: ""}] For Field Types radio and dropdown.
conditionOptionsIf Field Type is condition Options
eventOptionsIf Field Type is events Options
actionOptionsIf Field Type is actions Options

Options

PropDescription
labelOption label string
valueOption value string
typeType of the option field
dropdownOptionsIf the type is dropdown, multi-select, or multi-select-create

Field Types

  • text
  • long-text
  • dropdown
  • radio
  • events
  • actions
  • condition
  • condition-group

Component Props

PropDescriptionDefault value
requiredTo specify whether the input field is required or not. Booleantrue

Field Components

InputField

const initialProps = {
  ...otherProps,
  firstName: {
    label: "First Name",
    type: "text",
    value: "", // Default value.
    componentProps: {
      placeholder: "Enter name",
    },
  },
};

<InputField name="firstName" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string

TextareaField

const initialProps = {
  ...otherProps,
  description: {
    label: "Description",
    type: "long-text",
    value: "", // Default value.
  },
};

<TextareaField name="description" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp string
labelTo specify the text to be displayed above the field. string

SelectField

const initialProps = {
  ...otherProps,
  user: {
    label: "Project",
    type: "dropdown",
    options: [{ label: "Oliver", value: "oliver" }],
    value: "oliver", // Default selected option will be Oliver
  },
};

<SelectField name="user" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
optionsTo provide options for the Select input. [{label, value}].
onChange(value, setValue) => void setValue is to set the new value

RadioField

const initialProps = {
  ...otherProps,
  performer: {
    label: "Performer",
    type: "radio",
    value: "any", // Default selected value will be "any"
    options: [
      { label: "Admin", value: "admin" },
      { label: "Any", value: "any" },
    ],
  },
};

<RadioField name="performer" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
optionsTo provide options for the Radio input. [{label, value}].

Events

const initialProps = {
  ...otherProps,
  events: {
    label: "Events",
    type: "events",
    value: [{ id: "1", name: "when_created" }], // Default value
    eventOptions: [
      { label: "When Created", value: "when_created" },
      { label: "When Updated", value: "when_updated" },
      { label: "When Assigned", value: "when_deleted" },
    ],
  },
};

<Events name="events" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
onSelectEvent(name, selectedOption) => void This method will trigger when we select an event option. The name is to refer the event in the formik context.

Conditions

const initialProps = {
  ...otherProps,
  conditions: {
    label: "Conditions",
    type: "condition",
    conditionOptions: [
      {
        value: "status",
        label: "Status",
        type: "dropdown", // Types : text, textarea, dropdown, multi-select, multi-select-create, date.
        dropdownOptions: [
          { label: "Open", value: "open" },
          { label: "Closed", value: "closed" },
        ],
      },
      { value: "name", label: "Name", type: "text" },
      {
        value: "tags",
        label: "Tags",
        type: "multi-select-create",
      },
    ],
    value: [
      {
        id: "1",
        field: "status",
        verb: "is",
        value: "open",
        joinType: "and_operator",
      },
      {
        id: "2",
        field: "name",
        verb: "is",
        value: "Test",
        joinType: "and_operator",
      },
    ],
  },
};

<Card title="Conditions">
  <Conditions name="conditions" data={initialProps} />
</Card>;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
isConditionGroupTo specify whether the component is part of ConditionGroups field. Default is false
onSelectCondition(name, selectedOption) => void This method will trigger when we select a condition. The name is to refer the condition in the formik context.
selectedConditionOptions(selectedCondition)=> [{label, value}] To provide options for the selected condition if the type of selected condition is dropdown, multi-select, or multi-select-create

ConditionGroups

const initialProps = {
  ...otherProps,
  conditionGroups: {
    label: "Condition Groups",
    type: "condition-group",
    conditionOptions: [
      {
        value: "status",
        label: "Status",
        type: "dropdown", // Types : text, textarea, dropdown, multi-select, multi-select-create, date.
        dropdownOptions: [
          { label: "Open", value: "open" },
          { label: "Closed", value: "closed" },
        ],
      },
      { value: "name", label: "Name", type: "text" },
      {
        value: "tags",
        label: "Tags",
        type: "multi-select-create",
      },
    ],
    value: [
      {
        id: "1",
        joinType: "and_operator",
        conditions: [
          {
            id: "1",
            field: "status", Specify the value of the selected condition.
            verb: "is",
            value: "open",
            joinType: "and_operator",
          },
          {
            id: "2",
            field: "name",
            verb: "is",
            value: "Test",
            joinType: "and_operator",
          },
        ],
      },
    ],
  },
}

 <ConditionGroups name="conditionGroups" data={initialProps} />

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
onSelectCondition(name, selectedOption) => void This method will trigger when we select a condition. The name is to refer the condition in the formik context.
selectedConditionOptions(selectedCondition)=> [{label, value}] To provide options for the selected condition if the type of selected condition is dropdown, multi-select, or multi-select-create

Actions

const initialProps = {
  ...otherProps,
  actions: {
    label: "Actions",
    type: "actions",
    actionOptions: [
      {
        value: "change_status",
        label: "Change Status",
        type: "dropdown", // Types : emailToIds, email, dropdown, list, multiSelect, note
        dropdownOptions: [
          { label: "Open", value: "open" },
          { label: "Closed", value: "closed" },
        ],
      },
      {
        value: "email_to",
        label: "Email To",
        type: "emailToIds",
        hideSubject: true, // Hide subject field if this prop is true
      },
    ],
    value: [
      {
        id: "1",
        name: "email_to", // Specify the value of the selected action.
        metadata: { emails: ["a@a.com"], subject: "test", body: "test" },
      },
      {
        id: "2",
        name: "change_status",
        metadata: { value: "closed" },
      },
    ],
  },
};

<Actions name="fieldName" data={initialProps} />;

API

PropDescription
dataThe same initialProp that is passed to data prop in NeetoRulesForm.
nameName of the field. The name should be same as that in the initialProp
labelTo specify the text to be displayed above the field. string
onSelectAction(name, selectedOption) => void This method will trigger when we select an action. The name is to refer the action in the formik context.
selectedActionOptions(selectedAction)=> [{label, value}] To provide options for the selected action if the type of selected action is dropdown, or multi-select

Example: Refer Example App

Development

Install all the dependencies by executing the following command

yarn install

Start the development server using the yarn start command. Port: 8080

Building

The neetoRules package gets auto-published to npm for every new merge to the main branch. You can checkout the publish workflow in git actions to get a live update.

Integrations

ProjectPages
neeto-desk-webAutomation rules, views, Canned response
neeto-planner-webAutomation rules
0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.58

1 year ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.39

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago