-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Feat: make taskprocessing task types toggleable #49727
Open
janepie
wants to merge
14
commits into
master
Choose a base branch
from
feat/make-tasks-types-toggleable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
018413c
feat: add switch in frontend
janepie 22c79db
feat: save state in db
janepie 72a0cd1
feat: filter disabled apps in task types requests
janepie ef95ede
fix: show all types when no preferences saved
janepie 35a4a06
fix: update build files
janepie b1a0988
fix: eslint
janepie cae55c8
fix: always regenerate availabe task types
janepie 4f69306
test: add disabled task type unit test
janepie d7f075b
feat: add occ command for task type toggling
janepie b726495
docs: document adding of argument
janepie 565a607
test: add explicitly enabled task type unit test
janepie b0016d6
fix(taskrpocessing): Cache result of getAvailableTaskTypes
marcelklehr 1c030e4
feat: add occ command for task type toggling
janepie 7024824
feat: add error flags for json_decode
janepie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OC\Core\Command\TaskProcessing; | ||
|
||
use OC\Core\Command\Base; | ||
use OCP\IConfig; | ||
use OCP\TaskProcessing\IManager; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class EnabledCommand extends Base { | ||
public function __construct( | ||
protected IManager $taskProcessingManager, | ||
private IConfig $config, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() { | ||
$this | ||
->setName('taskprocessing:task-type:set-enabled') | ||
->setDescription('Enable or disable a task type') | ||
->addArgument( | ||
'task-type-id', | ||
InputArgument::REQUIRED, | ||
'ID of the task type to configure' | ||
) | ||
->addArgument( | ||
'enabled', | ||
InputArgument::REQUIRED, | ||
'status of the task type availability. Set 1 to enable and 0 to disable.' | ||
); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
$enabled = (bool)$input->getArgument('enabled'); | ||
$taskType = $input->getArgument('task-type-id'); | ||
$json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences'); | ||
if ($json === '') { | ||
$taskTypeSettings = []; | ||
} else { | ||
$taskTypeSettings = json_decode($json, true, flags: JSON_THROW_ON_ERROR); | ||
} | ||
|
||
$taskTypeSettings[$taskType] = $enabled; | ||
|
||
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskTypeSettings)); | ||
$this->writeArrayInOutputFormat($input, $output, $taskTypeSettings); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that this wasn't clear, we should also handle the JSON exceptions somewhere, so they don't break the whole server and cause a HTTP 500.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think should happen if the value is not parsable, return all task types or return none? I would say none so we do not enable something that should be disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense. Perhaps, we can also reset the value in the config to a valid json value when this happens?