Compare commits
1 Commits
AUT-1372
...
new-find-p
Author | SHA1 | Date | |
---|---|---|---|
![]() |
69ae448d64 |
13
packages/backend/src/apps/gitlab/actions.ts
Normal file
13
packages/backend/src/apps/gitlab/actions.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import FindProjectMergeRequests from './actions/find-project-merge-requests';
|
||||
|
||||
export default class Actions {
|
||||
findProjectMergeRequests: FindProjectMergeRequests;
|
||||
|
||||
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
|
||||
this.findProjectMergeRequests = new FindProjectMergeRequests(
|
||||
connectionData,
|
||||
parameters
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
import { Gitlab } from '@gitbeaker/node';
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default class FindProjectMergeRequests {
|
||||
client: any;
|
||||
projectId: number;
|
||||
state: string;
|
||||
|
||||
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
|
||||
if (connectionData?.accessToken) {
|
||||
this.client = new Gitlab({
|
||||
host: `https://${connectionData.host}`,
|
||||
oauthToken: connectionData?.accessToken as string,
|
||||
});
|
||||
}
|
||||
|
||||
if (parameters.project) {
|
||||
this.projectId = parameters.project as number;
|
||||
}
|
||||
|
||||
if (parameters.state) {
|
||||
this.state = parameters.state as string;
|
||||
}
|
||||
}
|
||||
|
||||
async run() {
|
||||
const mergeRequests = await this.client.MergeRequests.all({
|
||||
state: this.state,
|
||||
projectId: this.projectId,
|
||||
maxPages: 1,
|
||||
});
|
||||
|
||||
return { data: mergeRequests };
|
||||
}
|
||||
}
|
10
packages/backend/src/apps/gitlab/data.ts
Normal file
10
packages/backend/src/apps/gitlab/data.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import ListProjects from './data/list-projects';
|
||||
|
||||
export default class Data {
|
||||
listProjects: ListProjects;
|
||||
|
||||
constructor(connectionData: IJSONObject, parameters?: IJSONObject) {
|
||||
this.listProjects = new ListProjects(connectionData, parameters);
|
||||
}
|
||||
}
|
26
packages/backend/src/apps/gitlab/data/list-projects.ts
Normal file
26
packages/backend/src/apps/gitlab/data/list-projects.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Gitlab } from '@gitbeaker/node';
|
||||
import type { IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default class ListProjects {
|
||||
client?: any;
|
||||
|
||||
constructor(connectionData: IJSONObject, parameters?: IJSONObject) {
|
||||
if (connectionData?.accessToken) {
|
||||
this.client = new Gitlab({
|
||||
host: `https://${connectionData.host}`,
|
||||
oauthToken: connectionData?.accessToken as string,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async run() {
|
||||
const projects = await this.client.Projects.all({
|
||||
membership: true,
|
||||
});
|
||||
|
||||
return projects.map((project: any) => ({
|
||||
value: project.id,
|
||||
name: project.name_with_namespace,
|
||||
}));
|
||||
}
|
||||
}
|
@@ -1,15 +1,25 @@
|
||||
import Authentication from './authentication';
|
||||
import {
|
||||
IService,
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import Authentication from './authentication';
|
||||
import Actions from './actions';
|
||||
import Data from './data';
|
||||
|
||||
export default class Gitlab implements IService {
|
||||
authenticationClient: IAuthentication;
|
||||
actions: Actions;
|
||||
data: Data;
|
||||
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
constructor(
|
||||
appData: IApp,
|
||||
connectionData: IJSONObject,
|
||||
parameters: IJSONObject
|
||||
) {
|
||||
this.authenticationClient = new Authentication(appData, connectionData);
|
||||
this.actions = new Actions(connectionData, parameters);
|
||||
this.data = new Data(connectionData, parameters);
|
||||
}
|
||||
}
|
||||
|
@@ -234,5 +234,76 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"name": "Find project merge requests",
|
||||
"key": "findProjectMergeRequests",
|
||||
"description": "Find merge requests for a project.",
|
||||
"substeps": [
|
||||
{
|
||||
"key": "chooseAccount",
|
||||
"name": "Choose account"
|
||||
},
|
||||
{
|
||||
"key": "setupAction",
|
||||
"name": "Set up action",
|
||||
"arguments": [
|
||||
{
|
||||
"label": "Project",
|
||||
"key": "project",
|
||||
"type": "dropdown",
|
||||
"required": true,
|
||||
"description": "Search for merge requests in this project.",
|
||||
"variables": false,
|
||||
"source": {
|
||||
"type": "query",
|
||||
"name": "getData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "listProjects"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "State",
|
||||
"key": "state",
|
||||
"type": "dropdown",
|
||||
"required": true,
|
||||
"description": "Filter merge requests by their state.",
|
||||
"variables": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "All",
|
||||
"value": "all"
|
||||
},
|
||||
{
|
||||
"label": "Opened",
|
||||
"value": "opened"
|
||||
},
|
||||
{
|
||||
"label": "Closed",
|
||||
"value": "closed"
|
||||
},
|
||||
{
|
||||
"label": "Locked",
|
||||
"value": "locked"
|
||||
},
|
||||
{
|
||||
"label": "Merged",
|
||||
"value": "merged"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "testStep",
|
||||
"name": "Test action"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -68,6 +68,7 @@ type ActionSubstepArgument {
|
||||
variables: Boolean
|
||||
source: ActionSubstepArgumentSource
|
||||
dependsOn: [String]
|
||||
options: [TriggerSubstepArgumentOption]
|
||||
}
|
||||
|
||||
type ActionSubstepArgumentSource {
|
||||
@@ -76,6 +77,11 @@ type ActionSubstepArgumentSource {
|
||||
arguments: [ActionSubstepArgumentSourceArgument]
|
||||
}
|
||||
|
||||
type TriggerSubstepArgumentOption {
|
||||
label: String
|
||||
value: JSONObject
|
||||
}
|
||||
|
||||
type ActionSubstepArgumentSourceArgument {
|
||||
name: String
|
||||
value: String
|
||||
|
@@ -94,6 +94,10 @@ export const GET_APPS = gql`
|
||||
description
|
||||
variables
|
||||
dependsOn
|
||||
options {
|
||||
label
|
||||
value
|
||||
}
|
||||
source {
|
||||
type
|
||||
name
|
||||
|
Reference in New Issue
Block a user