Skip to content

Commit

Permalink
Merge pull request #2564 from Leantime/commentsComponent
Browse files Browse the repository at this point in the history
Comments component
  • Loading branch information
marcelfolaron authored Aug 27, 2024
2 parents 140aabc + 7b73266 commit 695fe04
Show file tree
Hide file tree
Showing 117 changed files with 2,572 additions and 1,083 deletions.
36 changes: 17 additions & 19 deletions .idea/leantime-oss.iml

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

2 changes: 1 addition & 1 deletion app/Core/Bootstrap/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct()

Facade::setFacadeApplication($this);

EventDispatcher::discover_listeners();
EventDispatcher::discoverListeners();

$this->boot();
}
Expand Down
14 changes: 0 additions & 14 deletions app/Core/Controller/Frontcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,6 @@ private static function executeAction(string $completeName, array $params = arra
return app()->make($classname)->getResponse();
}

/**
* includeAction - possible to include action from everywhere
*
* @access public
* @param string $completeName
* @param array $params
* @return void
* @throws BindingResolutionException
*/
public static function includeAction(string $completeName, array $params = array()): void
{
self::executeAction($completeName, $params);
}

/**
* getActionName - split string to get actionName
*
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Controller/HtmxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public function __construct(
protected IncomingRequest $incomingRequest,

/** @var Template $tpl */
protected Template $tpl,
public Template $tpl,

) {
self::dispatch_event('begin');

Expand Down
6 changes: 3 additions & 3 deletions app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static function dispatch_filter(
* @return void
* @throws BindingResolutionException
*/
public static function discover_listeners(): void
public static function discoverListeners(): void
{
static $discovered;
$discovered ??= false;
Expand All @@ -194,6 +194,7 @@ public static function discover_listeners(): void
}

foreach ($modules as $module) {
//File exists is not expensive and builds it's own cache to speed up performance
if (file_exists($moduleEventsPath = "$module/register.php")) {
include_once $moduleEventsPath;
}
Expand Down Expand Up @@ -221,7 +222,6 @@ public static function discover_listeners(): void
$enabledPlugins = $pluginService->getEnabledPlugins();

foreach ($enabledPlugins as $plugin) {

//Catch issue when plugins are cached on load but autoloader is not quite done loading.
//Only happens because the plugin objects are stored in session and the unserialize is not keeping up.
//Clearing session cache in that case.
Expand Down Expand Up @@ -501,7 +501,7 @@ private static function executeHandlers(
continue;
}

if($index == 0) {
if ($index == 0) {
$filteredPayload = $payload;
}
}
Expand Down
25 changes: 25 additions & 0 deletions app/Core/Exceptions/AuthException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Leantime\Core\Exceptions;

use Exception;
use Throwable;

class AuthException extends Exception
{
/**
* Construct the exception. Note: The message is NOT binary safe.
*
* @link https://php.net/manual/en/exception.construct.php
*
* @param string $message [optional] The Exception message to throw.
* @param Throwable|null $previous [optional] The previous throwable used for the exception chaining.
* @param int $code [optional] The Exception code.
*/
public function __construct(string $message = '', int $code = 403)
{
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
}
}
113 changes: 113 additions & 0 deletions app/Core/Http/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Session\SymfonySessionDecorator;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Console\CliRequest;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;

/**
Expand All @@ -16,6 +17,14 @@
*/
class IncomingRequest extends Request
{

/**
* The decoded JSON content for the request.
*
* @var \Symfony\Component\HttpFoundation\InputBag|null
*/
protected $json;

/**
* @param array $query The GET parameters
* @param array $request The POST parameters
Expand Down Expand Up @@ -139,6 +148,56 @@ public function getRequestParams(string $method = null): array
};
}

/**
* Retrieve an input item from the request.
*
* @param string|null $key
* @param mixed $default
* @return mixed
*/
public function input($key = null, $default = null)
{
return data_get(
$this->getInputSource()->all() + $this->query->all(),
$key,
$default
);
}

/**
* Get the JSON payload for the request.
*
* @param string|null $key
* @param mixed $default
* @return \Symfony\Component\HttpFoundation\InputBag|mixed
*/
public function json($key = null, $default = null)
{
if (! isset($this->json)) {
$this->json = new InputBag((array) json_decode($this->getContent() ?: '[]', true));
}

if (is_null($key)) {
return $this->json;
}

return data_get($this->json->all(), $key, $default);
}

/**
* Get the input source for the request.
*
* @return \Symfony\Component\HttpFoundation\InputBag
*/
protected function getInputSource()
{
if ($this->isJson()) {
return $this->json();
}

return in_array($this->getRealMethod(), ['GET', 'HEAD']) ? $this->query : $this->request;
}

/**
* Set the Laravel session instance.
*
Expand Down Expand Up @@ -207,5 +266,59 @@ public function expectsJson()

return false;
}
/**
* Determine if the request is JSON.
*
* @return bool
*/
public function isJson()
{
return $this->hasHeader('Content-Type') &&
str_contains($this->header('Content-Type')[0], 'json');
}

/**
* Determine if a header is set on the request.
*
* @param string $key
* @return bool
*/
public function hasHeader($key)
{
return ! is_null($this->header($key));
}

/**
* Retrieve a header from the request.
*
* @param string|null $key
* @param string|array|null $default
* @return string|array|null
*/
public function header($key = null, $default = null)
{
return $this->retrieveItem('headers', $key, $default);
}

/**
* Retrieve a parameter item from a given source.
*
* @param string $source
* @param string|null $key
* @param string|array|null $default
* @return string|array|null
*/
protected function retrieveItem($source, $key, $default)
{
if (is_null($key)) {
return $this->$source->all();
}

if ($this->$source instanceof InputBag) {
return $this->$source->all()[$key] ?? $default;
}

return $this->$source->get($key, $default);
}

}
1 change: 1 addition & 0 deletions app/Core/Middleware/StartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function handle(IncomingRequest $request, Closure $next)
protected function handleRequestWhileBlocking(IncomingRequest $request, $session, Closure $next)
{


$lockFor = $this->manager->defaultRouteBlockLockSeconds();

$lock = $this->cache("installation")
Expand Down
35 changes: 35 additions & 0 deletions app/Core/Support/DateTimeInfoEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Leantime\Core\Support;

/**
* Enum class FromFormat
*
* An enumeration class representing various formats for date and time values.
*/
enum DateTimeInfoEnum {

/**
* Displays date with content:
* Written On DATE at TIME
*/
case WrittenOnAt;

/**
* Displays date with content:
* Updated On DATE at TIME
*/
case UpcatedOnAt;

/**
* Displays date with content:
* XXX days/months ago
*/
case HumanReadable;

/**
* Just displays DATE TIME
*/
case Plain;

}
29 changes: 29 additions & 0 deletions app/Core/Support/EditorTypeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Leantime\Core\Support;

/**
* Enum class FromFormat
*
* An enumeration class representing various formats for date and time values.
*/
enum EditorTypeEnum: string
{

/**
* Shows a simplified editor used for comments
*/
case Simple = "tinymceSimple";

/**
* Shows a more complex editor for entity descriptions
*/
case Complex = "tinymceComplex";

/**
* Shows the full editor with all featuers
*/
case Notes = "tinymceNotes";


}
Loading

0 comments on commit 695fe04

Please sign in to comment.