Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:sparkles: Support for _parent and _top targets (#289)

Alicia Sykes4b98e05f756e
diff --git a/src/components/LinkItems/Item.vue b/src/components/LinkItems/Item.vue
index cc89198e..25896334 100644
--- a/src/components/LinkItems/Item.vue
+++ b/src/components/LinkItems/Item.vue
@@ -3,8 +3,8 @@
<a @click="itemOpened"
@mouseup.right="openContextMenu"
@contextmenu.prevent
- :href="(target !== 'modal' && target !== 'workspace') ? url : '#'"
- :target="target === 'newtab' ? '_blank' : ''"
+ :href="targetHref"
+ :target="anchorTarget"
:class="`item ${!icon? 'short': ''} size-${itemSize}`"
v-tooltip="getTooltipOptions()"
rel="noopener noreferrer" tabindex="0"
@@ -50,6 +50,7 @@ import ItemOpenMethodIcon from '@/components/LinkItems/ItemOpenMethodIcon';
import StatusIndicator from '@/components/LinkItems/StatusIndicator';
import ContextMenu from '@/components/LinkItems/ContextMenu';
import { localStorageKeys, serviceEndpoints } from '@/utils/defaults';
+import { targetValidator } from '@/utils/ConfigHelpers';
export default {
name: 'Item',
@@ -66,8 +67,7 @@ export default {
hotkey: Number, // Shortcut for quickly launching app
target: { // Where resource will open, either 'newtab', 'sametab' or 'modal'
type: String,
- default: 'newtab',
- validator: (value) => ['newtab', 'sametab', 'modal', 'workspace'].indexOf(value) !== -1,
+ validator: targetValidator,
},
itemSize: String,
enableStatusCheck: Boolean,
@@ -80,6 +80,21 @@ export default {
appConfig() {
return this.$store.getters.appConfig;
},
+ /* Convert config target value, into HTML anchor target attribute */
+ anchorTarget() {
+ switch (this.target) {
+ case 'sametab': return '_self';
+ case 'newtab': return '_blank';
+ case 'parent': return '_parent';
+ case 'top': return '_top';
+ default: return undefined;
+ }
+ },
+ /* Get the href value for the anchor, if not opening in modal/ workspace */
+ targetHref() {
+ const noAnchorNeeded = ['modal', 'workspace'];
+ return noAnchorNeeded.includes(this.target) ? '#' : this.url;
+ },
},
data() {
return {