Browse Source

Follow up eb52e11 - Fixes #4838 - Data retention rules for cleanup users (or other objects) from the system with the scheduler.

Dusan Vuckovic 1 year ago
parent
commit
1b53185458

+ 3 - 3
app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee

@@ -112,8 +112,8 @@ class App.UiElement.object_perform_action extends App.UiElement.ApplicationActio
         translate: true
         translate: true
         options: availableActions
         options: availableActions
         alerts:
         alerts:
-          delete: __('All affected tickets will be deleted immediately when this job is run. There is no rollback of this deletion possible.')
-          data_privacy_deletion_task: __('All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible.')
+          delete: __('All affected tickets will be deleted immediately when this job is run, without a history entry. There is no rollback of this deletion possible.')
+          data_privacy_deletion_task: __('All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible.')
 
 
     # Add data privacy deletion task action for the user object.
     # Add data privacy deletion task action for the user object.
     if attribute.object_name is 'User' and attribute.data_privacy_deletion_task
     if attribute.object_name is 'User' and attribute.data_privacy_deletion_task
@@ -126,7 +126,7 @@ class App.UiElement.object_perform_action extends App.UiElement.ApplicationActio
         options:
         options:
           data_privacy_deletion_task: __('Add a data privacy deletion task')
           data_privacy_deletion_task: __('Add a data privacy deletion task')
         alerts:
         alerts:
-          data_privacy_deletion_task: __('All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible.')
+          data_privacy_deletion_task: __('All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, users and tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible.')
 
 
     # add sender type selection as a ticket attribute
     # add sender type selection as a ticket attribute
     if attribute.object_name is 'Ticket' and attribute.sender_type
     if attribute.object_name is 'Ticket' and attribute.sender_type

+ 2 - 2
app/assets/javascripts/app/controllers/_ui_element/object_selector.coffee

@@ -41,8 +41,8 @@ class App.UiElement.object_selector extends App.UiElement.ApplicationSelectorExp
 
 
     switch attribute.object_name
     switch attribute.object_name
       when 'Ticket' then defaults.push 'ticket.state_id'
       when 'Ticket' then defaults.push 'ticket.state_id'
-      when 'User' then defaults.push 'user.firstname'
-      when 'Organization' then defaults.push 'organization.name'
+      when 'User' then defaults.push 'user.role_ids'
+      when 'Organization' then defaults.push 'organization.members_existing'
 
 
     for key, data of groups
     for key, data of groups
       continue if _.contains(data.model_show, attribute.object_name)
       continue if _.contains(data.model_show, attribute.object_name)

+ 1 - 6
app/assets/javascripts/app/views/data_privacy/tasks.jst.eco

@@ -5,8 +5,6 @@
       <div class="action-flow action-flow--noWrap">
       <div class="action-flow action-flow--noWrap">
         <% if task.preferences.user: %>
         <% if task.preferences.user: %>
           <h2><%- @T('Delete User') %></h2>
           <h2><%- @T('Delete User') %></h2>
-        <% else if task.preferences.organization: %>
-          <h2><%- @T('Delete Organization') %></h2>
         <% else if task.preferences.ticket: %>
         <% else if task.preferences.ticket: %>
           <h2><%- @T('Delete Ticket') %></h2>
           <h2><%- @T('Delete Ticket') %></h2>
         <% end %>
         <% end %>
@@ -17,14 +15,11 @@
         <% if task.preferences.user: %>
         <% if task.preferences.user: %>
           <div class="label"><%- @T('User (censored):') %></div>
           <div class="label"><%- @T('User (censored):') %></div>
           <%= task.preferences.user.firstname %> <%= task.preferences.user.lastname %> (<%= task.preferences.user.email %>)
           <%= task.preferences.user.firstname %> <%= task.preferences.user.lastname %> (<%= task.preferences.user.email %>)
-          <% if task.preferences.user.organization && task.preferences.delete_organization: %>
+          <% if task.preferences.delete_organization: %>
           <br><br>
           <br><br>
           <div class="label"><%- @T('Deleted Organization:') %></div>
           <div class="label"><%- @T('Deleted Organization:') %></div>
           <%= task.preferences.user.organization %>
           <%= task.preferences.user.organization %>
           <% end %>
           <% end %>
-        <% else if task.preferences.organization: %>
-          <div class="label"><%- @T('Organization (censored):') %></div>
-          <%= task.preferences.organization.name %>
         <% else if task.preferences.ticket: %>
         <% else if task.preferences.ticket: %>
           <div class="label"><%- @T('Ticket (censored):') %></div>
           <div class="label"><%- @T('Ticket (censored):') %></div>
           <%= task.preferences.ticket.title %>
           <%= task.preferences.ticket.title %>

+ 3 - 11
i18n/zammad.pot

@@ -1044,15 +1044,15 @@ msgid "All Tickets"
 msgstr ""
 msgstr ""
 
 
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
-msgid "All affected tickets will be deleted immediately when this job is run. There is no rollback of this deletion possible."
+msgid "All affected tickets will be deleted immediately when this job is run, without a history entry. There is no rollback of this deletion possible."
 msgstr ""
 msgstr ""
 
 
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
-msgid "All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible."
+msgid "All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible."
 msgstr ""
 msgstr ""
 
 
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
 #: app/assets/javascripts/app/controllers/_ui_element/object_perform_action.coffee
-msgid "All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible."
+msgid "All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, users and tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible."
 msgstr ""
 msgstr ""
 
 
 #: app/assets/javascripts/app/controllers/_ui_element/_application_action.coffee
 #: app/assets/javascripts/app/controllers/_ui_element/_application_action.coffee
