(core) fix form URL when team is encoded in domain

Summary:
This moves the `formUrl` logic to `encodeUrl`, which is more
aware of how the URL is constructed than UserAPI. UserAPI can
only reliably construct API URLs.

Test Plan: extended tests

Reviewers: georgegevoian

Reviewed By: georgegevoian

Subscribers: georgegevoian

Differential Revision: https://phab.getgrist.com/D4171
This commit is contained in:
Paul Fitzpatrick
2024-01-23 16:24:57 -05:00
parent 95c0441d84
commit dba3a59486
4 changed files with 60 additions and 46 deletions

View File

@@ -15,6 +15,7 @@ import DataTableModel from 'app/client/models/DataTableModel';
import {ViewFieldRec, ViewSectionRec} from 'app/client/models/DocModel';
import {ShareRec} from 'app/client/models/entities/ShareRec';
import {InsertColOptions} from 'app/client/models/entities/ViewSectionRec';
import {urlState} from 'app/client/models/gristUrlState';
import {SortedRowSet} from 'app/client/models/rowset';
import {showTransientTooltip} from 'app/client/ui/tooltips';
import {cssButton} from 'app/client/ui2018/buttons';
@@ -299,9 +300,12 @@ export class FormView extends Disposable {
this._url = Computed.create(this, use => {
const doc = use(this.gristDoc.docPageModel.currentDoc);
if (!doc) { return ''; }
const url = this.gristDoc.app.topAppModel.api.formUrl({
urlId: doc.id,
vsId: use(this.viewSection.id),
const url = urlState().makeUrl({
api: true,
doc: doc.id,
form: {
vsId: use(this.viewSection.id),
},
});
return url;
});
@@ -580,9 +584,12 @@ export class FormView extends Disposable {
throw new Error('Unable to copy link: form is not published');
}
const url = this.gristDoc.app.topAppModel.api.formUrl({
shareKey:remoteShare.key,
vsId: this.viewSection.id(),
const url = urlState().makeUrl({
doc: undefined,
form: {
shareKey: remoteShare.key,
vsId: this.viewSection.id(),
},
});
await copyToClipboard(url);
showTransientTooltip(element, 'Link copied to clipboard', {key: 'copy-form-link'});