File tree Expand file tree Collapse file tree 2 files changed +18
-21
lines changed
x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials Expand file tree Collapse file tree 2 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import React from 'react';
1111import { shallow } from 'enzyme' ;
1212
1313import { Credentials } from './credentials' ;
14- import { EuiCopy , EuiPageContentBody } from '@elastic/eui' ;
14+ import { EuiCopy , EuiLoadingContent , EuiPageContentBody } from '@elastic/eui' ;
1515
1616import { externalUrl } from '../../../shared/enterprise_search_url' ;
1717
@@ -48,10 +48,11 @@ describe('Credentials', () => {
4848 expect ( actions . resetCredentials ) . toHaveBeenCalledTimes ( 1 ) ;
4949 } ) ;
5050
51- it ( 'renders nothing if data is still loading' , ( ) => {
51+ it ( 'renders a limited UI if data is still loading' , ( ) => {
5252 setMockValues ( { dataLoading : true } ) ;
5353 const wrapper = shallow ( < Credentials /> ) ;
54- expect ( wrapper . find ( EuiPageContentBody ) ) . toHaveLength ( 0 ) ;
54+ expect ( wrapper . find ( '[data-test-subj="CreateAPIKeyButton"]' ) ) . toHaveLength ( 0 ) ;
55+ expect ( wrapper . find ( EuiLoadingContent ) ) . toHaveLength ( 1 ) ;
5556 } ) ;
5657
5758 it ( 'renders the API endpoint and a button to copy it' , ( ) => {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import {
1919 EuiButton ,
2020 EuiPageContentHeader ,
2121 EuiPageContentHeaderSection ,
22+ EuiLoadingContent ,
2223} from '@elastic/eui' ;
2324import { i18n } from '@kbn/i18n' ;
2425
@@ -41,11 +42,6 @@ export const Credentials: React.FC = () => {
4142 } ;
4243 } , [ ] ) ;
4344
44- // TODO
45- // if (dataLoading) { return <Loading /> }
46- if ( dataLoading ) {
47- return null ;
48- }
4945 return (
5046 < >
5147 < SetPageChrome
@@ -110,22 +106,22 @@ export const Credentials: React.FC = () => {
110106 </ EuiTitle >
111107 </ EuiPageContentHeaderSection >
112108 < EuiPageContentHeaderSection >
113- < EuiButton
114- color = "primary"
115- data-test-subj = "CreateAPIKeyButton"
116- fill = { true }
117- onClick = { ( ) => showCredentialsForm ( ) }
118- >
119- { i18n . translate ( 'xpack.enterpriseSearch.appSearch.credentials.createKey' , {
120- defaultMessage : 'Create a key' ,
121- } ) }
122- </ EuiButton >
109+ { ! dataLoading && (
110+ < EuiButton
111+ color = "primary"
112+ data-test-subj = "CreateAPIKeyButton"
113+ fill = { true }
114+ onClick = { ( ) => showCredentialsForm ( ) }
115+ >
116+ { i18n . translate ( 'xpack.enterpriseSearch.appSearch.credentials.createKey' , {
117+ defaultMessage : 'Create a key' ,
118+ } ) }
119+ </ EuiButton >
120+ ) }
123121 </ EuiPageContentHeaderSection >
124122 </ EuiPageContentHeader >
125123 < EuiSpacer size = "s" />
126- < EuiPanel >
127- < CredentialsList />
128- </ EuiPanel >
124+ < EuiPanel > { ! ! dataLoading ? < EuiLoadingContent lines = { 3 } /> : < CredentialsList /> } </ EuiPanel >
129125 </ EuiPageContentBody >
130126 </ >
131127 ) ;
You can’t perform that action at this time.
0 commit comments