Error 404 when editing non-Cilium network policies in Threat Monitoring

Summary

In Threat Monitoring > Policies, it is impossible to edit custom network policies that don't have the Cilium kind.

Steps to reproduce

Example Project

https://staging.gitlab.com/defend-team-test/cnp-alert-demo/-/threat_monitoring

What is the current bug behavior?

Error 404.

What is the expected correct behavior?

No error 404.

Implementation plan

  • backend update NetworkPolicyType with new field: kind,
  • frontend read value of kind field and use it when creating editPolicyPath:
diff --git a/ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue b/ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
index f3a3900fdc2..4737547f660 100644
--- a/ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
+++ b/ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
@@ -99,6 +99,7 @@ export default {
   data() {
     return {
       selectedPolicyName: null,
+      selectedPolicyKind: null,
       initialManifest: null,
       initialEnforcementStatus: null,
       networkPolicies: [],
@@ -141,7 +142,7 @@ export default {
     editPolicyPath() {
       return this.hasSelectedPolicy
         ? mergeUrlParams(
-            { environment_id: this.currentEnvironmentId },
+            { environment_id: this.currentEnvironmentId, kind: this.selectedPolicyKind },
             this.newPolicyPath.replace('new', `${this.selectedPolicyName}/edit`),
           )
         : '';
@@ -192,11 +193,13 @@ export default {
 
       const [selectedPolicy] = rows;
       this.selectedPolicyName = selectedPolicy?.name;
+      this.selectedPolicyKind = selectedPolicy?.kind;
       this.initialManifest = selectedPolicy?.yaml;
       this.initialEnforcementStatus = selectedPolicy?.enabled;
     },
     deselectPolicy() {
       this.selectedPolicyName = null;
+      this.selectedPolicyKind = null;
 
       const bTable = this.$refs.policiesTable.$children[0];
       bTable.clearSelected();
Edited by Alan (Maciej) Paruszewski