-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Graph] Shim plugin #47469
[Graph] Shim plugin #47469
Changes from 16 commits
7ba504f
eea0131
9f1c141
cf06de8
d06721a
0b2c0c0
adc67ce
ec9fbf1
b058df6
1946b6b
21d173c
b130290
9276ba5
c6f5e7b
4eee3cd
4776eb1
976d51f
c816050
d3c5a3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import { TopNavMenu } from '../../../core_plugins/kibana_react/public'; | |
|
||
const module = uiModules.get('kibana'); | ||
|
||
module.directive('kbnTopNav', () => { | ||
export function createTopNavDirective() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exporting the directive definition as a module export to be able to put it in a separate angular module with a different name. This is done to use existing code like this one but make sure it's not using any dependencies from the global angular instance |
||
return { | ||
restrict: 'E', | ||
template: '', | ||
|
@@ -71,9 +71,11 @@ module.directive('kbnTopNav', () => { | |
return linkFn; | ||
} | ||
}; | ||
}); | ||
} | ||
|
||
module.directive('kbnTopNavHelper', (reactDirective) => { | ||
module.directive('kbnTopNav', createTopNavDirective); | ||
|
||
export function createTopNavHelper(reactDirective) { | ||
return reactDirective( | ||
wrapInI18nContext(TopNavMenu), | ||
[ | ||
|
@@ -113,4 +115,6 @@ module.directive('kbnTopNavHelper', (reactDirective) => { | |
'showAutoRefreshOnly', | ||
], | ||
); | ||
}); | ||
} | ||
|
||
module.directive('kbnTopNavHelper', createTopNavHelper); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,14 +287,12 @@ const $setupHelpExtensionAutoClear = (newPlatform: CoreStart) => ( | |
|
||
const $setupUrlOverflowHandling = (newPlatform: CoreStart) => ( | ||
$location: ILocationService, | ||
$rootScope: IRootScopeService, | ||
Private: any, | ||
config: any | ||
$rootScope: IRootScopeService | ||
) => { | ||
const urlOverflow = new UrlOverflowService(); | ||
const check = () => { | ||
// disable long url checks when storing state in session storage | ||
if (config.get('state:storeInSessionStorage')) { | ||
if (newPlatform.uiSettings.get('state:storeInSessionStorage')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use config in here to avoid having to initialize it. |
||
return; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,98 +108,100 @@ function name(fn) { | |
return fn.name || fn.toString().split('\n').shift(); | ||
} | ||
|
||
uiModules.get('kibana/private') | ||
.provider('Private', function () { | ||
const provider = this; | ||
|
||
// one cache/swaps per Provider | ||
const cache = {}; | ||
const swaps = {}; | ||
export function PrivateProvider() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as for the top nav directive. Private isn't used in this PR but it will become necessary for shimming discover and others in the same style |
||
const provider = this; | ||
|
||
// return the uniq id for this function | ||
function identify(fn) { | ||
if (typeof fn !== 'function') { | ||
throw new TypeError('Expected private module "' + fn + '" to be a function'); | ||
} | ||
// one cache/swaps per Provider | ||
const cache = {}; | ||
const swaps = {}; | ||
|
||
if (fn.$$id) return fn.$$id; | ||
else return (fn.$$id = nextId()); | ||
// return the uniq id for this function | ||
function identify(fn) { | ||
if (typeof fn !== 'function') { | ||
throw new TypeError('Expected private module "' + fn + '" to be a function'); | ||
} | ||
|
||
provider.stub = function (fn, instance) { | ||
cache[identify(fn)] = instance; | ||
return instance; | ||
}; | ||
if (fn.$$id) return fn.$$id; | ||
else return (fn.$$id = nextId()); | ||
} | ||
|
||
provider.swap = function (fn, prov) { | ||
const id = identify(fn); | ||
swaps[id] = prov; | ||
}; | ||
provider.stub = function (fn, instance) { | ||
cache[identify(fn)] = instance; | ||
return instance; | ||
}; | ||
|
||
provider.$get = ['$injector', function PrivateFactory($injector) { | ||
provider.swap = function (fn, prov) { | ||
const id = identify(fn); | ||
swaps[id] = prov; | ||
}; | ||
|
||
// prevent circular deps by tracking where we came from | ||
const privPath = []; | ||
const pathToString = function () { | ||
return privPath.map(name).join(' -> '); | ||
}; | ||
provider.$get = ['$injector', function PrivateFactory($injector) { | ||
|
||
// call a private provider and return the instance it creates | ||
function instantiate(prov, locals) { | ||
if (~privPath.indexOf(prov)) { | ||
throw new Error( | ||
'Circular reference to "' + name(prov) + '"' + | ||
' found while resolving private deps: ' + pathToString() | ||
); | ||
} | ||
// prevent circular deps by tracking where we came from | ||
const privPath = []; | ||
const pathToString = function () { | ||
return privPath.map(name).join(' -> '); | ||
}; | ||
|
||
privPath.push(prov); | ||
// call a private provider and return the instance it creates | ||
function instantiate(prov, locals) { | ||
if (~privPath.indexOf(prov)) { | ||
throw new Error( | ||
'Circular reference to "' + name(prov) + '"' + | ||
' found while resolving private deps: ' + pathToString() | ||
); | ||
} | ||
|
||
const context = {}; | ||
let instance = $injector.invoke(prov, context, locals); | ||
if (!_.isObject(instance)) instance = context; | ||
privPath.push(prov); | ||
|
||
privPath.pop(); | ||
return instance; | ||
} | ||
const context = {}; | ||
let instance = $injector.invoke(prov, context, locals); | ||
if (!_.isObject(instance)) instance = context; | ||
|
||
// retrieve an instance from cache or create and store on | ||
function get(id, prov, $delegateId, $delegateProv) { | ||
if (cache[id]) return cache[id]; | ||
privPath.pop(); | ||
return instance; | ||
} | ||
|
||
let instance; | ||
// retrieve an instance from cache or create and store on | ||
function get(id, prov, $delegateId, $delegateProv) { | ||
if (cache[id]) return cache[id]; | ||
|
||
if ($delegateId != null && $delegateProv != null) { | ||
instance = instantiate(prov, { | ||
$decorate: _.partial(get, $delegateId, $delegateProv) | ||
}); | ||
} else { | ||
instance = instantiate(prov); | ||
} | ||
let instance; | ||
|
||
return (cache[id] = instance); | ||
if ($delegateId != null && $delegateProv != null) { | ||
instance = instantiate(prov, { | ||
$decorate: _.partial(get, $delegateId, $delegateProv) | ||
}); | ||
} else { | ||
instance = instantiate(prov); | ||
} | ||
|
||
// main api, get the appropriate instance for a provider | ||
function Private(prov) { | ||
let id = identify(prov); | ||
let $delegateId; | ||
let $delegateProv; | ||
return (cache[id] = instance); | ||
} | ||
|
||
if (swaps[id]) { | ||
$delegateId = id; | ||
$delegateProv = prov; | ||
// main api, get the appropriate instance for a provider | ||
function Private(prov) { | ||
let id = identify(prov); | ||
let $delegateId; | ||
let $delegateProv; | ||
|
||
prov = swaps[$delegateId]; | ||
id = identify(prov); | ||
} | ||
if (swaps[id]) { | ||
$delegateId = id; | ||
$delegateProv = prov; | ||
|
||
return get(id, prov, $delegateId, $delegateProv); | ||
prov = swaps[$delegateId]; | ||
id = identify(prov); | ||
} | ||
|
||
Private.stub = provider.stub; | ||
Private.swap = provider.swap; | ||
return get(id, prov, $delegateId, $delegateProv); | ||
} | ||
|
||
Private.stub = provider.stub; | ||
Private.swap = provider.swap; | ||
|
||
return Private; | ||
}]; | ||
} | ||
|
||
return Private; | ||
}]; | ||
}); | ||
uiModules.get('kibana/private') | ||
.provider('Private', PrivateProvider); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to support dynamic imports via
await import(...