Skip to content

Commit 7afaba5

Browse files
authored
Merge pull request #5760 from ProcessMaker/develop
Updating feature branch from develop branch... 2023-12-05
2 parents 6287b59 + e96aa22 commit 7afaba5

File tree

15 files changed

+126
-42
lines changed

15 files changed

+126
-42
lines changed

ProcessMaker/Http/Controllers/ProcessController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function triggerStartEventApi(Process $process, Request $request)
250250
$apiRequest = new ApiProcessController();
251251
$response = $apiRequest->triggerStartEvent($process, $request);
252252

253-
return redirect('/requests/' . $response->id)->cookie('fromTriggerStartEvent', true, 1);
253+
return redirect('/requests/' . $response->id . '?fromTriggerStartEvent=');
254254
}
255255

256256
private function checkAuth()

ProcessMaker/Http/Controllers/RequestController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,22 @@ public function show(ProcessRequest $request, Media $mediaItems)
7676
$definition = $startEvent->getDefinition();
7777
$allowInterstitial = false;
7878
if (isset($definition['allowInterstitial'])) {
79-
$allowInterstitial = filter_var($definition['allowInterstitial'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
79+
$allowInterstitial = filter_var(
80+
$definition['allowInterstitial'],
81+
FILTER_VALIDATE_BOOLEAN,
82+
FILTER_NULL_ON_FAILURE
83+
);
8084
}
81-
if ($allowInterstitial && $request->user_id == Auth::id() && request()->cookie('fromTriggerStartEvent')) {
85+
if ($allowInterstitial && $request->user_id == Auth::id() && request()->has('fromTriggerStartEvent')) {
8286
$active = $request->tokens()
8387
->where('user_id', Auth::id())
8488
->where('element_type', 'task')
8589
->where('status', 'ACTIVE')
8690
->orderBy('id')->first();
8791

88-
return redirect(route('tasks.edit', ['task' => $active ? $active->getKey() : $startEvent->getKey()]))->withoutCookie('fromTriggerStartEvent');
92+
return redirect(route('tasks.edit', [
93+
'task' => $active ? $active->getKey() : $startEvent->getKey()
94+
]));
8995
}
9096
}
9197
}

ProcessMaker/Jobs/RefreshArtisanCaches.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function handle()
4040
Artisan::call('config:cache', $options);
4141
} else {
4242
Artisan::call('queue:restart', $options);
43+
44+
// We call this manually here since this job is dispatched
45+
// automatically when the config *is* cached
46+
RestartMessageConsumers::dispatchSync();
4347
}
4448
}
4549
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace ProcessMaker\Jobs;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Foundation\Bus\Dispatchable;
8+
use Illuminate\Queue\InteractsWithQueue;
9+
use Illuminate\Support\Facades\Artisan;
10+
use Illuminate\Support\Facades\Log;
11+
use Illuminate\Support\Str;
12+
13+
class RestartMessageConsumers implements ShouldQueue
14+
{
15+
use Dispatchable, InteractsWithQueue, Queueable;
16+
17+
/**
18+
* Number of tries to run this job
19+
*
20+
* @var int
21+
*/
22+
public $tries = 1;
23+
24+
public function __construct()
25+
{
26+
//
27+
}
28+
29+
/**
30+
* Execute the job.
31+
*
32+
* @return void
33+
*/
34+
public function handle(): void
35+
{
36+
// For now, we;re only addressing the restart of the kafka consumer(s)
37+
// and we will address the rabbitmq consumer(s) in another PR
38+
if (Str::lower(config('app.message_broker_driver')) !== 'kafka') {
39+
return;
40+
}
41+
42+
$exitCode = Artisan::call('kafka:restart-consumers', [
43+
'--no-interaction' => true,
44+
]);
45+
46+
Log::info('Kafka Consumer(s) Restart Attempted', [
47+
'exit_code' => $exitCode,
48+
'command_output' => Artisan::output(),
49+
]);
50+
}
51+
}

ProcessMaker/Managers/ScreenBuilderManager.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
namespace ProcessMaker\Managers;
44

5-
use Illuminate\Support\Facades\Storage;
6-
use ProcessMaker\Models\ScreenType;
5+
use Illuminate\Foundation\PackageManifest;
76

