Skip to content
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

Epic/FOUR-9674: AI in modeler #5371

Merged
merged 29 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2367026
Add required data for script and screens modal in modeler
agustinbusso Sep 13, 2023
3965cc5
Add process id to script controller
agustinbusso Sep 13, 2023
5ce4c10
Add show method in screen modal
agustinbusso Sep 13, 2023
eb1acc1
Add show method in script modal
agustinbusso Sep 13, 2023
9138387
Add screens and scripts controls to bootstrap
agustinbusso Sep 13, 2023
e2b6a9d
Pass process id
agustinbusso Sep 13, 2023
c2e98ef
Add variables needed for modals in modeler
agustinbusso Sep 13, 2023
fba3cb3
Autofocus when coming from Modeler
agustinbusso Sep 14, 2023
792c3b1
Add flow for screen generation
agustinbusso Sep 14, 2023
7b677e6
Fix issue when no processId
agustinbusso Sep 14, 2023
9e9fad7
Send script id parameter
agustinbusso Sep 15, 2023
9de81e0
Send screen id parameter
agustinbusso Sep 15, 2023
9211222
Emit redirect
agustinbusso Sep 18, 2023
fcd084d
Script editor save before redirecting
TinCodes Sep 18, 2023
ced92c3
Fix issue with redirect in screen builder
agustinbusso Sep 19, 2023
d436bf6
Merge branch 'epic/FOUR-9674' of https://github.com/ProcessMaker/proc…
agustinbusso Sep 19, 2023
90e8e1e
Add redirectUrl for versions modal
agustinbusso Sep 19, 2023
4b93983
Fix redirect for export screen
agustinbusso Sep 19, 2023
9bb6f91
Fix variable check
agustinbusso Sep 19, 2023
9c4e5cd
Add default screen for AI control in modeler
agustinbusso Sep 21, 2023
3e1688d
Add count categories for subprocess modal implementation
agustinbusso Sep 21, 2023
07d7e21
Fix modal components export
agustinbusso Sep 22, 2023
7aba07d
Add title and description in prompts for script and screen
agustinbusso Sep 25, 2023
a70b5a5
Ui changes
agustinbusso Sep 26, 2023
e33f50e
Handle creation from modeler
agustinbusso Sep 26, 2023
994cc5c
Merge branch 'next' into epic/FOUR-9674
agustinbusso Sep 26, 2023
cb5ed08
MergeFix format
agustinbusso Sep 26, 2023
e131012
Add alt to image
agustinbusso Sep 26, 2023
8fb1c1e
Fix failing test
agustinbusso Sep 26, 2023
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
1 change: 1 addition & 0 deletions ProcessMaker/Console/Commands/BuildScriptExecutors.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function buildExecutor()
$success = $this->associateWithExistingImage($scriptExecutor);
if ($success) {
$this->info('Docker Image Associated');

// we associated with an existing image, no need to build
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion ProcessMaker/Helpers/MobileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MobileHelper
public static function isMobile($userAgent)
{
$device = '/(Mobile|Android|Tablet|GoBrowser|[0-9]x[0-9]*|uZardWeb\/|Mini|Doris\/|Skyfire\/|iPhone|Fennec\/|Maemo|Iris\/|CLDC\-|Mobi\/)/uis';
if (preg_match($device, $userAgent) && !empty($_COOKIE["isMobile"]) && $_COOKIE["isMobile"] === "true") {
if (preg_match($device, $userAgent) && !empty($_COOKIE['isMobile']) && $_COOKIE['isMobile'] === 'true') {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function index(Request $request)
} else {
$environment_variables = EnvironmentVariable::orderBy($orderBy, $orderDirection)->paginate($perPage);
}

// Return fractal representation of paged data
return new ApiCollection($environment_variables);
}
Expand Down
6 changes: 5 additions & 1 deletion ProcessMaker/Http/Controllers/Api/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public function index(Request $request, $getTotal = false, User $user = null)

//list only display elements type task
$nonSystem = filter_var($request->input('non_system'), FILTER_VALIDATE_BOOLEAN);
$query->where('element_type', '=', 'task')
$query->where(function ($query) {
$query->where('element_type', '=', 'task');
$query->orWhere('element_type', '=', 'serviceTask');
$query->where('element_name', '=', 'AI Assistant');
})
->when($nonSystem, function ($query) {
$query->nonSystem();
});
Expand Down
3 changes: 2 additions & 1 deletion ProcessMaker/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function showLoginForm()
}
}
}

