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

feat(settings): add admin & user setting iframe #4373

Merged

Conversation

codewithvk
Copy link
Collaborator

@codewithvk codewithvk commented Jan 7, 2025

  • Initial cool admin setting iframe setup
  • WIP auth
  • Temp: Auth handling stuff
  • WIP: wopi setting upload
  • Created an AppData-based directory for system settings and user settings
  • Create a Settings controller API endpoint for handling AppData-based directories
  • Temporary Commit: Created a temporary UI to validate the functionality of user and system settings.
  • Change the admin settings iframe URL to adminIntegratorSettings.
  • WOPI: Update the wopi setting upload route to accept a file and store it to system-settings dir
  • add delete button and create wopi/setting route to handle wopi file request
  • Manage setting configs files with dynamic routes
  • Code cleanup: Remove POC helper functions
  • Send WOPI setting base URL to integrator
  • fix: fetch config url
  • wopi: add delete setting file route
  • refactor: token generation for iframe
  • feat(user-settings): introduce iframe for user settings
  • fix: linting issue for CI
  • fix: generate token for user shared config url
  • fix: accept document and setting url token for file upload
  • fix: set proper WOPI response and remove unnecessary WOPI callback from iframe
  • fix(settings): remove iframe title and section
  • fix(settings): fetch directory from root folder
  • fix(wopi): share SharedSettings to wopi checkfileInfo
  • fix(wopi): Generating setting token for guest users
  • fix(settings): generate user config per userId & handle guest users
  • fix: composer psalm error via pointing correct folder
  • fix: code cleanups
  • fix: move admin setting iframe below server-config
  • refactor: some code cleanups
  • config: support hasSettingIframeSupport capability
  • fix: Avoid warning on file id explode
  • feat(wopi): pass WOPI settings if iframe capability is allowed
  • fix: admin iframe load issue

Some todos that next Prs can fix

  • Resolves: #
  • Target version: main

@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 62c98ce to 104c780 Compare January 7, 2025 17:02
@codewithvk codewithvk marked this pull request as draft January 7, 2025 17:04
Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

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

Some early feedback, general approach seems good 👍

lib/Controller/DocumentController.php Outdated Show resolved Hide resolved
lib/TokenManager.php Outdated Show resolved Hide resolved
lib/Db/WopiMapper.php Outdated Show resolved Hide resolved
lib/Controller/DocumentController.php Outdated Show resolved Hide resolved
lib/Controller/DocumentController.php Outdated Show resolved Hide resolved
@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 905e1e2 to cc91ef8 Compare January 11, 2025 18:22
@codewithvk
Copy link
Collaborator Author

Related serverside PR : nextcloud/server#50145

@pedropintosilva
Copy link
Contributor

@codewithvk @juliusknorr thanks. Probably worth to create a separated PR for the vue conversion, right?

@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from c042023 to 5e11402 Compare January 20, 2025 10:56
@codewithvk codewithvk marked this pull request as ready for review January 21, 2025 12:34

This comment was marked as spam.

@elzody
Copy link
Contributor

elzody commented Jan 22, 2025

In order to resolve the failing tests, you should do the following:

  1. Make sure all the new files (and existing files, even) have the SPDX reuse header at the top
  2. Run composer run cs:fix to address formatting and styling issues, etc.
  3. Run composer run psalm -- --no-cache which will inform you of errors which should be fixed

@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 5e11402 to bf5a8bf Compare January 23, 2025 05:54
@codewithvk codewithvk changed the title WIP: Admin setting iframe Admin & User setting iframe Jan 23, 2025
@codewithvk codewithvk changed the title Admin & User setting iframe feat(settings): add admin & user setting iframe Jan 23, 2025
@codewithvk
Copy link
Collaborator Author

codewithvk commented Jan 23, 2025

In order to resolve the failing tests, you should do the following:

  1. Make sure all the new files (and existing files, even) have the SPDX reuse header at the top
  2. Run composer run cs:fix to address formatting and styling issues, etc.
  3. Run composer run psalm -- --no-cache which will inform you of errors which should be fixed

@elzody We could have one psalm error because we need to merge PR :nextcloud/server#50145 before.. I fixed other errors...Also could you please run CI - as I don't have access to run CI.

@@ -34,6 +34,17 @@
</em>
</p>

<!-- user settings iframe -->
<div id="user-cool-frame-section" class="section">
<h2>{{ t('richdocuments', 'Collabora User Settings') }}</h2>
Copy link
Member

Choose a reason for hiding this comment

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

