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

💄 Transition validation markup #666

Open
wants to merge 1 commit into
base: support/3.2
Choose a base branch
from

Conversation

jbostoen
Copy link
Contributor

@jbostoen jbostoen commented Sep 4, 2024

Base information

Question Answer
Related to a SourceForge thead / Another PR / Combodo ticket? No
Type of change? Enhancement

Symptom (bug) / Objective (enhancement)

When using for example the new event listeners to perform a check before the object is written during a transition; the current error modal is ugly. It does not use a nice list; and it shows context data.

Proposed solution (bug and enhancement)

The error messages are just examples.

Before:
image

After:
image

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand digging in the code?

Checklist of things to do before PR is ready to merge

@jbostoen jbostoen changed the base branch from develop to support/3.2 September 4, 2024 04:00
@@ -1355,7 +1362,7 @@ function DisplayNavigatorGroupTab($oP)
$sMessage = $e->getMessage();
$sSeverity = 'info';
}
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten',$sIssues);
$sIssueDesc = ($oException !== null ? '<div style="display: block;"><style scoped> ul { list-style-type: disc; } </style>'.$oException->getHtmlMessage().'</div>' : Dict::Format('UI:ObjectCouldNotBeWritten', $sIssues));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While not ideal, this will be easier to maintain than a CSS rule somewhere in a file.

The main issues:

  • Error modal uses flex.
  • The "ul" element loses its standard formatting by default in iTop.

Copy link
Contributor

Choose a reason for hiding this comment

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

ErrorModal should be fixed IMHO

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, in the backoffice when you want HTML to retrieve its standard style like for lists, surround it with the .ibo-is-html-content.

I would strongly be against inline style like this. A dedicated rule in the right file would be better.

That being said, you should ping @jf-cbd or @rquetiez , they worked on error messages and removing/sanitizing HTML errors last summer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try the .ibo-is-html-content when I find some time.
Not sure if that would also change the display to block or if there's another CSS class which we can use.

@jf-cbd jf-cbd added enhancement New feature or request UI labels Sep 27, 2024
Comment on lines 1319 to +1323
$sIssues = $e->getMessage();

if($e instanceof CoreCannotSaveObjectException) {
$oException = $e;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if you would do this instead? Then there's no need to do the if/else later on.

Suggested change
$sIssues = $e->getMessage();
if($e instanceof CoreCannotSaveObjectException) {
$oException = $e;
}
$sIssues = $e->getHtmlMessage();

(correct styling would still something to be done in CSS, maybe separate PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure whether or not we can expect other exceptions here, which don't support the getHtmlMessage(), so I was being cautious :)

Copy link
Contributor

@Hipska Hipska Oct 2, 2024

Choose a reason for hiding this comment

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

Right, CoreException doesn’t seem to have this method 🤔

Then maybe just do getHtmlMessage when it exists and the normal getMessage otherwise?

@jf-cbd
Copy link
Contributor

jf-cbd commented Oct 11, 2024

Accepted during functional review. Will check with @rquetiez for technical details (3.2 compatibility and way to define the message).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UI
Projects
Status: Pending Combodo update
Development

Successfully merging this pull request may close these issues.

4 participants