$block = $manager->getBlock();
// clear cookie to avoid an issue when logout SLO and then try to login with simple PM login form
\Cookie::queue(\Cookie::forget(config('session.cookie')));
Expand Down Expand Up @@ -121,6 +121,7 @@ public function loginWithIntendedCheck(Request $request)
return $redirect;
}
}

return $this->login($request);
}

Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Http/Controllers/Designer/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function show(Process $process = null, Form $form = null)
{
if ($process->id !== $form->process_id) {
request()->session()->flash('_alert', json_encode(['danger', __('The form does not belong to process.')]));

// @todo This should actually redirect to designer url
return view('designer.designer', compact('process'));
}
Expand Down
27 changes: 27 additions & 0 deletions ProcessMaker/Http/Controllers/Process/ModelerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
use ProcessMaker\Managers\ModelerManager;
use ProcessMaker\Managers\SignalManager;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessCategory;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ScreenCategory;
use ProcessMaker\Models\ScreenType;
use ProcessMaker\Models\ScriptCategory;
use ProcessMaker\Models\ScriptExecutor;
use ProcessMaker\PackageHelper;
use ProcessMaker\Traits\HasControllerAddons;
use ProcessMaker\Traits\ProcessMapTrait;
Expand All @@ -31,6 +36,22 @@ public function show(ModelerManager $manager, Process $process, Request $request
*/
event(new ModelerStarting($manager));

// For create subprocess modal in modeler
$countProcessCategories = ProcessCategory::where(['status' => 'ACTIVE', 'is_system' => false])->count();

// For create screen modal in modeler
$screenTypes = [];
foreach (ScreenType::pluck('name')->toArray() as $type) {
$screenTypes[$type] = __(ucwords(strtolower($type)));
}
asort($screenTypes);
$countScreenCategories = ScreenCategory::where(['status' => 'ACTIVE', 'is_system' => false])->count();
$isProjectsInstalled = PackageHelper::isPackageInstalled(PackageHelper::PM_PACKAGE_PROJECTS);

// For create script modal in modeler
$scriptExecutors = ScriptExecutor::list();
$countScriptCategories = ScriptCategory::where(['status' => 'ACTIVE', 'is_system' => false])->count();

$draft = $process->versions()->draft()->first();
if ($draft) {
$process->fill($draft->only(['svg', 'bpmn']));
Expand All @@ -43,6 +64,12 @@ public function show(ModelerManager $manager, Process $process, Request $request
'autoSaveDelay' => config('versions.delay.process', 5000),
'isVersionsInstalled' => PackageHelper::isPackageInstalled('ProcessMaker\Package\Versions\PluginServiceProvider'),
'isDraft' => $draft !== null,
'screenTypes' => $screenTypes,
'scriptExecutors' => $scriptExecutors,
'countProcessCategories' => $countProcessCategories,
'countScreenCategories' => $countScreenCategories,
'countScriptCategories' => $countScriptCategories,
'isProjectsInstalled' => $isProjectsInstalled,
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ScreenBuilderController extends Controller
*
* @return Factory|View
*/
public function edit(ScreenBuilderManager $manager, Screen $screen)
public function edit(ScreenBuilderManager $manager, Screen $screen, $processId = null)
{
/**
* Emit the ModelerStarting event, passing in our ModelerManager instance. This will
Expand All @@ -44,6 +44,7 @@ public function edit(ScreenBuilderManager $manager, Screen $screen)
'autoSaveDelay' => config('versions.delay.process', 5000),
'isVersionsInstalled' => PackageHelper::isPmPackageVersionsInstalled(),
'isDraft' => $draft !== null,
'processId' => $processId,
]);
}
}
3 changes: 2 additions & 1 deletion ProcessMaker/Http/Controllers/Process/ScriptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function edit(Script $script, User $users)
return view('processes.scripts.edit', compact('script', 'selectedUser', 'scriptExecutors', 'addons'));
}

public function builder(ScriptBuilderManager $manager, Request $request, Script $script)
public function builder(ScriptBuilderManager $manager, Request $request, Script $script, $processId = null)
{
$processRequestAttributes = $this->getProcessRequestAttributes();
$processRequestAttributes['user_id'] = $request->user()->id;
Expand Down Expand Up @@ -91,6 +91,7 @@ public function builder(ScriptBuilderManager $manager, Request $request, Script
'isVersionsInstalled' => PackageHelper::isPmPackageVersionsInstalled(),
'isDraft' => $draft !== null,
'user' => \Auth::user(),
'processId' => $processId,
]);
}

Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Http/Middleware/SanitizeInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected function cleanValue($key, $value)
// Do not sanitize any values (should be handled elsewhere in the controller)
return $value;
}

// If this is a string and is not in the exceptions
// array, return it after sanitization.
return SanitizeHelper::sanitize($value, !in_array($key, $this->except, true));
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Http/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function handle(Request $request, Closure $next)
// Use the App facade to set the locale for our request lifecycle
App::setLocale($locale);
}

// Process next
return $next($request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ public function handle(Request $request, Closure $next)
{
$user = $request->route('user');
$fields = $request->json()->all();
if (($fields['username'] !== $user->getAttribute('username') || in_array('password', $fields)) &&
if (($fields['username'] !== $user->getAttribute('username') || in_array('password', $fields)) &&
!Auth::user()->hasPermission('edit-user-and-password') && !Auth::user()->is_administrator) {
throw new AuthorizationException(__('Not authorized to update the username and password.'));

}

return $next($request);
Expand Down
1 change: 0 additions & 1 deletion ProcessMaker/Jobs/ImportProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ protected function decodeFile()
if (property_exists($this->file, 'process') && property_exists($this->file->process, 'bpmn')) {
$this->file->process->bpmn = str_replace('bpmn2', 'bpmn', $this->file->process->bpmn);
}

}

/**
Expand Down
2 changes: 1 addition & 1 deletion ProcessMaker/Jobs/RefreshArtisanCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function handle()
{
Artisan::call('clear-compiled', $options = [
'--no-interaction' => true,
'--quiet' => true
'--quiet' => true,
]);

if (app()->configurationIsCached()) {
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Models/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ public function getCollaborations()
$this->bpmnDefinitions = app(BpmnDocumentInterface::class, ['process' => $this]);
if ($this->bpmn) {
$this->bpmnDefinitions->loadXML($this->bpmn);

// Load the collaborations if exists
return $this->bpmnDefinitions->getElementsByTagNameNS(BpmnDocument::BPMN_MODEL, 'collaboration');
}
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Models/ProcessRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ public function getErrors()
if ($this->errors) {
return $this->errors;
}

// select tokens with errors
return $this->tokens()
->select('token_properties->error as message', 'created_at', 'element_name')
Expand Down
5 changes: 5 additions & 0 deletions ProcessMaker/Models/ProcessRequestToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ public function getScreen(): ?Screen
$isManualTask = $localName === 'manualTask';
$defaultScreen = $isManualTask ? 'default-display-screen' : 'default-form-screen';
$screen = Screen::firstWhere('key', $defaultScreen);

if (array_key_exists('implementation', $definition) && $definition['implementation'] === 'package-ai/processmaker-ai-assistant') {
$defaultScreen = 'default-ai-form-screen';
$screen = Screen::firstWhere('key', $defaultScreen);
}
}

return $screen;
Expand Down
2 changes: 2 additions & 0 deletions ProcessMaker/Nayra/Managers/WorkflowManagerDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function triggerStartEvent(Definitions $definitions, StartEventInterface
{
//Validate data
$this->validateData($data, $definitions, $event);

//Schedule BPMN Action
return (new StartEvent($definitions, $event, $data))->handle();
}
Expand All @@ -169,6 +170,7 @@ public function callProcess(Definitions $definitions, ProcessInterface $process,
{
//Validate data
$this->validateData($data, $definitions, $process);

//Validate user permissions
//Validate BPMN rules
//Log BPMN actions
Expand Down
1 change: 1 addition & 0 deletions ProcessMaker/Providers/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function retrieveByCredentials(array $credentials)
} elseif (isset($credentials['username'])) {
return User::where('username', $credentials['username'])->first();
}

// No valid credential to find, let's return nothing
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion ProcessMaker/SanitizeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static function getRichTextElements($items, $parent = null)
$elements = array_merge($elements, self::getRichTextElements($item['items'], ($parent ? $parent . '.' . $item['config']['name'] : $item['config']['name'])));
} elseif (isset($item['component']) && $item['component'] === 'FormTextArea' && isset($item['config']['richtext']) && $item['config']['richtext'] === true) {
$elements[] = ($parent ? $parent . '.' . $item['config']['name'] : $item['config']['name']);
// Inside a table ..
// Inside a table ..
} elseif ($item['component'] == 'FormMultiColumn') {
foreach ($item['items'] as $cell) {
if (
Expand Down
2 changes: 1 addition & 1 deletion config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@
|
*/

'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'),

];
2 changes: 1 addition & 1 deletion config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
],
Expand Down
2 changes: 1 addition & 1 deletion config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Facades\Schema;
use ProcessMaker\Models\ProcessTemplates;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
Expand Down
429 changes: 429 additions & 0 deletions database/processes/screens/default-ai-form-screen.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions resources/img/cornea_icon.svg

This file was deleted.

Loading