openfin-adapter
Advanced tools
Comparing version 18.56.5 to 18.56.6
{ | ||
"name": "openfin-adapter", | ||
"version": "18.56.5", | ||
"version": "18.56.6", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./src/main.js", |
import LayoutPresetTypes from '../../../shapes/LayoutPresetTypes'; | ||
import type { ViewCreationOptions } from '../../view'; | ||
export interface InitLayoutOptions { | ||
@@ -8,1 +9,5 @@ containerId?: string; | ||
} | ||
export interface DragPayload { | ||
'view-config': ViewCreationOptions; | ||
'view-identity': [string, string, string]; | ||
} |
@@ -46,7 +46,7 @@ "use strict"; | ||
const { isSameApp, isSameWindow } = utils_1.compareIdentities(sourceIdentity, this.ofWindow.identity); | ||
if (!isSameApp || !(settings === null || settings === void 0 ? void 0 : settings.reorderEnabled)) { | ||
if ((!isSameApp || !(settings === null || settings === void 0 ? void 0 : settings.reorderEnabled)) && !utils_1.isLaunchByDrag(originalEvent)) { | ||
originalEvent.dataTransfer.dropEffect = 'none'; | ||
return true; | ||
} | ||
const notAllowedDragIn = (sourceSettings === null || sourceSettings === void 0 ? void 0 : sourceSettings.preventDragOut) || settings.preventDragIn; | ||
const notAllowedDragIn = (sourceSettings === null || sourceSettings === void 0 ? void 0 : sourceSettings.preventDragOut) || (settings === null || settings === void 0 ? void 0 : settings.preventDragIn); | ||
if (isSameWindow || notAllowedDragIn) { | ||
@@ -81,2 +81,5 @@ if (!isSameWindow) { | ||
this.dragProxy = null; | ||
// when performing a manifest launch by drag, there is no source window | ||
if (!sourceIdentity) | ||
return; | ||
const originWindow = fin.Window.wrapSync({ | ||
@@ -98,2 +101,3 @@ uuid: this.ofWindow.identity.uuid, | ||
.bind('drop', (ev) => { | ||
const { originalEvent } = ev; | ||
const winIdentity = this.ofWindow.identity; | ||
@@ -103,4 +107,6 @@ const { settings } = this.layout.toConfig(); | ||
const { isSameApp, isSameWindow } = utils_1.compareIdentities(sourceIdentity, this.ofWindow.identity); | ||
const isLaunchDrag = utils_1.isLaunchByDrag(originalEvent); | ||
const notAllowedDragIn = (sourceSettings === null || sourceSettings === void 0 ? void 0 : sourceSettings.preventDragOut) || (settings === null || settings === void 0 ? void 0 : settings.preventDragIn); | ||
if (!isSameApp || isSameWindow || !(settings === null || settings === void 0 ? void 0 : settings.reorderEnabled) || notAllowedDragIn) { | ||
const shouldIgnoreDrop = (!isSameApp || isSameWindow || !(settings === null || settings === void 0 ? void 0 : settings.reorderEnabled) || notAllowedDragIn) && !isLaunchDrag; | ||
if (shouldIgnoreDrop) { | ||
if (this.dragProxy) { | ||
@@ -116,5 +122,12 @@ this.dragProxy._contentItem._$destroy(); | ||
} | ||
// This data placed on the drag event in the golden layouts code | ||
const identityArr = JSON.parse(ev.originalEvent.dataTransfer.getData('view-identity')); | ||
const viewConfig = JSON.parse(identityArr[0]); | ||
let viewConfig; | ||
if (isLaunchDrag) { | ||
viewConfig = utils_1.getViewConfigFromDrag(originalEvent); | ||
viewConfig.name = utils_1.generateViewNameIfNeeded(viewConfig.name, false); | ||
} | ||
else { | ||
// This data placed on the drag event in the golden layouts code | ||
const identityArr = JSON.parse(ev.originalEvent.dataTransfer.getData('view-identity')); | ||
viewConfig = JSON.parse(identityArr[0]); | ||
} | ||
const createdComponent = this.getViewComponent({ name: 'internal-usage-to-be-replaced' }); | ||
@@ -130,7 +143,11 @@ createdComponent.componentState = viewConfig; | ||
utils_1.emitLocalEvent('tab-created', viewIdentity, this.container); | ||
setTimeout(() => { | ||
setTimeout(async () => { | ||
this.isDragging = false; | ||
this.hideHighlight(); | ||
this.showViews(); | ||
this.platform.reparentView({ uuid: winIdentity.uuid, name: viewConfig.name }, winIdentity); | ||
if (!isLaunchDrag) { | ||
const view = await fin.View.wrap(viewIdentity); | ||
viewConfig = await view.getOptions(); | ||
} | ||
this.platform.createView(viewConfig, winIdentity); | ||
}, 1); | ||
@@ -307,3 +324,3 @@ ev.stopPropagation(); | ||
} | ||
return ofView.show(); | ||
return ofView.show().catch((e) => e); // view might not exist yet/anymore, this is ok | ||
}; | ||
@@ -574,2 +591,7 @@ this.onStackCreated = (stack) => { | ||
if (existingComponent) { | ||
// in certain cases (i.e. creation by drag), config from the provider will have the full state | ||
// whereas the current one will be incomplete | ||
existingComponent.componentState = viewConfig; | ||
existingComponent.container.setState(viewConfig); | ||
this.updateButtonDisplay(); | ||
return this.createAndAttachView(existingComponent); | ||
@@ -576,0 +598,0 @@ } |
@@ -142,3 +142,2 @@ "use strict"; | ||
const CHILD_WINDOW_NAME_PREFIX = 'internal-generated-window-'; | ||
const VIEW_NAME_PREFIX = 'internal-generated-view-'; | ||
const STANDARD_FRAME_PATH = 'standard-frame'; | ||
@@ -197,12 +196,6 @@ const uniqueMergeValidArraysInOrder = (arr1, arr2) => [ | ||
function modifyContentItemName(contentItem, shouldReplace) { | ||
const name = generateViewNameIfNeeded(contentItem.componentState.name, shouldReplace); | ||
const name = utils_1.generateViewNameIfNeeded(contentItem.componentState.name, shouldReplace); | ||
const newComponentState = { ...contentItem.componentState, name }; | ||
return { ...contentItem, componentState: newComponentState }; | ||
} | ||
function generateViewNameIfNeeded(name, shouldReplace) { | ||
// either the view has no name OR it is being restored and has a generated name | ||
return !name || (shouldReplace && name.startsWith(VIEW_NAME_PREFIX)) | ||
? VIEW_NAME_PREFIX + fin.desktop.getUuid() | ||
: name; | ||
} | ||
function mapLayoutContentItems(contentItems, action) { | ||
@@ -645,3 +638,3 @@ return contentItems.reduce(async (res, contentItem) => { | ||
const { opts, target } = payload; | ||
opts.name = generateViewNameIfNeeded(opts.name, false); | ||
opts.name = utils_1.generateViewNameIfNeeded(opts.name, false); | ||
const { uuid } = fin.me.identity; | ||
@@ -648,0 +641,0 @@ const convertedOpts = await convertViewOptions(opts); |
@@ -74,2 +74,5 @@ /// <reference types="jquery" /> | ||
export declare const getMaximizedContentItem: (layout: GoldenLayout.GoldenLayout) => GoldenLayout.ContentItem | null; | ||
export declare const isLaunchByDrag: (originalEvent: DragEvent | undefined) => boolean; | ||
export declare const getViewConfigFromDrag: (originalEvent: DragEvent | undefined) => any; | ||
export declare const generateViewNameIfNeeded: (name: string, shouldReplace: boolean) => string; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getMaximizedContentItem = exports.unmaximizeLayout = exports.isLayoutMaximized = exports.detachOrCloseView = exports.showCloseButtonsIfClosable = exports.getOutOfBoundsWindows = exports.promisifyViewLoadEvents = exports.buildFailedEventPayload = exports.getComponentBounds = exports.updateViewState = exports.setViewBoundsByRect = exports.setFallbackBodyAndTitle = exports.setTabTitle = exports.getContainerMessage = exports.setContainerMessage = exports.mock = exports.compareIdentities = exports.getOutOfWindowDropBounds = exports.handleRenderError = exports.getDragPayload = exports.generateLayoutContent = exports.delay = exports.debounce = exports.createComponent = exports.generatePresetLayoutContent = exports.getPresetLayoutFunction = exports.generateTabsPreset = exports.emitLocalEvent = exports.addComponentToContentItem = void 0; | ||
exports.generateViewNameIfNeeded = exports.getViewConfigFromDrag = exports.isLaunchByDrag = exports.getMaximizedContentItem = exports.unmaximizeLayout = exports.isLayoutMaximized = exports.detachOrCloseView = exports.showCloseButtonsIfClosable = exports.getOutOfBoundsWindows = exports.promisifyViewLoadEvents = exports.buildFailedEventPayload = exports.getComponentBounds = exports.updateViewState = exports.setViewBoundsByRect = exports.setFallbackBodyAndTitle = exports.setTabTitle = exports.getContainerMessage = exports.setContainerMessage = exports.mock = exports.compareIdentities = exports.getOutOfWindowDropBounds = exports.handleRenderError = exports.getDragPayload = exports.generateLayoutContent = exports.delay = exports.debounce = exports.createComponent = exports.generatePresetLayoutContent = exports.getPresetLayoutFunction = exports.generateTabsPreset = exports.emitLocalEvent = exports.addComponentToContentItem = void 0; | ||
/* global CustomEvent getComputedStyle */ | ||
@@ -405,1 +405,16 @@ const base32 = require("hi-base32"); | ||
}; | ||
exports.isLaunchByDrag = (originalEvent) => { | ||
var _a; | ||
return !!((_a = originalEvent === null || originalEvent === void 0 ? void 0 : originalEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.some((dataType) => dataType === 'view-config')); | ||
}; | ||
exports.getViewConfigFromDrag = (originalEvent) => { | ||
var _a, _b; | ||
return JSON.parse((_b = (_a = originalEvent === null || originalEvent === void 0 ? void 0 : originalEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('view-config')) !== null && _b !== void 0 ? _b : '{}'); | ||
}; | ||
const VIEW_NAME_PREFIX = 'internal-generated-view-'; | ||
exports.generateViewNameIfNeeded = (name, shouldReplace) => { | ||
// either the view has no name OR it is being restored and has a generated name | ||
return !name || (shouldReplace && name.startsWith(VIEW_NAME_PREFIX)) | ||
? VIEW_NAME_PREFIX + fin.desktop.getUuid() | ||
: name; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3981579
18088