Skip to content

Table scheme import - #2888

Merged
blizzz merged 46 commits into
mainfrom
table-scheme-import
Aug 26, 2026
Merged

Table scheme import#2888
blizzz merged 46 commits into
mainfrom
table-scheme-import

Conversation

@luka-nextcloud

Copy link
Copy Markdown
Contributor

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@blizzz blizzz linked an issue Aug 14, 2026 that may be closed by this pull request
8 tasks

@blizzz blizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Early comments, some can be left for later.

UI wise it looks really nice already!

Image
  • I would not display the UUID as title in the check box. It looks technical and table managers will have not deeper knowledge about it. Would completely keeps this identifier internal and instead use the New Title.

  • In my quick test I also see that Views would be dropped instead of being kept

  • Maybe need to double check the sort order as well when nothing is defined

This is very promising already! :)

Comment thread lib/Migration/Version2200Date20260819000000.php
Comment thread lib/Controller/ContextController.php Outdated
Comment thread lib/Controller/ContextController.php Outdated
*/
#[NoAdminRequired]
#[RequirePermission(Application::PERMISSION_MANAGE, null, 'context', 'contextId')]
public function importScheme(int $contextId, ?string $name, ?string $iconName, ?string $description, ?array $nodes, ?array $tables): DataResponse {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Node sure I understand correctly the role of $nodes vs $tables. Maybe have an idea with the TODO against the nodes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

$nodes is array ids of tables and views to be shown. The $tables is array of related source tables.

Comment thread lib/Service/ColumnService.php Outdated
Comment thread lib/Service/StructureService.php
Comment thread lib/Service/TableService.php Outdated
$columns = $this->columnService->findAllByTable($id, null, $table);
$this->enhanceTable($table, $userId);
return new TableScheme($table->getTitle(), $table->getEmoji(), $columns, $table->getViews() ?: [], $table->getDescription() ?: '', $this->appManager->getAppVersion('tables'), $table->getColumnOrderSettingsArray(), $table->getSortArray());
$this->enhanceTable($table, $userId ?? $this->userId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i suppose there is a reason for this line change? ^

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It would cause error when $userId is null

Comment thread lib/Service/ViewService.php Outdated
@luka-nextcloud

Copy link
Copy Markdown
Contributor Author

@blizzz

In my quick test I also see that Views would be dropped instead of being kept

Does it mean that we should remove the Remove Views section?
image

Maybe need to double check the sort order as well when nothing is defined

Could you please share more details?

@blizzz

blizzz commented Aug 20, 2026

Copy link
Copy Markdown
Member

@blizzz

In my quick test I also see that Views would be dropped instead of being kept

Does it mean that we should remove the Remove Views section?

No, that should be there!

In my test, the scheme file I uploaded did not have any changes with the views. However the dialog showed they would be removed, instead of kept.

@luka-nextcloud

Copy link
Copy Markdown
Contributor Author

@blizzz

In my quick test I also see that Views would be dropped instead of being kept

Does it mean that we should remove the Remove Views section?

No, that should be there!

In my test, the scheme file I uploaded did not have any changes with the views. However the dialog showed they would be removed, instead of kept.

The application scheme includes the table schemes of related source tables. So it also detects the different views of those tables. Should we skip processing removed views when importing application scheme?

@blizzz

blizzz commented Aug 20, 2026

Copy link
Copy Markdown
Member

schemes

@blizzz

In my quick test I also see that Views would be dropped instead of being kept

Does it mean that we should remove the Remove Views section?

No, that should be there!
In my test, the scheme file I uploaded did not have any changes with the views. However the dialog showed they would be removed, instead of kept.

The application scheme includes the table schemes of related source tables. So it also detects the different views of those tables. Should we skip processing removed views when importing application scheme?

Views that are missing in the scheme that is being imported shall be removed. In my case the detection was not correct, since they were still present, they should not be shown to be removed.

@luka-nextcloud

Copy link
Copy Markdown
Contributor Author

@blizzz Do you mean that the view does present in the scheme but shown to be removed? It is strange, I cannot reproduce this issue. Could you please share the reproduce steps, as well as the scheme file you used and the uuid of the effected view?

luka-nextcloud and others added 10 commits August 21, 2026 12:11
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Comment thread tests/unit/Service/StructureServiceTest.php
@blizzz

This comment was marked as resolved.

@luka-nextcloud

This comment was marked as resolved.

@blizzz

This comment was marked as resolved.

@blizzz

This comment was marked as resolved.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz
blizzz force-pushed the table-scheme-import branch from f57b358 to c112d88 Compare August 21, 2026 18:54
blizzz added 3 commits August 21, 2026 21:09
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz
blizzz force-pushed the table-scheme-import branch from be79f8e to d82400f Compare August 21, 2026 19:14
if (!isset($tables['addTables']) || !is_array($tables['addTables'])
|| !isset($tables['modifyTables']) || !is_array($tables['modifyTables'])) {
throw new BadRequestError('Invalid tables structure provided.');
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

removing tables needs to be added as well, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should not remove the tables since they might be used in another application. Updating $node already reflect the elements to show on that application.

blizzz and others added 5 commits August 24, 2026 06:54
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
@luka-nextcloud
luka-nextcloud marked this pull request as ready for review August 24, 2026 13:33
@luka-nextcloud
luka-nextcloud requested a review from enjeck as a code owner August 24, 2026 13:33
luka-nextcloud and others added 3 commits August 24, 2026 17:04
Signed-off-by: Luka Trovic <luka@nextcloud.com>
fixes updating columns when UUIDs are provided, e.g. during schema
import. There we already have the proper local IDs in place.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Leads to confusion on other places, when it is re-imported and
json_decoded. For example in schema update cases, it would result into
identifying columns as modified while in fact they are unchanged.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz

blizzz commented Aug 24, 2026

Copy link
Copy Markdown
Member

I added two small commits with small fixes.

A bit unsure about f8e2e1c – here i soften the check and instead of erroring out, simply discard the submitted UUID. Easier on user front-ends. Also, when i would all passing this parameter, then the remaining call is set on true, but we have more entry points here afaik. cc @samin-z – FYI you had the error case and we talked about that as well.

More todos:

  • we need fix: ignore client sent option UUID and generate new UUID on column update #2899 extended with a migration step to add UUIDs to selection options where they are missing
    • background: newly created selection options do not get the UUID set upon creation, hence they are not being treated correctly
  • after an import on the web interface, the data is not being updated/reloaded automatically (e.g. when a table title is being changed).

I still only tested a little bit, but spent maybe too long on those small changes (investigation time…).

@enjeck enjeck left a comment

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.

lots of comments...

Comment thread lib/Model/FilterSet.php Outdated
Comment thread lib/Service/ContextService.php Outdated
Comment thread lib/Controller/ContextController.php Outdated
Comment thread lib/Model/ContextScheme.php Outdated
Comment thread lib/Controller/ApiTablesController.php Outdated
Comment thread lib/Service/ContextService.php Outdated
Comment thread lib/Service/ContextService.php
$nodes = $context->getNodes();
$tables = [];

foreach ($nodes as &$node) {

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 leaves a dangling reference, so we should unset($node) after the loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is unnecessary, we are not using the $node after loop.

Comment thread src/modules/modals/ImportTableScheme.vue Outdated
Comment thread src/modules/modals/ImportTableScheme.vue
enjeck
enjeck previously requested changes Aug 25, 2026
Signed-off-by: Luka Trovic <luka@nextcloud.com>
@blizzz

blizzz commented Aug 25, 2026

Copy link
Copy Markdown
Member
  • Views are shown as changed, because the columnUuid is not exposed in columnSettings in the export.
    • I am also seeing that in columnSettings the columnUuid is not being exported, hence not present on import. It appears as a changed column. Views are being updated. At least cannot smuggle in a foreign column :)
  • It must be possible to import a table with an already present UUID. The idea is having portable tables that can be updated. The issue that we have here is that we require table UUIDs for Contexts, fortunately only for them! The limitation currently makes it impossible to have a copy of a table on the same instance (main use case is across instances, but not everybody may have that).
    • My suggestion would be to catch the constrain in Table scheme import and regenerate the UUID. Or generate a new UUID for imported tables in general. But only for the Table! This should not cause any other issues when importing a scheme into a table (and we did not have it before – only added for Contexts.).
  • after importing a reload takes place, but it contains the old state
  • Contexts: Show in app list setting is not taken over (survivable)
  • ✔️ Context shares are not taken over, but this actually makes sense, with importing across instances in mind.
  • i am not sure about the column order. I do not see we can change it in tables (but I recall there was a feature). The JSON exports fills the order, but importing shows the changes, but it does not have any effect.

Comment thread lib/Migration/Version2200Date20260819000000.php Outdated
luka-nextcloud and others added 5 commits August 26, 2026 14:29
Signed-off-by: Luka Trovic <luka@nextcloud.com>
- UUIDs on tables are not needed for their strucutre updates
– …but for Contexts. When a table is used in them, it has to be shared

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

test('Export scheme to json', async ({ userPage: { page } }) => {
const sourceScheme = await getTutorialScheme(page)
prepareSchemeForImport(sourceScheme, 'Imported scheme export')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tests succeed locally when i add this back

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz
blizzz force-pushed the table-scheme-import branch from 7f5621d to d46fe08 Compare August 26, 2026 20:57
@blizzz
blizzz merged commit c242fc4 into main Aug 26, 2026
79 checks passed
@blizzz
blizzz deleted the table-scheme-import branch August 26, 2026 21:11
@blizzz blizzz mentioned this pull request Aug 26, 2026
1 task
@enjeck enjeck mentioned this pull request Aug 30, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structure update

3 participants