Skip to content

Updating feature branch from develop branch... 2023-12-05 #5760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ProcessMaker/Http/Controllers/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function triggerStartEventApi(Process $process, Request $request)
$apiRequest = new ApiProcessController();
$response = $apiRequest->triggerStartEvent($process, $request);

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

private function checkAuth()
Expand Down
12 changes: 9 additions & 3 deletions ProcessMaker/Http/Controllers/RequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,22 @@ public function show(ProcessRequest $request, Media $mediaItems)
$definition = $startEvent->getDefinition();
$allowInterstitial = false;
if (isset($definition['allowInterstitial'])) {
$allowInterstitial = filter_var($definition['allowInterstitial'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
$allowInterstitial = filter_var(
$definition['allowInterstitial'],
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE
);
}
if ($allowInterstitial && $request->user_id == Auth::id() && request()->cookie('fromTriggerStartEvent')) {
if ($allowInterstitial && $request->user_id == Auth::id() && request()->has('fromTriggerStartEvent')) {
$active = $request->tokens()
->where('user_id', Auth::id())
->where('element_type', 'task')
->where('status', 'ACTIVE')
->orderBy('id')->first();

return redirect(route('tasks.edit', ['task' => $active ? $active->getKey() : $startEvent->getKey()]))->withoutCookie('fromTriggerStartEvent');
return redirect(route('tasks.edit', [
'task' => $active ? $active->getKey() : $startEvent->getKey()
]));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ProcessMaker/Jobs/RefreshArtisanCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function handle()
Artisan::call('config:cache', $options);
} else {
Artisan::call('queue:restart', $options);

// We call this manually here since this job is dispatched
// automatically when the config *is* cached
RestartMessageConsumers::dispatchSync();
}
}
}
51 changes: 51 additions & 0 deletions ProcessMaker/Jobs/RestartMessageConsumers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace ProcessMaker\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class RestartMessageConsumers implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;

/**
* Number of tries to run this job
*
* @var int
*/
public $tries = 1;

public function __construct()
{
//
}

/**
* Execute the job.
*
* @return void
*/
public function handle(): void
{
// For now, we;re only addressing the restart of the kafka consumer(s)
// and we will address the rabbitmq consumer(s) in another PR
if (Str::lower(config('app.message_broker_driver')) !== 'kafka') {
return;
}

$exitCode = Artisan::call('kafka:restart-consumers', [
'--no-interaction' => true,
]);

Log::info('Kafka Consumer(s) Restart Attempted', [
'exit_code' => $exitCode,
'command_output' => Artisan::output(),
]);
}
}
8 changes: 6 additions & 2 deletions ProcessMaker/Managers/ScreenBuilderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace ProcessMaker\Managers;

use Illuminate\Support\Facades\Storage;
use ProcessMaker\Models\ScreenType;
use Illuminate\Foundation\PackageManifest;

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