We should call this differently as we want to remove the duplicate word "settings" from all seections we have (ref #4351)

Copy link
Contributor

Choose a reason for hiding this comment

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

How it looks now:
nextcloud local_index php_settings_user_richdocuments (1) (1)

I have discussed with Vivek that we should also remove Collabora since it's part of Office settings section.

If we also remove settings (even thought I do see "Personal settings" in the #4351 you have referenced) then we either replace it with something such as "preferences" or - and I think better - we simply remove that h2 completely and let the headings in the iframe being h2 (so, autotext and workbook will become upper level which probably makes more sense)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pedropintosilva Thanks for adding a screenshot :)

@juliusknorr
Copy link
Member

@codewithvk Can you also add some screenshots of how this looks in the settings page for review of @marcoambrosini as designer?

@codewithvk
Copy link
Collaborator Author

@juliusknorr @elzody I'm not able to figure out why wopi integration for db test broken, any idea?

@codewithvk
Copy link
Collaborator Author

Modified bit of UI of iframe

nextcloud local_index php_settings_user_richdocuments (2)
cc: @marcoambrosini @juliusknorr @pedropintosilva

@pedropintosilva
Copy link
Contributor

pedropintosilva commented Jan 24, 2025

Modified bit of UI of iframe

nextcloud local_index php_settings_user_richdocuments (2) cc: @marcoambrosini @juliusknorr @pedropintosilva

Awesome, much better, thanks!

I think We can still make it more clear in terms of the elements and their relation. What I mean is that right now the "Upload AutoText/Wordbook" buttons seem that they are referring to the list of files (which is not the case, those files were already uploaded). Best to clarify the main action by renaming it to "Add new AutoText" / "Add new Wordbook" but that seems a bit too long (specially when considering translations) -> so, what about "New AutoText" and "New Wordbook". I have noticed that in https://nextcloud-vue-components.netlify.app/#/Components/App%20containers/NcAppNavigation?id=ncappnavigationnewitem that sometimes they use the additional plus icon as a prefix (Maybe we could use it? @jancborchardt , @marcoambrosini )

try {
$categories = [];
$folder = $this->appData->getFolder($type);
$directories = $folder->getFullDirectoryListing();
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed that the server change was also required, but we cannot get that in for 31 anymore due to API freeze.

However you can directly access it by injecting IRootFolder and then fetching the path directly from it

		$instanceId = $this->config->getSystemValue('instanceid', null);

		if ($instanceId === null) {

		}

		return $this->rootFolder->get('appdata_' . $instanceId . '/richdocuments/your-path');

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@juliusknorr Is it safe to access the rootFolder from a security perspective?

May be for now we can do it as it seems we don't have other options.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that is fine, the server API that you have would do similar calls

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@juliusknorr I have added this commit - could you please checkout and restart CI ? 3e6964b

@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch 2 times, most recently from 3e6964b to 5302259 Compare January 27, 2025 12:42
$uri = $nextcloudUrl . '/index.php/apps/richdocuments/wopi/settings' . '?type=' . $type . '&access_token=' . $this->generateSettingToken($userId) . '&fileId=' . '-1';
return [
'uri' => $uri,
'stamp' => time()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@juliusknorr As of now temporary I'm sending stamp as time but we need to pass here Category folders etag/stamp - May be we can create method inside settingsService but still we need fetch stamp from Folder/SimpleFolder or even Node. I try to test with Node etag it seems not updating is something updated in child.

Copy link
Member

Choose a reason for hiding this comment

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

As a simple approach you could try the using getMTime which is probably enough, but I'm not entirely sure this propagates as well

If that doesn't we may need to manually update the etag whenever a file is added/updated/removed through richdocuments

The following code should work for that then:

$folder->getStorage()->getCache()->update($folder->getId(), [
	'etag' => uniqid(),
]);

Copy link
Member

@juliusknorr juliusknorr Jan 28, 2025

Choose a reason for hiding this comment

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

Just for future reference, the reason the etag is not propagating directly is because we skip it in https://github.com/nextcloud/server/blob/41c53648ad18e3a94b6ba18ad0e6c7c09a520bd9/lib/private/Files/Storage/Common.php#L346 as in other cases we do not make use of that for anything in appdata or we have a separate mountpoint like for collectives where we can apply our own storage wrapper nextcloud/collectives@b54e6be but that won't work for the case here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do in next PR.

@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 9e7c050 to 5124cff Compare January 29, 2025 09:58
codewithvk and others added 16 commits February 5, 2025 13:15
Signed-off-by: codewithvk <[email protected]>
@juliusknorr juliusknorr force-pushed the private/codewithvk/cool_setting_iframe branch from 56a8c72 to e170b53 Compare February 5, 2025 12:15
@juliusknorr
Copy link
Member

I have no clue yet why tests are failing, but this must be somewhat related to the branch, all recent prs against main succeed with cypress: https://github.com/nextcloud/richdocuments/pulls?q=sort%3Aupdated-desc+is%3Apr+is%3Aclosed+base%3Amain

I'll continue digging

$wopi = $this->wopiMapper->getWopiForToken($access_token);

$userId = $wopi->getEditorUid();
// TODO: auth - for admin??
Copy link
Member

Choose a reason for hiding this comment

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

What would be left here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nothing, Older comment ig. Will remove it

}
}

// TODO: Handle installDefaultSystemFiles setting
Copy link
Member

Choose a reason for hiding this comment

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

Please track todos as checklist items in the pr description rather then in the code so we can file them in follow up issues on merge

@codewithvk
Copy link
Collaborator Author

codewithvk commented Feb 5, 2025

I have no clue yet why tests are failing, but this must be somewhat related to the branch, all recent prs against main succeed with cypress: https://github.com/nextcloud/richdocuments/pulls?q=sort%3Aupdated-desc+is%3Apr+is%3Aclosed+base%3Amain

I'll continue digging

I have found that a few tests are failing locally, and they also fail on the main branch (based on my local testing). So, perhaps I'll try to create a separate PR to fix those Cypress tests.

@juliusknorr
Copy link
Member

juliusknorr commented Feb 5, 2025

Pushed two prs:

@juliusknorr
Copy link
Member

Seems to proof that main is running fine, just this branch, still no clue yet

@codewithvk
Copy link
Collaborator Author

Seems to proof that main is running fine, just this branch, still no clue yet

For me - Main branch not works :)
Screenshot from 2025-02-05 21-41-59

@juliusknorr juliusknorr merged commit 452fb40 into nextcloud:main Feb 5, 2025
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress enhancement New feature or request feedback-requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants