-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Components - invision_community (#12623)
* invision_community init * [Components] invision_community #12563 Sources - New Member (Instant) - New Forum Topic (Instant) - New Topic Post (Instant) Actions - Create Member - Update Member - Create Forum Topic * pnpm update
- Loading branch information
1 parent
f6d3a72
commit 0355b13
Showing
14 changed files
with
946 additions
and
211 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
components/invision_community/actions/create-forum-topic/create-forum-topic.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import invisionCommunity from "../../invision_community.app.mjs"; | ||
|
||
export default { | ||
key: "invision_community-create-forum-topic", | ||
name: "Create Forum Topic", | ||
description: "Creates a new forum topic. [See the documentation](https://invisioncommunity.com/developers/rest-api?endpoint=forums/topics/postindex)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
invisionCommunity, | ||
forumId: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"forumId", | ||
], | ||
}, | ||
title: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"title", | ||
], | ||
}, | ||
postContent: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"postContent", | ||
], | ||
}, | ||
author: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"authorId", | ||
], | ||
}, | ||
tags: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"tags", | ||
], | ||
optional: true, | ||
}, | ||
openTime: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"openTime", | ||
], | ||
optional: true, | ||
}, | ||
closeTime: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"closeTime", | ||
], | ||
optional: true, | ||
}, | ||
hidden: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"hidden", | ||
], | ||
}, | ||
pinned: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"pinned", | ||
], | ||
}, | ||
featured: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"featured", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
|
||
const response = await this.invisionCommunity.createForumTopic({ | ||
$, | ||
params: { | ||
forum: this.forumId, | ||
title: this.title, | ||
post: this.postContent, | ||
author: this.author, | ||
tags: parseObject(this.tags)?.join(","), | ||
open_time: this.openTime, | ||
close_time: this.closeTime, | ||
hidden: +this.hidden, | ||
pinned: +this.pinned, | ||
featured: +this.featured, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully created forum topic with title "${this.title}"`); | ||
return response; | ||
}, | ||
}; |
61 changes: 61 additions & 0 deletions
61
components/invision_community/actions/create-member/create-member.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import invisionCommunity from "../../invision_community.app.mjs"; | ||
|
||
export default { | ||
key: "invision_community-create-member", | ||
name: "Create Member", | ||
description: "Creates a new member. [See the documentation](https://invisioncommunity.com/developers/rest-api?endpoint=core/members/postindex)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
invisionCommunity, | ||
name: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"name", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"email", | ||
], | ||
}, | ||
password: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"password", | ||
], | ||
optional: true, | ||
}, | ||
groupId: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"groupId", | ||
], | ||
optional: true, | ||
}, | ||
validated: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"validated", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.invisionCommunity.createMember({ | ||
$, | ||
params: { | ||
name: this.name, | ||
email: this.email, | ||
password: this.password, | ||
group: this.groupId, | ||
registrationIpAddress: this.registrationIpAddress, | ||
validated: this.validated, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created member with ID ${response.id}`); | ||
return response; | ||
}, | ||
}; |
69 changes: 69 additions & 0 deletions
69
components/invision_community/actions/update-member/update-member.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import invisionCommunity from "../../invision_community.app.mjs"; | ||
|
||
export default { | ||
key: "invision_community-update-member", | ||
name: "Update Member", | ||
description: "Updates an existing member's details. [See the documentation](https://invisioncommunity.com/developers/rest-api?endpoint=core/members/postitem)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
invisionCommunity, | ||
memberId: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"memberId", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"name", | ||
], | ||
optional: true, | ||
}, | ||
email: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"email", | ||
], | ||
optional: true, | ||
}, | ||
password: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"password", | ||
], | ||
optional: true, | ||
}, | ||
groupId: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"groupId", | ||
], | ||
optional: true, | ||
}, | ||
validated: { | ||
propDefinition: [ | ||
invisionCommunity, | ||
"validated", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.invisionCommunity.updateMember({ | ||
$, | ||
memberId: this.memberId, | ||
params: { | ||
name: this.name, | ||
email: this.email, | ||
password: this.password, | ||
group: this.groupId, | ||
registrationIpAddress: this.registrationIpAddress, | ||
validated: this.validated, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully updated member with Id: ${this.memberId}`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; |
Oops, something went wrong.