Skip to content

Commit

Permalink
[Fleet] Add loading spinner to page headers (elastic#79568)
Browse files Browse the repository at this point in the history
* Add loading spinner to page headers

* Avoid blinking
  • Loading branch information
jen-huang authored Oct 6, 2020
1 parent 32d45b6 commit e451a4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => {
<EuiFlexItem>
<EuiText className="eui-textBreakWord">
<h1>
{(agentPolicy && agentPolicy.name) || (
<FormattedMessage
id="xpack.ingestManager.policyDetails.policyDetailsTitle"
defaultMessage="Policy '{id}'"
values={{
id: policyId,
}}
/>
{isLoading ? (
<Loading />
) : (
(agentPolicy && agentPolicy.name) || (
<FormattedMessage
id="xpack.ingestManager.policyDetails.policyDetailsTitle"
defaultMessage="Policy '{id}'"
values={{
id: policyId,
}}
/>
)
)}
</h1>
</EuiText>
Expand All @@ -98,7 +102,7 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => {
) : null}
</EuiFlexGroup>
),
[getHref, agentPolicy, policyId]
[getHref, isLoading, agentPolicy, policyId]
);

const enrollmentCancelClickHandler = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ export const AgentDetailsPage: React.FunctionComponent = () => {
<EuiFlexItem>
<EuiText>
<h1>
{typeof agentData?.item?.local_metadata?.host === 'object' &&
typeof agentData?.item?.local_metadata?.host?.hostname === 'string' ? (
{isLoading && isInitialRequest ? (
<Loading />
) : typeof agentData?.item?.local_metadata?.host === 'object' &&
typeof agentData?.item?.local_metadata?.host?.hostname === 'string' ? (
agentData.item.local_metadata.host.hostname
) : (
<FormattedMessage
Expand All @@ -114,8 +116,7 @@ export const AgentDetailsPage: React.FunctionComponent = () => {
</EuiFlexItem>
</EuiFlexGroup>
),
/* eslint-disable-next-line react-hooks/exhaustive-deps */
[agentData, agentId, getHref]
[agentData?.item?.local_metadata?.host, agentId, getHref, isInitialRequest, isLoading]
);

const headerRightContent = useMemo(
Expand Down

0 comments on commit e451a4d

Please sign in to comment.