@@ -4021,10 +4021,6 @@ msgstr ""
 msgid "Delete Knowledge Base"
 msgid "Delete Knowledge Base"
 msgstr ""
 msgstr ""
 
 
-#: app/assets/javascripts/app/views/data_privacy/tasks.jst.eco
-msgid "Delete Organization"
-msgstr ""
-
 #: app/assets/javascripts/app/views/data_privacy/tasks.jst.eco
 #: app/assets/javascripts/app/views/data_privacy/tasks.jst.eco
 msgid "Delete Ticket"
 msgid "Delete Ticket"
 msgstr ""
 msgstr ""
@@ -8492,10 +8488,6 @@ msgstr ""
 msgid "Organization & Department Name"
 msgid "Organization & Department Name"
 msgstr ""
 msgstr ""
 
 
-#: app/assets/javascripts/app/views/data_privacy/tasks.jst.eco
-msgid "Organization (censored):"
-msgstr ""
-
 #: app/assets/javascripts/app/views/getting_started/base.jst.eco
 #: app/assets/javascripts/app/views/getting_started/base.jst.eco
 msgid "Organization Name"
 msgid "Organization Name"
 msgstr ""
 msgstr ""

+ 11 - 2
public/assets/tests/qunit/form_object_perform_action.js

@@ -117,6 +117,8 @@ QUnit.test('defaults to ticket object', (assert) => {
     },
     },
   }
   }
   assert.deepEqual(params, test_params, 'params structure')
   assert.deepEqual(params, test_params, 'params structure')
+
+
 })
 })
 
 
 QUnit.test('supports ticket object', (assert) => {
 QUnit.test('supports ticket object', (assert) => {
@@ -158,7 +160,14 @@ QUnit.test('supports ticket object', (assert) => {
   assert.deepEqual(el.find('.js-value option').map(function () { return $(this).attr('value') }).toArray(), ['data_privacy_deletion_task', 'delete'], 'has correct actions')
   assert.deepEqual(el.find('.js-value option').map(function () { return $(this).attr('value') }).toArray(), ['data_privacy_deletion_task', 'delete'], 'has correct actions')
 
 
   // Alert
   // Alert
-  assert.equal(el.find('.js-alert').text(), 'All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible.', 'has proper warning shown')
+  assert.equal(el.find('.js-alert').text(), 'All affected tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible.', 'has proper warning shown')
+
+  el.find('select[name="perform::ticket.action::value"]')
+    .val('delete')
+    .trigger('change')
+
+  // Alert #2
+  assert.equal(el.find('.js-alert').text(), 'All affected tickets will be deleted immediately when this job is run, without a history entry. There is no rollback of this deletion possible.')
 })
 })
 
 
 QUnit.test('supports user object', (assert) => {
 QUnit.test('supports user object', (assert) => {
@@ -201,5 +210,5 @@ QUnit.test('supports user object', (assert) => {
   assert.deepEqual(el.find('.js-value option').map(function () { return $(this).attr('value') }).toArray(), ['data_privacy_deletion_task'], 'has correct actions')
   assert.deepEqual(el.find('.js-value option').map(function () { return $(this).attr('value') }).toArray(), ['data_privacy_deletion_task'], 'has correct actions')
 
 
   // Alert
   // Alert
-  assert.equal(el.find('.js-alert').text(), 'All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, there is no rollback of this deletion possible.', 'has proper warning shown')
+  assert.equal(el.find('.js-alert').text(), 'All affected users and their customer tickets will be scheduled for deletion when this job is run. Once the data privacy task is executed, users and tickets will be deleted and a history entry preserved. There is no rollback of this deletion possible.', 'has proper warning shown')
 })
 })

+ 12 - 12
public/assets/tests/qunit/form_object_selector.js

@@ -177,9 +177,9 @@ QUnit.test('supports user object', (assert) => {
   var params = App.ControllerForm.params(el)
   var params = App.ControllerForm.params(el)
   var test_params = {
   var test_params = {
     condition: {
     condition: {
-      'user.firstname': { // default
-        operator: 'contains',
-        value: '',
+      'user.role_ids': { // default
+        operator: 'is',
+        value: [],
       },
       },
     },
     },
   }
   }
@@ -222,9 +222,9 @@ QUnit.test('supports organization object', (assert) => {
   var params = App.ControllerForm.params(el)
   var params = App.ControllerForm.params(el)
   var test_params = {
   var test_params = {
     condition: {
     condition: {
-      'organization.name': { // default
-        operator: 'contains',
-        value: '',
+      'organization.members_existing': { // default
+        operator: 'is',
+        value: true,
       },
       },
     },
     },
   }
   }
@@ -322,9 +322,9 @@ QUnit.test('supports user object', (assert) => {
   var params = App.ControllerForm.params(el)
   var params = App.ControllerForm.params(el)
   var test_params = {
   var test_params = {
     condition: {
     condition: {
-      'user.firstname': { // default
-        operator: 'contains',
-        value: '',
+      'user.role_ids': { // default
+        operator: 'is',
+        value: [],
       },
       },
     },
     },
   }
   }
@@ -367,9 +367,9 @@ QUnit.test('supports organization object', (assert) => {
   var params = App.ControllerForm.params(el)
   var params = App.ControllerForm.params(el)
   var test_params = {
   var test_params = {
     condition: {
     condition: {
-      'organization.name': { // default
-        operator: 'contains',
-        value: '',
+      'organization.members_existing': { // default
+        operator: 'is',
+        value: true,
       },
       },
     },
     },
   }
   }