Skip to content

Commit 8844fc3

Browse files
committed
Can now delete the incident from the discover incident page
1 parent ce9647c commit 8844fc3

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/Server/Coderr.Server.Abstractions/Security/ClaimsExtensions.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ public static int GetAccountId(this ClaimsPrincipal principal)
3737
throw new InvalidOperationException(
3838
"Failed to find ClaimTypes.NameIdentifier, user is probably not logged in.");
3939

40-
if (!int.TryParse(claim.Value, out var userId))
41-
throw new FormatException(
42-
$"UserId {claim.Value} is not a number. All claims: {principal.ToFriendlyString()}");
40+
if (int.TryParse(claim.Value, out var userId)) return userId;
41+
42+
var ex = new FormatException($"UserId {claim.Value} is not a number.");
43+
foreach (var c in principal.Claims)
44+
{
45+
ex.Data[$"Claim.{c.Type}"] = c.Value;
46+
}
4347

44-
return userId;
48+
throw ex;
4549
}
4650

4751
/// <summary>

src/Server/Coderr.Server.Web/ClientApp/components/discover/incidents/incident.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export default class IncidentComponent extends Vue {
107107
});
108108
}
109109

110+
delete() {
111+
AppRoot.Instance.incidentService.delete(this.incidentId, "yes");
112+
AppRoot.notify("Incident have been removed", 'fa-info', 'success');
113+
this.$router.push({ name: 'suggest'});
114+
}
115+
110116
private displayChart(days: ReportDay[]) {
111117
var labels: Date[] = [];
112118
var series: number[] = [];

src/Server/Coderr.Server.Web/ClientApp/components/discover/incidents/incident.vue.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ <h3>{{incident.Description}} <small class="text-muted">[{{incident.FullName}}]</
1010
<div class="btn-group" role="group">
1111
<a class="btn btn-primary" href="#" v-if="incident.IncidentState == 0" v-on:click.prevent="assignToMe">Assign to me</a>
1212
<div class="dropdown" style="display: inline-block">
13-
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
13+
<button class="btn btn-outline-dark dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
1414
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
1515
<a class="dropdown-item" href="#" v-if="incident.IncidentState == 0" v-on:click.prevent="assignToSomeoneElse">Assign to ..</a>
1616
<a class="dropdown-item" href="#" v-if="!isClosed && !isIgnored" v-on:click.prevent="ignore">Ignore</a>
1717
<a class="dropdown-item" href="#" v-if="!isClosed" v-on:click.prevent="close">Close</a>
18+
<a class="dropdown-item" href="#" v-on:click.prevent="delete">Delete</a>
1819
</div>
1920
</div>
2021
</div>

0 commit comments

Comments
 (0)