Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/LinkItems/SubItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import Icon from '@/components/LinkItems/ItemIcon.vue';
import ContextMenu from '@/components/LinkItems/ItemContextMenu';
import ItemMixin from '@/mixins/ItemMixin';
// import { targetValidator } from '@/utils/ConfigHelpers';

export default {
name: 'Item',
Expand Down
3 changes: 2 additions & 1 deletion src/components/PageStrcture/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export default {
switch (link.target) {
case 'sametab': return '_self';
case 'newtab': return '_blank';
case 'newwindow': return '_blank';
case 'parent': return '_parent';
case 'top': return '_top';
default: return undefined;
default: return '_blank';
}
},
},
Expand Down
16 changes: 14 additions & 2 deletions src/mixins/ItemMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export default {
} else if (this.accumulatedTarget === 'clipboard') {
e.preventDefault();
this.copyToClipboard(url);
} else if (this.accumulatedTarget === 'newwindow') {
e.preventDefault();
const { width, height } = window.screen;
window.open(url, '_blank', `width=${width},height=${height},noopener,noreferrer`);
}
// Emit event to clear search field, etc
this.$emit('itemClicked');
Expand All @@ -172,6 +176,12 @@ export default {
case 'sametab':
window.open(url, '_self');
break;
case 'parent':
window.open(url, '_parent');
break;
case 'top':
window.open(url, '_top');
break;
case 'modal':
this.$emit('triggerModal', url);
break;
Expand All @@ -181,9 +191,11 @@ export default {
case 'clipboard':
this.copyToClipboard(url);
break;
case 'newwindow':
window.open(url, '_blank', 'noopener,noreferrer');
case 'newwindow': {
const { width, height } = window.screen;
window.open(url, '_blank', `width=${width},height=${height},noopener,noreferrer`);
break;
}
default: window.open(url, '_blank');
}
},
Expand Down
17 changes: 0 additions & 17 deletions src/utils/ConfigHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
localStorageKeys,
language as defaultLanguage,
} from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';
import ConfigSchema from '@/utils/ConfigSchema.json';

/* Given a page name, converts to lowercase, removes special characters and extension */
export const makePageName = (pageName) => {
Expand Down Expand Up @@ -101,18 +99,3 @@ export const getUsersLanguage = () => {
const langObj = languages.find(lang => lang.code === resolvedCode);
return langObj;
};

/**
* validator for item target attribute
* Uses enum values from config schema, and shows warning if invalid
* @param {String} target
* @returns {Boolean} isValid
*/
export const targetValidator = (target) => {
if (!target) return true;
const acceptedTargets = ConfigSchema.properties.sections.items
.properties.items.items.properties.target.enum;
const isTargetValid = acceptedTargets.indexOf(target) !== -1;
if (!isTargetValid) ErrorHandler(`Unknown target value: ${target}`);
return isTargetValid;
};
16 changes: 6 additions & 10 deletions src/utils/ConfigSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@
},
"target": {
"title": "Opening Method",
"type": ["string", "null"],
"type": "string",
"enum": [
"newtab",
"sametab",
"parent",
"top",
"newwindow",
"",
null
"newwindow"
],
"default": "newtab",
"description": "Where / how the item is opened when it's clicked"
Expand Down Expand Up @@ -207,7 +205,8 @@
"top",
"modal",
"workspace",
"clipboard"
"clipboard",
"newwindow"
],
"default": "newtab",
"description": "The default opening method for items. Only used if no item.target is specified"
Expand Down Expand Up @@ -394,7 +393,6 @@
"enum": [
"newtab",
"sametab",
"modal",
"workspace"
],
"default": "newtab",
Expand Down Expand Up @@ -1067,7 +1065,7 @@
},
"target": {
"title": "Opening Method",
"type": ["string", "null"],
"type": "string",
"enum": [
"newtab",
"sametab",
Expand All @@ -1076,9 +1074,7 @@
"modal",
"workspace",
"clipboard",
"newwindow",
"",
null
"newwindow"
],
"default": "newtab",
"description": "Where / how the item is opened when it's clicked"
Expand Down
5 changes: 4 additions & 1 deletion src/views/Workspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import WebContent from '@/components/Workspace/WebContent';
import WidgetView from '@/components/Workspace/WidgetView';
import MultiTaskingWebComtent from '@/components/Workspace/MultiTaskingWebComtent';
import Defaults from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';

export default {
name: 'Workspace',
Expand Down Expand Up @@ -49,12 +50,14 @@ export default {
if (options.target === 'newtab') {
window.open(options.url, '_blank');
} else if (options.target === 'newwindow') {
window.open(options.url, '_blank', 'noopener,noreferrer');
const { width, height } = window.screen;
window.open(options.url, '_blank', `width=${width},height=${height},noopener,noreferrer`);
} else if (options.target === 'clipboard') {
if (navigator.clipboard) {
navigator.clipboard.writeText(options.url);
this.$toasted.show(this.$t('context-menus.item.copied-toast'), { className: 'toast-success' });
} else {
ErrorHandler('Clipboard access requires HTTPS. See: https://bit.ly/3N5WuAA');
this.$toasted.show('Unable to copy, see log', { className: 'toast-error' });
}
return;
Expand Down
Loading