-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix Navigation Url when external link - MEED-7881 - Meeds-io/mee…
…ds#2622 (#4215) Prior to this change, the external link behavior wasn't the same switch Navigation Node display mode: - Desktop Menu Item - Desktop Menu Sub item (displayed in Second or Third Level) - Mobile Menu Item - Mobile Menu Sub item (displayed in Second or Third Level) Thus, when clicking on external link in Mobile, the behavior is just to open the URL as it was a current page URL. This change will introduce the usage of **AutoLink** API in order to ensure the URL behavior consistency comparing to provided link by the user. In addition, when a Dash is used in user provided URL, the behavior has been improved to always open the URL and not let the builtin behavior occurs, which will not change to the opened page.
- Loading branch information
Showing
6 changed files
with
153 additions
and
83 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
webapp/src/main/webapp/vue-apps/common/js/NavigationUtils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
export function getNavigationNodeUri(baseSiteUri, navigation) { | ||
const hasPage = !!navigation?.pageKey; | ||
const pageUrl = hasPage && `${baseSiteUri}${navigation.uri}`; | ||
const pageLink = navigation?.pageLink && Autolinker.parse(navigation?.pageLink, { | ||
email: true, | ||
})?.[0]?.getUrl?.() || navigation?.pageLink; | ||
navigation.nodeUri = pageLink || pageUrl; | ||
return navigation.nodeUri; | ||
} | ||
|
||
export function getNavigationNodeTarget(navigation) { | ||
navigation.nodeTarget = navigation?.target === 'SAME_TAB' && '_self' || '_blank'; | ||
return navigation.nodeTarget; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.