-
Notifications
You must be signed in to change notification settings - Fork 17
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
FEATURE: Implement Media Details Screen #148
Conversation
Hi @grebaldi, thx for jumping on this topic! Especially with actions like replace, delete etc. we have to be careful in the UX as we need to make sure an editor understands the global consequences. I wouldn't introduce a separate flag for this as we can replace all old features and I don't expect issues there. |
Hi @Sebobo,
Thanks for the pointer, I wasn't aware of the discussion :) I added the TODOs from there to the list in this PR. There's one question though:
Does this refer to Shel.Neos.ImageChecker? Regarding Architecture:
Okay, I'll add a I'd still like to clarify one thing in this context: AFAICT the
I'd prefer the second approach. What do you think, @Sebobo? |
👍 no problem, should have linked the issue
Yes, but it's isn't part of this issue. As the rewrite of the AssetEditor is separate (big) topic.
👍 yes that sounds perfect. It might be a bit confusing now that they all lie next to each other but have those not super obvious interdependencies. So at some point we might need to have 3 folders for packages, ui plugin, backend module and shared stuff. |
I think there's a way to make I'm going to experiment a little to see, whether To hide wdyt, @Sebobo? |
|
87e88b3
to
52d3e8e
Compare
Hi @Sebobo, I've rebased and everything is green 🎉 I'm currently stuck with a problem that we should discuss probably: The image editor (Neos.Ui) passes an I suppose it is possible to resolve the local asset Id, but I think we should discuss how to go about this. |
I think for now we should disable the button then if we have an imported asset. There are several issues with imported assets atm and I have to workaround them in other places too. So we should discuss this separately as the Media API needs to be fixed for that. But targeting this for Neos 9 would be essential I think. |
Never mind, I'll take a look. Probably missed a bug with the recent changes, because I tested with imported assets last (and the screen you're seeing is the current behavior for imported assets - I apparently overlooked that regular assets are broken too).
I believe that would require a change for the Image Editor (Neos.Ui). Regarding that: I've been thinking that it might be sensible to move that editor entirely over to Flowpack.Media.Ui (it definitely makes more sense to let it reside closer to the Media Context rather than the Core). Such a migration would be out of scope for this PR though. So, I'm considering two options for going forward:
Wdyt? |
I investigated locally and regular assets seem to work fine for me. So, we'd need to take a look at what's happening in your setup. |
buildLinkToMediaUi={buildLinkToMediaUi} | ||
assetIdentity={{ | ||
assetId: this.props.imageIdentity, | ||
assetSourceId: '', |
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.
This is the problem. You need to define the asset source or it won't work when more than one is defined.
But I don't unterstand why it works then if you only have one asset source.
assetSourceId: '', | |
assetSourceId: 'neos', |
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.
Interestingly enough it still works with assets from other sources 🤷🏻♂️
Noticed some graphical things:
|
261833a
to
52dd187
Compare
Hi @Sebobo, I was able to fix some of the issues you have found (and I'll continue with the rest of course). Along the way there are a couple of questions/remarks I'd like to clarify:
I was able to fix the line break, but the missing icons seem to be an issue with Neos UI itself. In plugin context, the dialog uses the Checkboxes as provided by Neos UI. Those Checkboxes do not provide the greyed-out checkmark icon (maybe an older version did?).
What browser did you use for testing? I was not able to reproduce this issue in Gecko, WebKit or Blink on Linux.
How do I get to the variants tab? (Full disclosure: I don't know what the variants tab is 😅) |
Thx! The variant tab is enabled via the feature flag I'm testing with Brave. Will check your latest version later today and see if the error is still there and if I see why it's there if so. Regarding the icon we then can check whether we need a hot fix in our code or fix it in the UI itself. |
Looks like those icons have been explicitly removed: neos/neos-ui#2995 The "@neos-project/react-ui-components": "5.3.7" The commit on Neos UI PR 2995 seems only to be included as early as That explains why the icon shows up in the backend module but not in Neos UI. For a fix, I could update |
ah ok 👌 Updating the components should be no problem. We have some other dependencies which break everything when being updated. |
Looks good so far. My first tests looked fine! I still have the issue with the content exceeding the content area and breaking the ui layout. |
private $assetProxyQuery; | ||
|
||
/** | ||
* @param AssetProxyQueryInterface $assetProxyQuery |
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.
You can remove all the duplicate type annotations in this class.
Yeah, this was it :) I've started development on 8.1 and didn't upgrade since. I can reproduce the issue now on 8.2 and will come up with fix soonish. Update: I fixed the scrolling issue for 8.2 and also removed superfluous type comments from the PHP code. |
This includes the following changes: - Package `@media-ui/media-details-screen` has been created - Code that is specific to the details screen has been moved from `@media-ui/media-module` to `@media-ui/media-details-screen` - Details.tsx - Preview.tsx - Package `@media-ui/neos-ui-plugin` has been created - Package `@media-ui/neos-ui-plugin` registers secondary inspector editors from both `@media-ui/media-details-screen` and `@media-ui/media-selection-screen` - Yarn script `watch:editor` has been renamed to `watch:plugin` - Yarn script `watch:plugin` has been adjusted to watch `@media-ui/neos-ui-plugin` instead of `@media-ui/media-selection-screen` - Yarn script `build:editor` has been renamed to `build:plugin` - Yarn script `build:plugin` has been adjusted to build `@media-ui/neos-ui-plugin` instead of `@media-ui/media-selection-screen`
…lsScreen This includes the following changes: - `InteractionProvider` has been introduced - Lives in `@media-ui/core` - A context-driven API that allows to open up a `confirm`-style Dialog from anywhere in the application - `faExclamationTriangle` was added to the icon library to replicate Neos.Neos.Ui Look&Feel - Same API can potentially be used to implement `prompt`- and/or `alert`-style Dialogs as well - Something like this should actually be provided by Neos.Neos.Ui - `ApprovalAttainmentStrategy` has been introduced - Lives in `@media-ui/core` - A strategy that allows different application entry points to define custom behavior when it comes to obtaining approval for certain actions - This allows the MediaDetailsScreen to ask for confirmation before e.g. deleting an asset, whereas the main media module does not - The default strategy is `AssumeApprovalWasGivenForEveryAction`, which never asks for confirmation - `InteractionProvider` gets instantiated in every application entry point - `ApprovalAttainmentStrategy` covers all critical actions - `updateAsset` - `setAssetCollections` - `setAssetTags` - `deleteAsset` - `replaceAsset` - Make sure that SelectBoxes for Tags and Asset Collections do not update prematurely (before approval/confirmation was given) - The underlying SelectBox component otherwise stays in a broken state if not synced back properly
This includes the following changes: - A PHPUnit setup was added to the project - PHPUnit ^9.5 - Unit tests can be found under `Tests/Unit` - This includes an additional job in the github actions `tests` workflow - The `SearchTerm` domain object has been introduced - A value object encapsulating newly introduced logic for search terms entered in the Media UI - A search term may now have a special format `/id:([0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12})/` in which case the search will look for an asset by its Id rather than performing a full text search - The `AssetProxyIteratorAggregate` domain object has been introduced - This has become necessary, because `QueryResolver` relies on processing iterables, which is fulfilled when dealing with an `AssetProxyQueryInterface` (or better: `AssetProxyQueryResultInterface`). However, looking up an asset by its Id via `AssetProxyRepositoryInterface::getAssetProxy` won't return an `AssetProxyQueryInterface`, but an `AssetProxyInterface`, which is not iterable. - There's two implementations of `AssetProxyIteratorAggregate`: - `AssetProxyListIterator` - will take 1 or more `AssetProxyInterface`s and provide the means to iterate over them - `AssetProxyQueryIterator` - will take an `AssetProxyQueryInterface` and resolves the query once iteration starts - The `createAssetProxyQuery` method of `QueryResolver` has been adjusted and is now called `createAssetProxyIterator` - Both, the `assetCount` and the `assets` method of `QueryResolver` have been adjusted accordingly
…ails screen This includes the following changes: - A JavaScript unit test setup was added to the project - mocha (^10.1) & chai (^4.3) - Unit tests are colocated with the respective item under test (in an `{itemName}.spec.ts` file each) - This includes an additional job in the github actions `tests` workflow - The `SearchTerm` domain object has been introduced to `@media-ui/core` - Replicates the funcationality of the PHP `SearchTerm` domain object - A `SearchTerm` can be created from the current window location (if it contains a `searchTerm` parameter) - Since `SearchTerm`s are now able to match an exact Id, it is possible to link to the Media Ui with a single asset being selected - A button "Open in Media Ui" has been added to the `<PreviewActions />`-Component in `@media-ui/media-details-screen` - If a `SearchTerm` refers to an exact Id, the asset source "neos" will be selected automatically, regardless of persisted selection - The `useSelectAssetSource` has been modified, so the returned `selectAssetSource` function accepts an asset source id rather than an entire `AssetSource` object
This includes the following changes: - The media details screen layout remains stable when switching from loading to loaded state - During loading state the preview image now has a low opacity to reduce flashing - Scrollability has been limited to the asset inspector area as opposed to the entire media details screen
Big ❤️, thx Wilhelm |
resolves: #73
This is a full integration of the Media Details Screen. It's available with
useNewMediaSelection
set to true.Interaction
: Ad-Hocconfirm
-,alert
- andprompt
-style dialogsThis PR introduces the
Interaction
concept to the@media-ui/core
. It is a context-driven API that needs to be initialized for every application entry point. The idea is to enable ad-hocconfirm
-,alert
- andprompt
-style dialogs without much React ceremony, but instead with an API closer to the browser-nativeconfirm
,alert
andprompt
functions.The call-site looks as simple as this:
Currently, only
confirm
has been implemented, because there's no need for the other ones in the scope of this PR (or perhaps the Media UI at large). In fact, this API (or one similar to this) should actually be provided by Neos.Neos.Ui.ApprovalAttainmentStrategy
: To ask or not to ask?This lengthy name refers to another concept introduced by this PR. The problem is that depending on the context certain actions (like updating asset properties) should require confirmation by the user. For example: While editing asset properties in the media module is not a problem at all, editing asset properties in the secondary inspector might give an editor the impression that the changes will only be applied to the image variant that is used as a node property.
Media Module:
Peek.2022-11-16.15-48.mp4
Secondary Inspector:
Peek.2022-11-16.15-49.mp4
To solve this, different application entry points can now provide an
ApprovalAttainmentStrategy
. Depending on the action anApprovalAttainmentStrategy
can use theInteraction
API to show a confirmation dialog or just returnPromise.resolve(true)
to automatically give the approval.Components like
<PropertyInspector />
then ask the currently appliedApprovalAttainmentStrategy
for approval before they perform a critical action.The
ApprovalAttainmentStrategy
covers the following actions:updateAsset
setAssetCollections
setAssetTags
deleteAsset
replaceAsset
By default, only
deleteAsset
will ask for confirmation (This also solves:TODO: Use custom modal
, see:media-ui/Resources/Private/JavaScript/core/src/provider/MediaUiProvider.tsx
Line 74 in 1326bef
The application entry point in
@media-ui/media-details-screen
adds confirmation dialogs for all actions."Open in Media Ui" Action
Peek.2022-11-30.15-13.mp4
The Media Ui main application now reads the URL parameter
searchTerm
, which can be used as a means to initialize the search term input. Additionally, the search term can now have a special format/id:([0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12})/
in which case the search will look for an asset by its Id rather than performing a full text search. Also, the asset passed via the search term will be selected automatically.With both these features in place, it is now possible to create a link into the Media Ui main application with a preselected asset. The
<PreviewActions />
-Component of the media details screen now provides such a link. The Media Ui main application will respectively open in a separate tab and show the asset from media details screen.Along with this feature come unit test setups for both Server-Side and Client-Side code (mainly to test the
SearchTerm
-related domain logic). Regarding the JavaScript tests, I'd like to address the elephant in the room right away:Why not
jest
?I have chosen to use the good ol'
mocha
+chai
combination for JavaScript unit tests. So, obviously, one might ask why not usejest
(as probably the majority of contemporary projects do, including Neos.Ui)?I recently have found
jest
to be a considerable maintenance burden with the node ecosystem moving towards native ESModule support. I have had projects halt the transition towards ESM entirely, becausejest
couldn't be made to work. ESM has been stable since Node v12 (see: https://nodejs.org/docs/latest-v12.x/api/esm.html), so for at least 3 years. TypeScript took a very long time to catch up to that, but since May of this year, full ESM support for Node has been added as well (see: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/). Unfortunately, ESM support injest
is still an experimental feature (see: https://jestjs.io/docs/ecmascript-modules), so it is likely to still be a reason for many packages in the ecosystem to hold back their transition towards ESM. I'm aware that this is not an immediate problem for the Media Ui, since it's based on CommonJS packages. But since I have fought this problem multiple times already, I've decided to not start any new testing setups on the basis ofjest
, but usemocha
+chai
instead, because both these packages are well maintained and just work.mocha
+chai
do not come without their own problems though. Notably, I had to exclude@types/mocha
from the setup, because those types were colliding with globals registered bytestcafe
(this is being addressed here: DevExpress/testcafe#6338). However, it is likely this issue would have come up withjest
as well.All of this being said, I wish to point out, that I'm of course open to discuss this point (This also applies to every other implementation decision I have made in this PR :)).
TODOs
/id:([0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12})/
format is likely to be a false assumption, because assets from foreign asset sources may have Ids that are not UUIDs.neos
to retrieve the local asset, Ids are guaranteed to be UUIDs.neos
solves this.TODO
@media-ui/media-details-screen
@media-ui/neos-ui-plugin
package and move plugin integration logic there (for both details screen and selection screen)Make "Replace Asset" work, OR: Remove "replace" button?Make "Preview Asset" workMake "Delete Asset" workShow Title, description & copyright in AssetEditor (see Shel.imageValidator) hidden under a button with an "I" iconAllow adding rules like in the validator package and show an alert if they are not fulfilledtheme.sidebarWidth
space for the asset inspector, to leave more room for the asset itself@neos-project/react-ui-components
to the latest5.3.*
5.3.18
atm, but I went for5.3.13
instead, because the package patch for@neos-project/react-ui-components
won't work otherwise and5.3.13
contains neos/neos-ui@abceecc, which is the change that needed to be addressed.