See description.
This issue created for D8.

Copy/paste from D7 issue:
The following patch allows to check if the currently logged user can access a path before outputting it (from a field). This allows to add custom "Edit" or "Delete" links in tables without having to use php.

Comments

m.lebedev created an issue. See original summary.

m.lebedev’s picture

Status: Active » Needs review
StatusFileSize
new1.63 KB

There is returning $text in the patch because it is default behavior if url is incorrect. It will not be useful for all cases; so I think need adding additional option "Hide if no access".

m.lebedev’s picture

joachim’s picture

Category: Task » Bug report
Issue tags: +Needs issue summary update
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -769,6 +770,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+        '#title' => $this->t('Check access'),

This needs more UI text. What will happen if I select this option and the user has no access -- is the field shown as just text without a link, or is it completely hidden?

Status: Needs review » Needs work

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

kunalgautam’s picture

Assigned: Unassigned » kunalgautam
kunalgautam’s picture

kunalgautam’s picture

Assigned: kunalgautam » Unassigned
Status: Needs work » Needs review
ankitsingh0188’s picture

Issue tags: +Needs tests

Patch applied and looks good to me. Tests cases failed, updated the ticket tag accordingly.

ankitsingh0188’s picture

Status: Needs review » Needs work

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

akalam’s picture

Tested on 8.9 works fine.

kunalgautam’s picture

Assigned: Unassigned » kunalgautam
kunalgautam’s picture

StatusFileSize
new690.08 KB

Patch #8 is applied successfully for Drupal 8.9.1 and working fine. Need to update Test cases.

Drupal 8.9.1

kunalgautam’s picture

Assigned: kunalgautam » Unassigned

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lendude’s picture

Title: Views. Add access check when using "Output this field as a link" » Add access check when using "Output this field as a link"
Category: Bug report » Feature request
Issue summary: View changes

This is a feature request in D7 and seems like a feature request for D8 also.

Since we are adding a new setting, we would also need an upgrade path for this.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.