Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@
"platformKind": {
"cloudfoundry": {
"label": "Cloud Foundry",
"urlTooltip": "API URL to Cloud Foundry"
"urlTooltip": "API URL to Cloud Foundry",
"credentialTooltip": "Use credential of type source control"
}
}
}
15 changes: 13 additions & 2 deletions client/src/app/hooks/usePlatformKindList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ export const DEFAULT_KIND = "cloudfoundry";

export const KIND_MAP: Map<
string,
{ labelKey: string; urlTooltipKey: string }
{ labelKey: string; urlTooltipKey: string; credentialTooltipKey: string }
> = new Map([
[
"cloudfoundry",
{
labelKey: "platformKind.cloudfoundry.label",
urlTooltipKey: "platformKind.cloudfoundry.urlTooltip",
credentialTooltipKey: "platformKind.cloudfoundry.credentialTooltip",
},
],
]);
Expand Down Expand Up @@ -50,5 +51,15 @@ export const usePlatformKindList = () => {
[t]
);

return { kinds, getDisplayLabel, getUrlTooltip };
const getCredentialTooltip = useCallback(
(kind: string | undefined | null): string => {
if (kind && KIND_MAP.has(kind)) {
return t(KIND_MAP.get(kind)!.credentialTooltipKey);
}
return "";
},
[t]
);

return { kinds, getDisplayLabel, getUrlTooltip, getCredentialTooltip };
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const PlatformFormRenderer: React.FC<PlatformFormProps> = ({
onClose,
}) => {
const { t } = useTranslation();
const { kinds: platformKindList, getUrlTooltip } = usePlatformKindList();
const { kinds: platformKindList, getUrlTooltip, getCredentialTooltip } = usePlatformKindList();

const { existingPlatforms, createPlatform, updatePlatform } =
usePlatformFormData({
Expand Down Expand Up @@ -233,6 +233,20 @@ const PlatformFormRenderer: React.FC<PlatformFormProps> = ({
name="credentials"
label={t("terms.credentials")}
fieldId="credentials"
labelIcon={
getCredentialTooltip(selectedKind) ? (
<Popover bodyContent={<div>{getCredentialTooltip(selectedKind)}</div>}>
<button
type="button"
aria-label="More info for credential field"
onClick={(e) => e.preventDefault()}
className="pf-v5-c-button pf-m-plain"
>
<HelpIcon />
</button>
</Popover>
) : undefined
}
renderInput={({ field: { value, name, onChange } }) => (
<>
<SimpleSelect
Expand Down
Loading