Skip to content

Commit 2f3a25f

Browse files
committed
Add tooltip for Cloud Foundry credential on create platform wizard
Signed-off-by: Nandini Chandra <[email protected]>
1 parent 786b3cf commit 2f3a25f

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

client/public/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@
874874
"platformKind": {
875875
"cloudfoundry": {
876876
"label": "Cloud Foundry",
877-
"urlTooltip": "API URL to Cloud Foundry"
877+
"urlTooltip": "API URL to Cloud Foundry",
878+
"credentialTooltip": "Use credential of type source control"
878879
}
879880
}
880881
}

client/src/app/hooks/usePlatformKindList.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ export const DEFAULT_KIND = "cloudfoundry";
77

88
export const KIND_MAP: Map<
99
string,
10-
{ labelKey: string; urlTooltipKey: string }
10+
{ labelKey: string; urlTooltipKey: string; credentialTooltipKey: string }
1111
> = new Map([
1212
[
1313
"cloudfoundry",
1414
{
1515
labelKey: "platformKind.cloudfoundry.label",
1616
urlTooltipKey: "platformKind.cloudfoundry.urlTooltip",
17+
credentialTooltipKey: "platformKind.cloudfoundry.credentialTooltip",
1718
},
1819
],
1920
]);
@@ -50,5 +51,15 @@ export const usePlatformKindList = () => {
5051
[t]
5152
);
5253

53-
return { kinds, getDisplayLabel, getUrlTooltip };
54+
const getCredentialTooltip = useCallback(
55+
(kind: string | undefined | null): string => {
56+
if (kind && KIND_MAP.has(kind)) {
57+
return t(KIND_MAP.get(kind)!.credentialTooltipKey);
58+
}
59+
return "";
60+
},
61+
[t]
62+
);
63+
64+
return { kinds, getDisplayLabel, getUrlTooltip, getCredentialTooltip };
5465
};

client/src/app/pages/source-platforms/components/platform-form.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const PlatformFormRenderer: React.FC<PlatformFormProps> = ({
6161
onClose,
6262
}) => {
6363
const { t } = useTranslation();
64-
const { kinds: platformKindList, getUrlTooltip } = usePlatformKindList();
64+
const { kinds: platformKindList, getUrlTooltip, getCredentialTooltip } = usePlatformKindList();
6565

6666
const { existingPlatforms, createPlatform, updatePlatform } =
6767
usePlatformFormData({
@@ -233,6 +233,20 @@ const PlatformFormRenderer: React.FC<PlatformFormProps> = ({
233233
name="credentials"
234234
label={t("terms.credentials")}
235235
fieldId="credentials"
236+
labelIcon={
237+
getCredentialTooltip(selectedKind) ? (
238+
<Popover bodyContent={<div>{getCredentialTooltip(selectedKind)}</div>}>
239+
<button
240+
type="button"
241+
aria-label="More info for credential field"
242+
onClick={(e) => e.preventDefault()}
243+
className="pf-v5-c-button pf-m-plain"
244+
>
245+
<HelpIcon />
246+
</button>
247+
</Popover>
248+
) : undefined
249+
}
236250
renderInput={({ field: { value, name, onChange } }) => (
237251
<>
238252
<SimpleSelect

0 commit comments

Comments
 (0)