Skip to content
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

[NP] Cutover ensureDefaultIndexPattern to kibana_utils #59895

Merged
merged 16 commits into from
Mar 18, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Proper name for argument
sulemanof committed Mar 18, 2020
commit a06df267c1e20bb0040417ff6497899847dcf33f
Original file line number Diff line number Diff line change
@@ -38,17 +38,17 @@ let timeoutId: NodeJS.Timeout | undefined;
* resolve to wait for the URL change to happen.
*/
export async function ensureDefaultIndexPattern(
newPlatform: CoreStart,
core: CoreStart,
data: DataPublicPluginStart,
history: History
) {
const patterns = await data.indexPatterns.getIds();
let defaultId = newPlatform.uiSettings.get('defaultIndex');
let defaultId = core.uiSettings.get('defaultIndex');
let defined = !!defaultId;
const exists = contains(patterns, defaultId);

if (defined && !exists) {
newPlatform.uiSettings.remove('defaultIndex');
core.uiSettings.remove('defaultIndex');
defaultId = defined = false;
}

@@ -59,10 +59,9 @@ export async function ensureDefaultIndexPattern(
// If there is any index pattern created, set the first as default
if (patterns.length >= 1) {
defaultId = patterns[0];
newPlatform.uiSettings.set('defaultIndex', defaultId);
core.uiSettings.set('defaultIndex', defaultId);
} else {
const canManageIndexPatterns =
newPlatform.application.capabilities.management.kibana.index_patterns;
const canManageIndexPatterns = core.application.capabilities.management.kibana.index_patterns;
const redirectTarget = canManageIndexPatterns ? '/management/kibana/index_pattern' : '/home';

if (timeoutId) {
@@ -71,7 +70,7 @@ export async function ensureDefaultIndexPattern(

// Avoid being hostile to new users who don't have an index pattern setup yet
// give them a friendly info message instead of a terse error message
bannerId = newPlatform.overlays.banners.replace(
bannerId = core.overlays.banners.replace(
bannerId,
toMountPoint(
<EuiCallOut
@@ -87,7 +86,7 @@ export async function ensureDefaultIndexPattern(

// hide the message after the user has had a chance to acknowledge it -- so it doesn't permanently stick around
timeoutId = setTimeout(() => {
newPlatform.overlays.banners.remove(bannerId);
core.overlays.banners.remove(bannerId);
timeoutId = undefined;
}, 15000);