chore: remove legacy link support

Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
This commit is contained in:
Christian Hartmann 2024-10-05 20:14:44 +02:00
Родитель d5de048ffa
Коммит c732219ece
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 01CF79F7199D2C63
10 изменённых файлов: 42 добавлений и 123 удалений

Просмотреть файл

@ -68,16 +68,13 @@ class Constants {
public const FORM_ACCESS_NOPUBLICSHARE = 0;
public const FORM_ACCESS_PERMITALLUSERS = 1;
public const FORM_ACCESS_SHOWTOALLUSERS = 2;
/** @deprecated 5.0.0 still needed for Migrations */
public const FORM_ACCESS_LEGACYLINK = 3;
public const FORM_ACCESS_LEGACYLINK_PERMITALLUSERS = 4;
public const FORM_ACCESS_LEGACYLINK_SHOWTOALLUSERS = 5;
public const FORM_ACCESS_ARRAY_PERMIT = [
self::FORM_ACCESS_PERMITALLUSERS,
self::FORM_ACCESS_LEGACYLINK_PERMITALLUSERS
];
public const FORM_ACCESS_ARRAY_SHOWN = [
self::FORM_ACCESS_SHOWTOALLUSERS,
self::FORM_ACCESS_LEGACYLINK_SHOWTOALLUSERS
];
/**

Просмотреть файл

@ -2765,11 +2765,6 @@ class ApiController extends OCSController {
// If hash given, find the corresponding share & check if hash corresponds to given formId.
if ($shareHash !== '') {
// public by legacy Link
if (isset($form->getAccess()['legacyLink']) && $shareHash === $form->getHash()) {
$isPublicShare = true;
}
// Public link share
$share = $this->shareMapper->findPublicShareByHash($shareHash);
if ($share->getFormId() === $formId) {

Просмотреть файл

@ -117,31 +117,6 @@ class PageController extends Controller {
return new RedirectResponse($internalView);
}
// For legacy-support, show public template
try {
$form = $this->formMapper->findByHash($hash);
} catch (DoesNotExistException $e) {
return $this->provideEmptyContent(Constants::EMPTY_NOTFOUND);
}
if (isset($form->getAccess()['legacyLink'])) {
// Inject style on all templates
Util::addStyle($this->appName, 'forms');
// Has form expired
if ($this->formsService->hasFormExpired($form)) {
return $this->provideEmptyContent(Constants::EMPTY_EXPIRED, $form);
}
// Public Template to fill the form
Util::addScript($this->appName, 'forms-submit');
$this->insertHeaderOnIos();
$this->initialState->provideInitialState('form', $this->formsService->getPublicForm($form));
$this->initialState->provideInitialState('isLoggedIn', $this->userSession->isLoggedIn());
$this->initialState->provideInitialState('shareHash', $hash);
$this->initialState->provideInitialState('maxStringLengths', Constants::MAX_STRING_LENGTHS);
return $this->provideTemplate(self::TEMPLATE_MAIN, $form);
}
// Otherwise Redirect to login (& then internal view)
return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', ['redirect_url' => $internalView]));
}

Просмотреть файл

@ -98,10 +98,7 @@ class Form extends Entity {
$accessEnum = $this->getAccessEnum();
$access = [];
if ($accessEnum >= Constants::FORM_ACCESS_LEGACYLINK) {
$access['legacyLink'] = true;
}
switch ($accessEnum % Constants::FORM_ACCESS_LEGACYLINK) {
switch ($accessEnum) {
case Constants::FORM_ACCESS_NOPUBLICSHARE:
$access['permitAllUsers'] = false;
$access['showToAllUsers'] = false;
@ -135,11 +132,6 @@ class Form extends Entity {
$value = Constants::FORM_ACCESS_PERMITALLUSERS;
}
// If legacyLink add 3
if (isset($access['legacyLink']) && $access['legacyLink']) {
$value += Constants::FORM_ACCESS_LEGACYLINK;
}
$this->setAccessEnum($value);
}

Просмотреть файл

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Forms\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version050000Date20241005173955 extends SimpleMigrationStep {
public function __construct(
protected IDBConnection $db,
) {
}
/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$qbUpdate = $this->db->getQueryBuilder();
$qbUpdate->update('forms_v2_forms')
->set('access_enum', 'access_enum - 3')
->where($qbUpdate->expr()->gte('access_enum', '3'))
->executeStatement();
}
}

Просмотреть файл

@ -357,7 +357,7 @@ class FormsService {
* @return boolean
*/
public function canSubmit(Form $form): bool {
// We cannot control how many time users can submit if public link / legacyLink available
// We cannot control how many time users can submit if public link available
if ($this->hasPublicLink($form)) {
return true;
}
@ -387,10 +387,6 @@ class FormsService {
private function hasPublicLink(Form $form): bool {
$access = $form->getAccess();
if (isset($access['legacyLink'])) {
return true;
}
$shareEntities = $this->shareMapper->findByForm($form->getId());
foreach ($shareEntities as $shareEntity) {
if ($shareEntity->getShareType() === IShare::TYPE_LINK) {

Просмотреть файл

@ -208,11 +208,7 @@ export default {
* Submit Multiple is disabled, if it cannot be controlled.
*/
disableSubmitMultiple() {
return (
this.hasPublicLink ||
this.form.access.legacyLink ||
this.form.isAnonymous
)
return this.hasPublicLink || this.form.isAnonymous
},
disableSubmitMultipleExplanation() {
if (this.disableSubmitMultiple) {

Просмотреть файл

@ -115,37 +115,6 @@
:text="qrDialogText"
@closed="qrDialogText = ''" />
<!-- Legacy Info, if present -->
<div v-if="form.access.legacyLink" class="share-div">
<div class="share-div__avatar">
<IconLinkVariant :size="20" />
</div>
<div class="share-div__desc share-div__desc--twoline">
<span>{{ t('forms', 'Legacy Link') }}</span>
<span>{{
t('forms', 'Form still supports old sharing-link.')
}}</span>
</div>
<div
v-tooltip="
t(
'forms',
'For compatibility with the old Sharing, the internal link is still usable as Share link. Please replace the link with a new Share link. The internal sharing link will not work anymore starting with Forms 5.0',
)
"
class="share-div__legacy-warning">
<IconAlertCircleOutline :size="20" />
</div>
<NcActions>
<NcActionButton @click="removeLegacyLink">
<template #icon>
<IconDelete :size="20" />
</template>
{{ t('forms', 'Remove Legacy Link') }}
</NcActionButton>
</NcActions>
</div>
<!-- Internal link -->
<div class="share-div">
<div class="share-div__avatar">
@ -229,7 +198,6 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import IconAccountMultiple from 'vue-material-design-icons/AccountMultiple.vue'
import IconAlertCircleOutline from 'vue-material-design-icons/AlertCircleOutline.vue'
import IconCodeBrackets from 'vue-material-design-icons/CodeBrackets.vue'
import IconDelete from 'vue-material-design-icons/Delete.vue'
import IconLinkBoxVariantOutline from 'vue-material-design-icons/LinkBoxVariantOutline.vue'
@ -252,7 +220,6 @@ export default {
components: {
FormsIcon,
IconAccountMultiple,
IconAlertCircleOutline,
IconCodeBrackets,
IconCopyAll,
IconDelete,
@ -469,11 +436,6 @@ export default {
newAccess.showToAllUsers = newVal
this.$emit('update:formProp', 'access', newAccess)
},
removeLegacyLink() {
const newAccess = { ...this.form.access }
delete newAccess.legacyLink
this.$emit('update:formProp', 'access', newAccess)
},
openQrDialog(share) {
this.qrDialogText = this.getPublicShareLink(share)
@ -535,11 +497,5 @@ export default {
}
}
}
&__legacy-warning {
background-size: 18px;
margin-inline-end: 4px;
color: var(--color-error);
}
}
</style>

Просмотреть файл

@ -104,19 +104,6 @@
<p v-if="infoMessage" class="info-message">
{{ infoMessage }}
</p>
<!-- TODO: remove with Forms 5.0
Show info about legacyLink that will be removed -->
<NcNoteCard
v-if="form.access.legacyLink"
type="warning"
:heading="t('forms', 'Legacy link in use')">
{{
t(
'forms',
'This form still uses a deprecated share link, that will be removed in Forms 5.0. Please use the new sharing mechanism.',
)
}}
</NcNoteCard>
</header>
<section>

Просмотреть файл

@ -63,19 +63,6 @@
<p v-if="infoMessage" class="info-message">
{{ infoMessage }}
</p>
<!-- TODO: remove with Forms 5.0
Show info about legacyLink that will be removed -->
<NcNoteCard
v-if="form.access?.legacyLink"
type="warning"
:heading="t('forms', 'Legacy link in use')">
{{
t(
'forms',
'This form still uses a deprecated share link, that will be removed in Forms 5.0. Please use the new sharing mechanism.',
)
}}
</NcNoteCard>
</header>
<NcEmptyContent