Skip to content

Commit

Permalink
[Discover] Deangularize context.app (#80851)
Browse files Browse the repository at this point in the history
* [Discover] Deangularize context.app

* Add a unit test

* Addressing PR comments; fixin I18n provider; replacing kui with EUI code

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Maja Grubic and kibanamachine authored Oct 21, 2020
1 parent c11163d commit 3df30e0
Show file tree
Hide file tree
Showing 11 changed files with 947 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getServices } from '../../../../kibana_services';
import { fetchAnchorProvider } from '../api/anchor';
import { fetchContextProvider } from '../api/context';
import { getQueryParameterActions } from '../query_parameters';
import { FAILURE_REASONS, LOADING_STATUS } from './constants';
import { FAILURE_REASONS, LOADING_STATUS } from './index';
import { MarkdownSimple } from '../../../../../../kibana_react/public';

export function QueryActionsProvider(Promise) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
*/

export { QueryActionsProvider } from './actions';
export { FAILURE_REASONS, LOADING_STATUS } from './constants';
export { FAILURE_REASONS, LOADING_STATUS } from '../../../components/context_app/constants';
export { createInitialLoadingStatusState } from './state';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { LOADING_STATUS } from './constants';
import { LOADING_STATUS } from './index';

export function createInitialLoadingStatusState() {
return {
Expand Down
46 changes: 12 additions & 34 deletions src/plugins/discover/public/application/angular/context_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@


<!-- Error feedback -->
<context-error-message
status="contextApp.state.loadingStatus.anchor.status"
<context-error-message
status="contextApp.state.loadingStatus.anchor.status"
reason="contextApp.state.loadingStatus.anchor.reason">
</context-error-message>

Expand All @@ -35,39 +35,17 @@
type="'predecessors'"
></context-action-bar>


<!-- Loading feedback -->
<div
ng-if="[
contextApp.constants.LOADING_STATUS.UNINITIALIZED,
contextApp.constants.LOADING_STATUS.LOADING,
].includes(contextApp.state.loadingStatus.anchor.status)"
class="kuiPanel kuiPanel--centered kuiVerticalRhythm"
>
<div
class="kuiTableInfo"
i18n-id="discover.context.loadingDescription"
i18n-default-message="Loading…"
></div>
</div>

<!-- Table -->
<div
ng-if="contextApp.state.loadingStatus.anchor.status === contextApp.constants.LOADING_STATUS.LOADED"
class="kuiPanel kuiVerticalRhythm"
>
<div class="discover-table" fixed-scroll>
<doc-table
filter="contextApp.actions.addFilter"
hits="contextApp.state.rows.all"
index-pattern="contextApp.indexPattern"
sorting="contextApp.state.queryParameters.sort"
columns="contextApp.state.queryParameters.columns"
infinite-scroll="true"
minimum-visible-rows="contextApp.state.rows.all.length"
></doc-table>
</div>
</div>
<context-app-legacy
filter="contextApp.actions.addFilter"
hits="contextApp.state.rows.all"
index-pattern="contextApp.indexPattern"
sorting="contextApp.state.queryParameters.sort"
columns="contextApp.state.queryParameters.columns"
infinite-scroll="true"
minimum-visible-rows="contextApp.state.rows.all.length"
status="contextApp.state.loadingStatus.anchor.status"
></context-app-legacy>

<!-- Controls -->
<context-action-bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function convertDirectiveToRenderFn(
let rejected = false;

const cleanupFnPromise = injectAngularElement(domNode, directive.template, props, getInjector);

cleanupFnPromise.catch(() => {
rejected = true;
render(<div>error</div>, domNode);
Expand All @@ -91,10 +92,10 @@ export interface DocTableLegacyProps {
rows: Array<Record<string, unknown>>;
indexPattern: IIndexPattern;
minimumVisibleRows: number;
onAddColumn: (column: string) => void;
onSort: (sort: string[][]) => void;
onMoveColumn: (columns: string, newIdx: number) => void;
onRemoveColumn: (column: string) => void;
onAddColumn?: (column: string) => void;
onSort?: (sort: string[][]) => void;
onMoveColumn?: (columns: string, newIdx: number) => void;
onRemoveColumn?: (column: string) => void;
sort?: string[][];
}

Expand Down
Loading

0 comments on commit 3df30e0

Please sign in to comment.