Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add token and new notifications #665

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@
"select_ecosystem": "Select Ecosystems",
"registered_email_address": "Registered email address",
"api_token": "API token",
"api_token_header": "API token header",
"consumer_key": "Consumer key",
"consumer_secret": "Consumer secret",
"personal_access_token": "Personal Access Token",
Expand Down
32 changes: 32 additions & 0 deletions src/views/administration/notifications/Alerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export default {
<b-input-group-form-input id="input-destination" :label="$t('admin.destination')" input-group-size="mb-3"
:required="(!(this.alert.hasOwnProperty('teams') && this.alert.teams != null && this.alert.teams.length > 0)).toString()"
type="text" v-model="destination" lazy="true" />
<b-input-group-form-input v-if="this.publisherClass === 'org.dependencytrack.notification.publisher.WebhookPublisher'" id="input-token-header" :label="$t('admin.api_token_header')" input-group-size="mb-3"
type="password" v-model="tokenHeader" lazy="true" />
<b-input-group-form-input v-if="this.publisherClass === 'org.dependencytrack.notification.publisher.WebhookPublisher'" id="input-token" :label="$t('admin.api_token')" input-group-size="mb-3"
type="password" v-model="token" lazy="true" />
<b-input-group-form-input v-if="this.publisherClass === 'org.dependencytrack.notification.publisher.JiraPublisher'" id="input-jira-ticket-type"
:label="$t('admin.jira_ticket_type')" :required="true" type="text" v-model="jiraTicketType" lazy="true" />
<b-form-group v-if="this.publisherClass === 'org.dependencytrack.notification.publisher.SendMailPublisher'"
Expand Down Expand Up @@ -197,6 +201,8 @@ export default {
<div class="list-group-item"><b-form-checkbox value="FILE_SYSTEM">FILE_SYSTEM</b-form-checkbox></div>
<div class="list-group-item"><b-form-checkbox value="INDEXING_SERVICE">INDEXING_SERVICE</b-form-checkbox></div>
<div class="list-group-item"><b-form-checkbox value="REPOSITORY">REPOSITORY</b-form-checkbox></div>
<div class="list-group-item"><b-form-checkbox value="USER_CREATED">USER_CREATED</b-form-checkbox></div>
<div class="list-group-item"><b-form-checkbox value="USER_DELETED">USER_DELETED</b-form-checkbox></div>
</b-form-checkbox-group>
</div>
</b-form-group>
Expand Down Expand Up @@ -233,6 +239,8 @@ export default {
publisherClass: row.publisher.publisherClass,
notificationLevel: row.notificationLevel,
destination: this.parseDestination(row),
token: this.parseToken(row),
tokenHeader: this.parseTokenHeader(row),
jiraTicketType: this.parseJiraTicketType(row),
scope: row.scope,
notifyOn: row.notifyOn,
Expand All @@ -256,6 +264,8 @@ export default {
},
created() {
this.parseDestination(this.alert);
this.parseToken(this.alert);
this.parseTokenHeader(this.alert);
this.parseJiraTicketType(this.alert);
},
watch: {
Expand Down Expand Up @@ -292,6 +302,24 @@ export default {
return null;
}
},
parseToken: function (alert) {
if (alert.publisherConfig) {
let value = JSON.parse(alert.publisherConfig);
if (value) {
return value.token;
}
return null;
}
},
parseTokenHeader: function (alert) {
if (alert.publisherConfig) {
let value = JSON.parse(alert.publisherConfig);
if (value) {
return value.tokenHeader;
}
return null;
}
},
parseJiraTicketType: function (alert) {
if (alert.publisherConfig) {
let value = JSON.parse(alert.publisherConfig);
Expand All @@ -314,12 +342,16 @@ export default {
publisherConfig: JSON.stringify({
destination: this.destination,
jiraTicketType: this.jiraTicketType,
token: this.token,
tokenHeader: this.tokenHeader,
}),
notifyOn: this.notifyOn,
})
.then((response) => {
this.alert = response.data;
this.destination = this.parseDestination(this.alert);
this.token = this.parseToken(this.alert);
this.tokenHeader = this.parseTokenHeader(this.alert);
this.jiraTicketType = this.parseJiraTicketType(this.alert);
EventBus.$emit('admin:alerts:rowUpdate', index, this.alert);
this.$toastr.s(this.$t('message.updated'));
Expand Down
Loading