Skip to content

Reactify configuration editing without changing stored setting formats#10509

Open
Montekkundan wants to merge 3 commits into
aces:mainfrom
Montekkundan:montek/5213-configuration-reactify
Open

Reactify configuration editing without changing stored setting formats#10509
Montekkundan wants to merge 3 commits into
aces:mainfrom
Montekkundan:montek/5213-configuration-reactify

Conversation

@Montekkundan
Copy link
Copy Markdown
Contributor

Brief summary of changes

  • Rewrites the main Configuration module page from the Smarty/jQuery form into a React entrypoint.
  • Adds JSON endpoints for loading configuration categories/settings and saving setting updates.

Testing instructions (if applicable)

  • Open /configuration/ as a user with the config permission and confirm the page loads as the React UI without the old Smarty form.
  • Click through the category tabs and confirm settings load for each category.
  • Edit a text/email/textarea setting and confirm the value saves on blur and persists after category reload.
  • Edit a boolean setting that currently stores true/false, then one that stores 1/0, and confirm each keeps its existing storage format after saving.
  • Add and remove values from a multi-value setting such as scan types or instruments and confirm the updated values persist.

Link(s) to related issue(s)

@github-actions github-actions Bot added Language: PHP PR or issue that update PHP code Language: Javascript PR or issue that update Javascript code Module: configuration PR or issue related to configuration module labels May 25, 2026
@MaximeBICMTL
Copy link
Copy Markdown
Contributor

Although they are currently (unfortunately) pervasively used in LORIS, propTypes and defaultProps are removed in the next version of React. I am a strong advocate that we should use Typescript exclusively for all new Javascript code moving forward. To be discussed at a next meeting.

https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops

@github-actions github-actions Bot added the Module: dashboard PR or issue related to dashboard module label May 27, 2026
@skarya22 skarya22 self-assigned this May 29, 2026
@skarya22 skarya22 self-requested a review May 29, 2026 15:31
Copy link
Copy Markdown
Contributor

@skarya22 skarya22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the changes from #8471 to .eslintrc.json and Makefile?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file -- it should not have been committed, can you also add it to the gitignore?

Comment on lines +183 to +185
$setting['Value'] = '';
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If is not allow multiple and there are multiple settings it should throw this error:

 throw new \ConfigurationException(
                                "Multiple config settings for setting that "
                                . "does not allow multiple"
                            );

$setting['Value'] = '';
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing boolean check / conversion

                if ($setting['DataType'] == "boolean") {
                    $settingValue = $setting['Value'] ?? "false";
                    if ($settingValue === "false") {
                        $setting['Value'] = false;
                    } else if ($settingValue === "true") {
                        $setting['Value'] = true;
                    } else {
                        $setting['Value'] = !empty($settingValue);
                    }
                }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be quite different than the version in @8471, it is missing loadResources for instance -- was that on purpose?

Comment on lines +31 to +42
/**
* Returns true if user has access to this endpoint.
*
* @param \User $user The user whose access is being checked
*
* @return bool
*/
#[\Override]
public function isAccessibleBy(\User $user) : bool
{
return $user->hasPermission('config');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permission is checked by the module entry in configuration.class.inc, so we don't need this here

*
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
*/
class Setting extends \NDB_Page implements RequestHandlerInterface
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this extend Endpoint instead of Page like it did in #8471? Since we don't really open the Settings page as a page? Let me know if there was a reason you did NDB_Page instead. If it is changed to Endpoint it will need

    public function process(
        ServerRequestInterface $request,
        RequestHandlerInterface $handler
    ) : ResponseInterface {
        return $handler->handle($request);
    }

from #8471

};

/**
* Intro text for the configuration page.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this comment to be the actual intro

<p>
Please enter the various configuration variables into the fields below.
For information on how to configure LORIS, please refer to the Help
section and/or the Developer&apos;s guide.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
section and/or the Developer&apos;s guide.
section and/or the Developer's guide.

Comment on lines +513 to +537
function booleanRadioValue(value: ConfigValue): string {
if (value === '1' || value === 1) {
return '1';
}
if (value === '0' || value === 0) {
return '0';
}
if (value === true || value === 'true') {
return 'true';
}
return 'false';
}

/**
* Preserve legacy 1/0 boolean storage when a setting already uses it.
*
* @param {ConfigValue} value Stored boolean value
* @return {object}
*/
function booleanRadioOptions(value: ConfigValue): ConfigOptionMap {
if (value === '1' || value === '0' || value === 1 || value === 0) {
return {'1': 'Yes', '0': 'No'};
}
return {'true': 'Yes', 'false': 'No'};
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are config values being moved from 0 / 1 to true / false? I think we should keep them as 0 / 1 for now, and revisit migrating to true / false later.

@skarya22 skarya22 assigned Montekkundan and unassigned skarya22 Jun 2, 2026
@skarya22 skarya22 added the State: Needs work PR awaiting additional work by the author to proceed label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Module: configuration PR or issue related to configuration module Module: dashboard PR or issue related to dashboard module State: Needs work PR awaiting additional work by the author to proceed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Configuration] module rewrite with react

3 participants