$directories = glob('vendor/processmaker/packages/*', GLOB_ONLYDIR);
$installed = app(PackageManifest::class)->list();
$directories = array_values(array_filter($directories, function ($directory) use ($installed) {
$package = 'processmaker/' . basename($directory);
return in_array($package, $installed);
}));
foreach ($directories as $directory) {
$extensionsFullName = $directory . '/js/' . $extensionsFile;
$files = glob($extensionsFullName);
Expand Down
5 changes: 2 additions & 3 deletions ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public function completeTask(Definitions $definitions, ExecutionInstanceInterfac
// Get complementary information
$version = $instance->process_version_id;
$userId = $this->getCurrentUserId();
$state = $this->serializeState($instance);

// Dispatch complete task action
$this->dispatchAction([
Expand All @@ -152,7 +151,7 @@ public function completeTask(Definitions $definitions, ExecutionInstanceInterfac
'element_id' => $token->element_id,
'data' => $data,
],
'state' => $state,
'collaboration_uuid' => $instance->collaboration_uuid,
'session' => [
'user_id' => $userId,
],
Expand Down Expand Up @@ -556,7 +555,7 @@ public function throwSignalEventRequest(ProcessRequest $request, $signalRef, arr
/**
* Retrieves IDs of all instances collaborating with the given instance.
*
* This function compiles a list of IDs from execution instances associated
* This function compiles a list of IDs from execution instances associated
* with the same process as the input instance, including the instance itself.
*
* @param ProcessRequest $instance The instance to find collaborators for.
Expand Down
27 changes: 23 additions & 4 deletions ProcessMaker/Providers/SettingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\ServiceProvider;
use ProcessMaker\Events\MarkArtisanCachesAsInvalid;
use ProcessMaker\Jobs\RefreshArtisanCaches;
use ProcessMaker\Jobs\RestartMessageConsumers;
use ProcessMaker\Jobs\TerminateHorizon;
use ProcessMaker\Models\Setting;
use ProcessMaker\Repositories\ConfigRepository;
Expand All @@ -19,14 +20,14 @@ class SettingServiceProvider extends ServiceProvider
*
* @var bool
*/
protected static $shouldCacheConfiguration = false;
protected static bool $shouldCacheConfiguration = false;

/**
* Eloquent events which trigger configuration-related updates
*
* @var array
*/
public static $listen = [
public static array $listen = [
'eloquent.saved: ' . Setting::class,
'eloquent.deleted: ' . Setting::class,
];
Expand All @@ -53,10 +54,11 @@ public function register(): void
});

// When the config:cache command is run, we need to restart
// horizon to ensure they use the latest version of the
// cached configuration
// horizon and the message consumer(s) to ensure they use
// the latest version of the cached configuration
$this->app['events']->listen(CommandFinished::class, function ($event) {
if ($this->isCacheConfigCommand($event)) {
$this->restartMessageConsumers();
$this->restartHorizon();
}
});
Expand Down Expand Up @@ -119,6 +121,23 @@ public function isCacheConfigCommand($event): bool
return is_int(strpos($command, 'config:cache'));
}

/**
* Restart the `processmaker:consume` commands to
* pick up new config changes
*
* @return void
*/
public function restartMessageConsumers(): void
{
// If there's already a job pending to restart the message consumers,
// then we don't need to queue another. The job itself checks which
// messaging service is configured and will restart the consumer for
// it appropriately
if (!job_pending($job = RestartMessageConsumers::class)) {
$job::dispatch();
}
}

/**
* Restart the horizon queue manager whenever the configuration is cached so ensure
* the new configuration is picked up by the supervisor/queue processes.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"Gmail"
],
"processmaker": {
"build": "3daac8b4",
"build": "822678fc",
"custom": {
"package-ellucian-ethos": "1.14.1",
"package-plaid": "1.3.1",
Expand Down Expand Up @@ -148,7 +148,7 @@
"package-files": "1.11.2",
"package-googleplaces": "1.9.0",
"package-photo-video": "1.2.0",
"package-pm-blocks": "1.3.2",
"package-pm-blocks": "1.3.3",
"package-process-documenter": "1.8.0",
"package-process-optimization": "1.8.0",
"package-product-analytics": "1.5.8",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'github' => [
'base_url' => 'https://raw.githubusercontent.com/processmaker/',
'template_repo' => env('DEFAULT_TEMPLATE_REPO', 'process-templates'),
'template_branch' => env('DEFAULT_TEMPLATE_BRANCH', 'main'),
'template_branch' => env('DEFAULT_TEMPLATE_BRANCH', '2023-fall'),
'template_categories' => env('DEFAULT_TEMPLATE_CATEGORIES', 'accounting-and-finance,customer-success,human-resources,marketing-and-sales,operations,it'),
],

Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/vue-fontawesome": "^0.1.9",
"@panter/vue-i18next": "^0.15.2",
"@processmaker/modeler": "1.42.1",
"@processmaker/modeler": "1.42.2",
"@processmaker/processmaker-bpmn-moddle": "0.14.1",
"@processmaker/screen-builder": "2.79.0",
"@processmaker/screen-builder": "2.79.1",
"@processmaker/vue-form-elements": "0.49.4",
"@processmaker/vue-multiselect": "2.2.0",
"autoprefixer": "10.4.5",
Expand Down
3 changes: 1 addition & 2 deletions resources/js/components/requests/card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ export default {
.then(response => {
this.spin = 0;
let instance = response.data;
this.$cookies.set('fromTriggerStartEvent', true, '1min');
if (this.$cookies.get("isMobile") === "true") {
window.location = "/requests/mobile/" + instance.id;
} else {
window.location = "/requests/" + instance.id;
window.location = `/requests/${instance.id}?fromTriggerStartEvent=`;
}
}).catch((err) => {
this.disabled = false;
Expand Down
12 changes: 6 additions & 6 deletions resources/js/processes/screens/components/CreateScreenModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
v-if="isProjectsInstalled"
v-model="formData.projects"
:errors="errors.projects"
:projectId="projectId"
:project-id="projectId"
:label="$t('Project')"
:required="isProjectSelectionRequired"
api-get="projects"
Expand Down Expand Up @@ -161,13 +161,13 @@ export default {
this.resetFormData();
this.resetErrors();
if (this.isQuickCreate === true) {
this.screenTypes = filterScreenType();
this.screenTypes = filterScreenType() ?? this.types;
// in any case the screenType if the only one, default to the first value
if (Object.keys(this.screenTypes).length === 1) this.formData.type = Object.keys(this.screenTypes)[0];
}
if (this.callFromAiModeler === true) {
this.screenTypes = this.types;
}
}
},
methods: {
show() {
Expand All @@ -193,10 +193,10 @@ export default {
this.resetErrors();
},
close() {
this.$bvModal.hide('createScreen');
this.$bvModal.hide("createScreen");
this.disabled = false;
this.$emit('reload');
},
this.$emit("reload");
},
onSubmit() {
this.resetErrors();
// single click
Expand Down
4 changes: 3 additions & 1 deletion resources/js/utils/filterScreenType.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { ScreenTypes } from "../models/screens";

/**
* Filter the screen types based on the task
* @return {?Object};
*/
export function filterScreenType() {
const screen = new URLSearchParams(window.location.search).get("screenType").split(",");
const screen = new URLSearchParams(window.location.search).get("screenType")?.split(",");
if (!screen) return;
return Object.fromEntries(Object.entries(ScreenTypes).filter(([key]) => screen.includes(key)));
}