Skip to content

Commit

Permalink
✨ Support for _parent and _top targets (gchq#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Oct 22, 2021
1 parent 9316748 commit 4b98e05
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/components/LinkItems/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 4b98e05

Please sign in to comment.