mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add UI for export in rules
This commit is contained in:
parent
ad2e8ee002
commit
f35ac036eb
7 changed files with 34 additions and 3 deletions
|
|
@ -2501,6 +2501,7 @@ export enum RuleActionType {
|
|||
AddLabel = 'ADD_LABEL',
|
||||
Archive = 'ARCHIVE',
|
||||
Delete = 'DELETE',
|
||||
Export = 'EXPORT',
|
||||
MarkAsRead = 'MARK_AS_READ',
|
||||
SendNotification = 'SEND_NOTIFICATION',
|
||||
Webhook = 'WEBHOOK'
|
||||
|
|
|
|||
|
|
@ -1877,6 +1877,7 @@ enum RuleActionType {
|
|||
ADD_LABEL
|
||||
ARCHIVE
|
||||
DELETE
|
||||
EXPORT
|
||||
MARK_AS_READ
|
||||
SEND_NOTIFICATION
|
||||
WEBHOOK
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { LiqeQuery } from '@omnivore/liqe'
|
||||
import axios from 'axios'
|
||||
import { Any } from 'typeorm'
|
||||
import { ReadingProgressDataSource } from '../datasources/reading_progress_data_source'
|
||||
import { IntegrationType } from '../entity/integration'
|
||||
import { LibraryItem, LibraryItemState } from '../entity/library_item'
|
||||
|
|
@ -115,7 +116,9 @@ const sendToWebhook = async (obj: RuleActionObj) => {
|
|||
|
||||
const exportItem = async (obj: RuleActionObj) => {
|
||||
const userId = obj.userId
|
||||
const integrationNames = obj.action.params
|
||||
const integrations = await findIntegrations(userId, {
|
||||
name: Any(integrationNames.map((param) => param.toUpperCase())),
|
||||
enabled: true,
|
||||
type: IntegrationType.Export,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2168,6 +2168,7 @@ const schema = gql`
|
|||
MARK_AS_READ
|
||||
SEND_NOTIFICATION
|
||||
WEBHOOK
|
||||
EXPORT
|
||||
}
|
||||
|
||||
type RulesError {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ interface NotionPage {
|
|||
url: string
|
||||
}
|
||||
'Omnivore ID': {
|
||||
unique_id: string
|
||||
url: string
|
||||
}
|
||||
'Omnivore URL'?: {
|
||||
url: string
|
||||
|
|
@ -231,7 +231,7 @@ export class NotionClient implements IntegrationClient {
|
|||
}
|
||||
: undefined,
|
||||
'Omnivore ID': {
|
||||
unique_id: item.id,
|
||||
url: item.id,
|
||||
},
|
||||
'Omnivore URL': item.slug
|
||||
? {
|
||||
|
|
@ -275,7 +275,10 @@ export class NotionClient implements IntegrationClient {
|
|||
text: {
|
||||
content: highlight.quote || '',
|
||||
link: {
|
||||
url: getHighlightUrl(item.slug!, highlight.id),
|
||||
url: getHighlightUrl(
|
||||
item.slug || item.id,
|
||||
highlight.id
|
||||
),
|
||||
},
|
||||
},
|
||||
annotations: {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export enum RuleActionType {
|
|||
Delete = 'DELETE',
|
||||
SendNotification = 'SEND_NOTIFICATION',
|
||||
Webhook = 'WEBHOOK',
|
||||
Export = 'EXPORT',
|
||||
}
|
||||
|
||||
export enum RuleEventType {
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ const CreateActionModal = (props: CreateActionModalProps): JSX.Element => {
|
|||
params = form.getFieldValue('labels')
|
||||
} else if (actionType == RuleActionType.Webhook) {
|
||||
params = [form.getFieldValue('url')]
|
||||
} else if (actionType == RuleActionType.Export) {
|
||||
params = form.getFieldValue('integrations')
|
||||
}
|
||||
|
||||
if (props.rule) {
|
||||
|
|
@ -229,6 +231,25 @@ const CreateActionModal = (props: CreateActionModalProps): JSX.Element => {
|
|||
<Input />
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
{actionType == RuleActionType.Export && (
|
||||
<Form.Item
|
||||
label="Integrations"
|
||||
name="integrations"
|
||||
rules={[
|
||||
{ required: true, message: 'Please choose at least one integration' },
|
||||
]}
|
||||
>
|
||||
<Select mode="multiple">
|
||||
<Select.Option key="notion" value="notion">
|
||||
Notion
|
||||
</Select.Option>
|
||||
<Select.Option key="readwise" value="readwise">
|
||||
Readwise
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue