From a24ecb2401414794a4ee2a3f46e0203517eee9e5 Mon Sep 17 00:00:00 2001 From: Chris Jellen <64814231+CDJellen@users.noreply.github.com> Date: Wed, 13 Oct 2021 15:26:44 -0700 Subject: [PATCH 1/7] Possible fix to Issue #2315 (affects `templates/abilities.html`) The REST API expects an ability object in which the cleanup field is an array (list) of strings. Currently, the "Create Ability" UI saves the cleanup command as a string, causing an Unprocessable Entity response status code (422) when executing the PUT request in API v2. This commit includes a slight change to the cleanup field in the Create Ability modal which converts a line-break separated list of cleanup commands to the correct type. The net effect of the change is to enable users to create and edit abilities which include cleanup commands through the UI and API v2. --- templates/abilities.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/templates/abilities.html b/templates/abilities.html index 5ad17528f..7e82b914b 100644 --- a/templates/abilities.html +++ b/templates/abilities.html @@ -302,9 +302,14 @@

Abilities

-
+
+
+ +
- + + +
@@ -511,6 +516,15 @@

Abilities

} }, + transformCleanup(cleanup) { + if (typeof cleanup === 'string') { + if (cleanup.includes('\n')) { + return cleanup.split('\n'); + } + } + return cleanup; + }, + addExecutorToAbility(bOrA) { const template = { payloads: [], From 383c3372f908c430aa0c1f5d5be186a5cd38436f Mon Sep 17 00:00:00 2001 From: Chris Jellen <64814231+CDJellen@users.noreply.github.com> Date: Wed, 13 Oct 2021 15:45:36 -0700 Subject: [PATCH 2/7] Update abilities.html Ensure correct typing in `transformCleanup` under the Alpine.js framework. --- templates/abilities.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/abilities.html b/templates/abilities.html index 7e82b914b..406044e42 100644 --- a/templates/abilities.html +++ b/templates/abilities.html @@ -522,7 +522,7 @@

Abilities

return cleanup.split('\n'); } } - return cleanup; + return [cleanup]; }, addExecutorToAbility(bOrA) { From 2c9f43209e7802a151143787ed2ff5025f37d34c Mon Sep 17 00:00:00 2001 From: Chris Jellen <64814231+CDJellen@users.noreply.github.com> Date: Thu, 14 Oct 2021 17:02:40 -0700 Subject: [PATCH 3/7] Tweaks to cleanup command structure Redone cleanup commands to enable easy and intuitive addition and removal of cleanup commands. --- templates/abilities.html | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/templates/abilities.html b/templates/abilities.html index 406044e42..28f145b1c 100644 --- a/templates/abilities.html +++ b/templates/abilities.html @@ -300,18 +300,20 @@

Abilities

-
-
-
-
- -
-
- - - +
@@ -516,20 +518,12 @@

Abilities

} }, - transformCleanup(cleanup) { - if (typeof cleanup === 'string') { - if (cleanup.includes('\n')) { - return cleanup.split('\n'); - } - } - return [cleanup]; - }, - addExecutorToAbility(bOrA) { const template = { payloads: [], platform: 'linux', - name: 'sh' + name: 'sh', + cleanup: [] }; if (bOrA === 'after') { From 6c13dd2470c99d6f48c7c74fac8dbeb9717a6539 Mon Sep 17 00:00:00 2001 From: Chris Jellen <64814231+CDJellen@users.noreply.github.com> Date: Thu, 14 Oct 2021 17:07:43 -0700 Subject: [PATCH 4/7] Propagate change to abilities modal Propagate change to ability modal to `profiles.html`. --- templates/profiles.html | 49 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/templates/profiles.html b/templates/profiles.html index 3911c87cc..aff2fab74 100644 --- a/templates/profiles.html +++ b/templates/profiles.html @@ -370,10 +370,8 @@

Create a profile

-