From 8d6fb09ff9fcf3ebf275db19c2cc8bf769b02186 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Fri, 3 Jan 2020 10:33:10 +0100 Subject: [PATCH 1/2] [APM] Delay rendering invalid license notification Don't render an invalid license notification if the license information has not been loaded. (Don't render any UI either). --- .../plugins/apm/public/context/LicenseContext/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx b/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx index 8cdb7f050027d..b366c3d916fcd 100644 --- a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx +++ b/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx @@ -19,6 +19,10 @@ export function LicenseProvider({ children }: { children: React.ReactChild }) { const license = useObservable(license$); const hasInvalidLicense = !license?.isActive; + if (!license) { + return null; + } + // if license is invalid show an error message if (hasInvalidLicense) { return ; From 9505d3f529b6df68a07c1be1ec8de715d2259b98 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Thu, 9 Jan 2020 22:23:26 +0100 Subject: [PATCH 2/2] Show UI if license has not loaded --- .../plugins/apm/public/context/LicenseContext/index.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx b/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx index b366c3d916fcd..0bd3896782603 100644 --- a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx +++ b/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx @@ -16,12 +16,8 @@ export const LicenseContext = React.createContext( export function LicenseProvider({ children }: { children: React.ReactChild }) { const { license$ } = useApmPluginContext().plugins.licensing; - const license = useObservable(license$); - const hasInvalidLicense = !license?.isActive; - - if (!license) { - return null; - } + const license = useObservable(license$, { isActive: true } as ILicense); + const hasInvalidLicense = !license.isActive; // if license is invalid show an error message if (hasInvalidLicense) {