Skip to content

Commit 63cbe42

Browse files
authored
small azure patches (#4341)
1 parent b6c25dc commit 63cbe42

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

dashboard/src/components/porter/Link.tsx

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import DynamicLink from "components/DynamicLink";
21
import React from "react";
32
import styled from "styled-components";
43

4+
import DynamicLink from "components/DynamicLink";
5+
56
type Props = {
67
to?: string;
78
onClick?: () => void;
@@ -11,6 +12,7 @@ type Props = {
1112
color?: string;
1213
hoverColor?: string;
1314
showTargetBlankIcon?: boolean;
15+
inline?: boolean;
1416
};
1517

1618
const Link: React.FC<Props> = ({
@@ -22,14 +24,39 @@ const Link: React.FC<Props> = ({
2224
color = "#ffffff",
2325
hoverColor,
2426
showTargetBlankIcon = true,
27+
inline = true,
2528
}) => {
2629
return (
2730
<LinkWrapper hoverColor={hoverColor} color={color}>
2831
{to ? (
29-
<StyledLink to={to} target={target} color={color}>
32+
<StyledLink
33+
to={to}
34+
target={target}
35+
color={color}
36+
inline={inline}
37+
>
3038
{children}
3139
{target === "_blank" && showTargetBlankIcon && (
32-
<Svg color={color} hoverColor={hoverColor} data-testid="geist-icon" fill="none" height="1em" shape-rendering="geometricPrecision" stroke="currentColor" stroke-linecap="round" strokeLinejoin="round" stroke-width="2" viewBox="0 0 24 24" width="1em" data-darkreader-inline-stroke="" data-darkreader-inline-color=""><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path><path d="M15 3h6v6"></path><path d="M10 14L21 3"></path></Svg>
40+
<Svg
41+
color={color}
42+
hoverColor={hoverColor}
43+
data-testid="geist-icon"
44+
fill="none"
45+
height="1em"
46+
shape-rendering="geometricPrecision"
47+
stroke="currentColor"
48+
stroke-linecap="round"
49+
strokeLinejoin="round"
50+
stroke-width="2"
51+
viewBox="0 0 24 24"
52+
width="1em"
53+
data-darkreader-inline-stroke=""
54+
data-darkreader-inline-color=""
55+
>
56+
<path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>
57+
<path d="M15 3h6v6"></path>
58+
<path d="M10 14L21 3"></path>
59+
</Svg>
3360
)}
3461
</StyledLink>
3562
) : (
@@ -44,7 +71,7 @@ const Link: React.FC<Props> = ({
4471

4572
export default Link;
4673

47-
const Svg = styled.svg<{ color: string, hoverColor?: string }>`
74+
const Svg = styled.svg<{ color: string; hoverColor?: string }>`
4875
margin-left: 5px;
4976
stroke: ${(props) => props.color};
5077
stroke-width: 2;
@@ -59,9 +86,13 @@ const Underline = styled.div<{ color: string }>`
5986
background: ${(props) => props.color};
6087
`;
6188

62-
const StyledLink = styled(DynamicLink) <{ hasunderline?: boolean, color: string, removeInline?: boolean }>`
89+
const StyledLink = styled(DynamicLink)<{
90+
hasunderline?: boolean;
91+
color: string;
92+
inline: boolean;
93+
}>`
6394
color: ${(props) => props.color};
64-
${(props) => !props.removeInline && "display: inline-flex;"};
95+
${(props) => props.inline && "display: inline-flex;"};
6596
font-size: 13px;
6697
cursor: pointer;
6798
align-items: center;
@@ -75,7 +106,7 @@ const Div = styled.span<{ color: string }>`
75106
align-items: center;
76107
`;
77108

78-
const LinkWrapper = styled.span<{ hoverColor?: string, color: string }>`
109+
const LinkWrapper = styled.span<{ hoverColor?: string; color: string }>`
79110
position: relative;
80111
display: inline-flex;
81112
align-items: center;
@@ -95,5 +126,5 @@ const LinkWrapper = styled.span<{ hoverColor?: string, color: string }>`
95126
svg {
96127
stroke: ${({ hoverColor, color }) => hoverColor ?? color};
97128
}
98-
};
99-
`;
129+
}
130+
`;

dashboard/src/lib/hooks/useCluster.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,11 @@ export const useUpdateCluster = ({
426426
// otherwise, continue to create the contract
427427
} catch (err) {
428428
throw new Error(
429-
getErrorMessageFromNetworkCall(err, "Cluster preflight checks")
429+
getErrorMessageFromNetworkCall(
430+
err,
431+
"Cluster preflight checks",
432+
preflightCheckErrorReplacements
433+
)
430434
);
431435
} finally {
432436
setIsHandlingPreflightChecks(false);
@@ -531,15 +535,28 @@ export const useClusterNodeList = ({
531535
};
532536
};
533537

538+
const preflightCheckErrorReplacements = {
539+
RequestThrottled:
540+
"Your cloud provider is currently throttling API requests. Please try again in a few minutes.",
541+
};
542+
534543
const getErrorMessageFromNetworkCall = (
535544
err: unknown,
536-
networkCallDescription: string
545+
networkCallDescription: string,
546+
replaceError?: Record<string, string>
537547
): string => {
538548
if (axios.isAxiosError(err)) {
539549
const parsed = z
540550
.object({ error: z.string() })
541551
.safeParse(err.response?.data);
542552
if (parsed.success) {
553+
if (replaceError) {
554+
for (const key in replaceError) {
555+
if (parsed.data.error.includes(key)) {
556+
return `${networkCallDescription} failed: ${replaceError[key]}`;
557+
}
558+
}
559+
}
543560
return `${networkCallDescription} failed: ${parsed.data.error}`;
544561
}
545562
}

dashboard/src/main/home/infrastructure-dashboard/modals/help/preflight/ResolutionStepsModalContents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ResolutionStepsModalContents: React.FC<Props> = ({ resolution }) => {
2424
{resolution.steps.map((step, i) => (
2525
<Step number={i + 1} key={i}>
2626
{step.externalLink ? (
27-
<Link to={step.externalLink} target="_blank">
27+
<Link to={step.externalLink} target="_blank" inline={false}>
2828
{step.text}
2929
</Link>
3030
) : (

0 commit comments

Comments
 (0)