Skip to content

Commit

Permalink
adding access denied page
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Dec 2, 2019
1 parent 320f38e commit 96bcd72
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import uiRoutes from 'ui/routes';
import { I18nContext } from 'ui/i18n';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { AccessDeniedPage } from './page';

const module = uiModules.get('apps/ml', ['react']);

const template = `<access-denied />`;

uiRoutes.when('/access-denied', {
template,
});

module.directive('accessDenied', function() {
return {
scope: {},
restrict: 'E',
link: async (scope: ng.IScope, element: ng.IAugmentedJQuery) => {
ReactDOM.render(
<I18nContext>{React.createElement(AccessDeniedPage)}</I18nContext>,
element[0]
);

element.on('$destroy', () => {
ReactDOM.unmountComponentAtNode(element[0]);
scope.$destroy();
});
},
};
});
export { Page } from './page';
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@elastic/eui';
import { NavigationMenu } from '../components/navigation_menu';

export const AccessDeniedPage = () => (
export const Page = () => (
<Fragment>
<NavigationMenu tabId="access-denied" />
<EuiPage>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FC } from 'react';
import { MlRoute, PageLoader } from '../router';
import { useResolver } from '../router';
import { KibanaConfigTypeFix } from '../../contexts/kibana';
import { Page } from '../../access_denied';

export const accessDeniedRoute: MlRoute = {
path: '/access-denied',
render: (props: any, config: any) => <PageWrapper config={config} />,
};

const PageWrapper: FC<{ config: KibanaConfigTypeFix }> = ({ config }) => {
const { context } = useResolver(undefined, config, {});

return (
<PageLoader context={context}>
<Page />
</PageLoader>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './settings';
export * from './data_frame_analytics';
export * from './timeseriesexplorer';
export * from './explorer';
export * from './access_denied';

0 comments on commit 96bcd72

Please sign in to comment.