Skip to content

Commit

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

* Avoid blinking
  • Loading branch information
jen-huang committed Oct 6, 2020
1 parent c0e2275 commit 62a60f7
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 62a60f7

Please sign in to comment.