Skip to content

Commit

Permalink
feat(janus-idp#1019): implemented feedback plugin (janus-idp#1045)
Browse files Browse the repository at this point in the history
* feat(feedback): add feedback frontend and backend plugin

Signed-off-by: Yash Oswal <[email protected]>

* tests(feedback): fixed tests failing for entity page

Signed-off-by: Yash Oswal <[email protected]>

* feat(feedback-backend): add return statement before sending HTTP response

This helps in preventing further code execution and improves the control flow.

Signed-off-by: Yash Oswal <[email protected]>

* feat(feedback): update readme files  in feedback plugin

- fixed build pipeline was failing.
- fixed failing test cases

Signed-off-by: Yash Oswal <[email protected]>

* fix(feedback): add tsc script to package.json for feedback plugin

Signed-off-by: Yash Oswal <[email protected]>

* fix(feedback): removed duplicated code block

- removed duplicated code from backend plugin
- add janus-idp repo info to package.json

Signed-off-by: Yash Oswal <[email protected]>

* chore(feedback): add yarn.lock file with feedback plugin deps
- updated frontend plugin to work isolated

Signed-off-by: Yash Oswal <[email protected]>

* chore(feedback): add OWNERS file to feedback plugins

Signed-off-by: Yash Oswal <[email protected]>

---------

Signed-off-by: Yash Oswal <[email protected]>
  • Loading branch information
yashoswalyo authored Jan 18, 2024
1 parent da3d8fc commit 34c312e
Show file tree
Hide file tree
Showing 78 changed files with 4,712 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ yarn.lock @janus-idp/maintainers-plugins
/plugins/orchestrator @janus-idp/maintainers-plugins @caponetto @jkilzi
/plugins/orchestrator-backend @janus-idp/maintainers-plugins @caponetto @jkilzi
/plugins/orchestrator-common @janus-idp/maintainers-plugins @caponetto @jkilzi
/plugins/feedback @janus-idp/maintainers-plugins @yashoswalyo @riginoommen @deshmukhmayur
/plugins/feedback-backend @janus-idp/maintainers-plugins @yashoswalyo @riginoommen @deshmukhmayur
1 change: 1 addition & 0 deletions plugins/feedback-backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
8 changes: 8 additions & 0 deletions plugins/feedback-backend/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- yashoswalyo
- riginoommen
- deshmukhmayur
reviewers:
- yashoswalyo
- riginoommen
- deshmukhmayur
91 changes: 91 additions & 0 deletions plugins/feedback-backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Feedback Backend

This is feedback-backend plugin which provides Rest API to create feedbacks.

It is also repsonsible for creating JIRA tickets,

## Getting started

### Installation

1. Install the backend plugin.

```bash
# From your backstage root directory
yarn workspace backend add @janus-idp/backstage-plugin-feedback-backend
```

2. Then create a new file `packages/backend/src/plugins/feedback.ts` and add the following:

```ts
import { Router } from 'express';

import { createRouter } from '@janus-idp/backstage-plugin-feedback-backend';

import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
config: env.config,
discovery: env.discovery,
});
}
```

3. Next we wire this into overall backend router, edit `packages/backend/src/index.ts`:

```ts
import feedback from './plugins/feedback';

// ...
async function main() {
// ...
const feedbackEnv = useHotMemoize(module, () => createEnv('feedback'));
apiRouter.use('/feedback', await feedback(feedbackEnv));
}
```

4. Now add below config in your `app-config.yaml` file.

```yaml
feedback:
integrations:
jira:
# Under this object you can define multiple jira hosts
- host: ${JIRA_HOST_URL}
token: ${JIRA_TOKEN}

email:
## Email integration uses nodemailer to send emails
host: ${EMAIL_HOST}
port: ${EMAIL_PORT} # defaults to 587, if not found

## Email address of sender
from: ${EMAIL_FROM}

## [optional] Authorization using user and password
auth:
user: ${EMAIL_USER}
pass: ${EMAIL_PASS}

# boolean
secure: false

# Path to ca certificate if required by mail server
caCert: ${NODE_EXTRA_CA_CERTS}
```
### Set up frontend plugin
Follow instructions provided [feedback-plugin](../feedback/README.md)
### API reference
The API specifications file can be found at [docs/openapi3_0](./docs/openapi3_0.yaml)
### Run
1. Now run `yarn workspace @janus-idp/backstage-plugin-feedback-backedn start-backend`.
25 changes: 25 additions & 0 deletions plugins/feedback-backend/app-config.janus-idp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
feedback:
integrations:
jira:
# Under this object you can define multiple jira hosts
- host: ${JIRA_HOST_URL}
token: ${JIRA_TOKEN}

email:
## Email integration uses nodemailer to send emails
host: ${EMAIL_HOST}
port: ${EMAIL_PORT} # defaults to 587, if not found

# Email address of sender
from: ${EMAIL_FROM}

## Authorization using user and password
auth:
user: ${EMAIL_USER}
pass: ${EMAIL_PASS}

# boolean
secure: false

# Path to ca certificate if required by mail server
caCert: ${NODE_EXTRA_CA_CERTS}
71 changes: 71 additions & 0 deletions plugins/feedback-backend/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Configuration options for the application.
*/
export interface Config {
feedback?: {
integrations: {
/**
* Configuration options for JIRA integration.
* It is an array, which can be used to set up multiple jira servers at the same time.
*/
jira?: Array<{
/**
* The hostname or URL of the JIRA organization.
*/
host: string;

/**
* The access token for authenticating with JIRA.
*/
token: string;
}>;

/**
* Configuration options for email integration.
*/
email?: {
/**
* The SMTP server's hostname or IP address.
*/
host: string;

/**
* The port number to use for the SMTP server.
*/
port: number;

/**
* Optional authentication settings for the SMTP server.
*/
auth?: {
/**
* The username to use for SMTP server authentication.
*/
user?: string;

/**
* The password to use for SMTP server authentication.
* @visibility secret
*/
pass?: string;
};

/**
* Set to `true` if you want to use SSL/TLS for the SMTP connection.
* Default is `false`.
*/
secure?: boolean;

/**
* The email address from which emails will be sent.
*/
from?: string;

/**
* Path to a custom CA certificate file.
*/
caCert?: string;
};
};
};
}
Loading

0 comments on commit 34c312e

Please sign in to comment.