87
class ScreenBuilderManager
98
{
@@ -57,6 +56,11 @@ public function addPackageScripts($type = 'DISPLAY')
5756
$extensionsFile = 'screen-builder-' . strtolower($type) . '-components.js';
5857

5958
$directories = glob('vendor/processmaker/packages/*', GLOB_ONLYDIR);
59+
$installed = app(PackageManifest::class)->list();
60+
$directories = array_values(array_filter($directories, function ($directory) use ($installed) {
61+
$package = 'processmaker/' . basename($directory);
62+
return in_array($package, $installed);
63+
}));
6064
foreach ($directories as $directory) {
6165
$extensionsFullName = $directory . '/js/' . $extensionsFile;
6266
$files = glob($extensionsFullName);

ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public function completeTask(Definitions $definitions, ExecutionInstanceInterfac
140140
// Get complementary information
141141
$version = $instance->process_version_id;
142142
$userId = $this->getCurrentUserId();
143-
$state = $this->serializeState($instance);
144143

145144
// Dispatch complete task action
146145
$this->dispatchAction([
@@ -152,7 +151,7 @@ public function completeTask(Definitions $definitions, ExecutionInstanceInterfac
152151
'element_id' => $token->element_id,
153152
'data' => $data,
154153
],
155-
'state' => $state,
154+
'collaboration_uuid' => $instance->collaboration_uuid,
156155
'session' => [
157156
'user_id' => $userId,
158157
],
@@ -556,7 +555,7 @@ public function throwSignalEventRequest(ProcessRequest $request, $signalRef, arr
556555
/**
557556
* Retrieves IDs of all instances collaborating with the given instance.
558557
*
559-
* This function compiles a list of IDs from execution instances associated
558+
* This function compiles a list of IDs from execution instances associated
560559
* with the same process as the input instance, including the instance itself.
561560
*
562561
* @param ProcessRequest $instance The instance to find collaborators for.

ProcessMaker/Providers/SettingServiceProvider.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\ServiceProvider;
88
use ProcessMaker\Events\MarkArtisanCachesAsInvalid;
99
use ProcessMaker\Jobs\RefreshArtisanCaches;
10+
use ProcessMaker\Jobs\RestartMessageConsumers;
1011
use ProcessMaker\Jobs\TerminateHorizon;
1112
use ProcessMaker\Models\Setting;
1213
use ProcessMaker\Repositories\ConfigRepository;
@@ -19,14 +20,14 @@ class SettingServiceProvider extends ServiceProvider
1920
*
2021
* @var bool
2122
*/
22-
protected static $shouldCacheConfiguration = false;
23+
protected static bool $shouldCacheConfiguration = false;
2324

2425
/**
2526
* Eloquent events which trigger configuration-related updates
2627
*
2728
* @var array
2829
*/
29-
public static $listen = [
30+
public static array $listen = [
3031
'eloquent.saved: ' . Setting::class,
3132
'eloquent.deleted: ' . Setting::class,
3233
];
@@ -53,10 +54,11 @@ public function register(): void
5354
});
5455

5556
// When the config:cache command is run, we need to restart
56-
// horizon to ensure they use the latest version of the
57-
// cached configuration
57+
// horizon and the message consumer(s) to ensure they use
58+
// the latest version of the cached configuration
5859
$this->app['events']->listen(CommandFinished::class, function ($event) {
5960
if ($this->isCacheConfigCommand($event)) {
61+
$this->restartMessageConsumers();
6062
$this->restartHorizon();
6163
}
6264
});
@@ -119,6 +121,23 @@ public function isCacheConfigCommand($event): bool
119121
return is_int(strpos($command, 'config:cache'));
120122
}
121123

124+
/**
125+
* Restart the `processmaker:consume` commands to
126+
* pick up new config changes
127+
*
128+
* @return void
129+
*/
130+
public function restartMessageConsumers(): void
131+
{
132+
// If there's already a job pending to restart the message consumers,
133+
// then we don't need to queue another. The job itself checks which
134+
// messaging service is configured and will restart the consumer for
135+
// it appropriately
136+
if (!job_pending($job = RestartMessageConsumers::class)) {
137+
$job::dispatch();
138+
}
139+
}
140+
122141
/**
123142
* Restart the horizon queue manager whenever the configuration is cached so ensure
124143
* the new configuration is picked up by the supervisor/queue processes.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"Gmail"
9797
],
9898
"processmaker": {
99-
"build": "3daac8b4",
99+
"build": "822678fc",
100100
"custom": {
101101
"package-ellucian-ethos": "1.14.1",
102102
"package-plaid": "1.3.1",
@@ -148,7 +148,7 @@
148148
"package-files": "1.11.2",
149149
"package-googleplaces": "1.9.0",
150150
"package-photo-video": "1.2.0",
151-
"package-pm-blocks": "1.3.2",
151+
"package-pm-blocks": "1.3.3",
152152
"package-process-documenter": "1.8.0",
153153
"package-process-optimization": "1.8.0",
154154
"package-product-analytics": "1.5.8",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
'github' => [
4343
'base_url' => 'https://raw.githubusercontent.com/processmaker/',
4444
'template_repo' => env('DEFAULT_TEMPLATE_REPO', 'process-templates'),
45-
'template_branch' => env('DEFAULT_TEMPLATE_BRANCH', 'main'),
45+
'template_branch' => env('DEFAULT_TEMPLATE_BRANCH', '2023-fall'),
4646
'template_categories' => env('DEFAULT_TEMPLATE_CATEGORIES', 'accounting-and-finance,customer-success,human-resources,marketing-and-sales,operations,it'),
4747
],
4848

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
"@fortawesome/free-solid-svg-icons": "^5.15.1",
5252
"@fortawesome/vue-fontawesome": "^0.1.9",
5353
"@panter/vue-i18next": "^0.15.2",
54-
"@processmaker/modeler": "1.42.1",
54+
"@processmaker/modeler": "1.42.2",
5555
"@processmaker/processmaker-bpmn-moddle": "0.14.1",
56-
"@processmaker/screen-builder": "2.79.0",
56+
"@processmaker/screen-builder": "2.79.1",
5757
"@processmaker/vue-form-elements": "0.49.4",
5858
"@processmaker/vue-multiselect": "2.2.0",
5959
"autoprefixer": "10.4.5",

resources/js/components/requests/card.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ export default {
7979
.then(response => {
8080
this.spin = 0;
8181
let instance = response.data;
82-
this.$cookies.set('fromTriggerStartEvent', true, '1min');
8382
if (this.$cookies.get("isMobile") === "true") {
8483
window.location = "/requests/mobile/" + instance.id;
8584
} else {
86-
window.location = "/requests/" + instance.id;
85+
window.location = `/requests/${instance.id}?fromTriggerStartEvent=`;
8786
}
8887
}).catch((err) => {
8988
this.disabled = false;

resources/js/processes/screens/components/CreateScreenModal.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
v-if="isProjectsInstalled"
7979
v-model="formData.projects"
8080
:errors="errors.projects"
81-
:projectId="projectId"
81+
:project-id="projectId"
8282
:label="$t('Project')"
8383
:required="isProjectSelectionRequired"
8484
api-get="projects"
@@ -161,13 +161,13 @@ export default {
161161
this.resetFormData();
162162
this.resetErrors();
163163
if (this.isQuickCreate === true) {
164-
this.screenTypes = filterScreenType();
164+
this.screenTypes = filterScreenType() ?? this.types;
165165
// in any case the screenType if the only one, default to the first value
166166
if (Object.keys(this.screenTypes).length === 1) this.formData.type = Object.keys(this.screenTypes)[0];
167167
}
168168
if (this.callFromAiModeler === true) {
169169
this.screenTypes = this.types;
170-
}
170+
}
171171
},
172172
methods: {
173173
show() {
@@ -193,10 +193,10 @@ export default {
193193
this.resetErrors();
194194
},
195195
close() {
196-
this.$bvModal.hide('createScreen');
196+
this.$bvModal.hide("createScreen");
197197
this.disabled = false;
198-
this.$emit('reload');
199-
},
198+
this.$emit("reload");
199+
},
200200
onSubmit() {
201201
this.resetErrors();
202202
// single click

resources/js/utils/filterScreenType.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { ScreenTypes } from "../models/screens";
22

33
/**
44
* Filter the screen types based on the task
5+
* @return {?Object};
56
*/
67
export function filterScreenType() {
7-
const screen = new URLSearchParams(window.location.search).get("screenType").split(",");
8+
const screen = new URLSearchParams(window.location.search).get("screenType")?.split(",");
9+
if (!screen) return;
810
return Object.fromEntries(Object.entries(ScreenTypes).filter(([key]) => screen.includes(key)));
911
}

0 commit comments

Comments
 (0)