Skip to content

Commit

Permalink
NCL-8755 Update tooltip message for SSH Credentials button
Browse files Browse the repository at this point in the history
  • Loading branch information
DnsZhou committed Sep 12, 2024
1 parent afd36c7 commit 970aadc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/components/BuildPages/BuildPages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { PageTabs } from 'components/PageTabs/PageTabs';
import { PageTabsItem } from 'components/PageTabs/PageTabsItem';
import { PageTabsLabel } from 'components/PageTabs/PageTabsLabel';
import { ServiceContainerLoading } from 'components/ServiceContainers/ServiceContainerLoading';
import { SshCredentialsButton } from 'components/SshCredentialsButton/SshCredentialsButton';
import { BUILD_STATUS, SshCredentialsButton } from 'components/SshCredentialsButton/SshCredentialsButton';

import * as buildApi from 'services/buildApi';
import { uiLogger } from 'services/uiLogger';
Expand Down Expand Up @@ -166,7 +166,15 @@ export const BuildPages = () => {
key="ssh-credentials"
serviceContainerSshCredentials={serviceContainerBuildSshCredentials}
buildBelongToCurrentUser={buildBelongToCurrentUser || isCurrentUserAdmin}
hasBuildFailed={!!serviceContainerBuild.data?.status && !!buildStatusData[serviceContainerBuild.data.status].failed}
buildStatus={
!serviceContainerBuild.data?.status
? BUILD_STATUS.InProgress
: buildStatusData[serviceContainerBuild.data.status].failed
? BUILD_STATUS.Failed
: buildStatusData[serviceContainerBuild.data.status].progress !== 'FINISHED'
? BUILD_STATUS.InProgress
: BUILD_STATUS.Success
}
/>,
<CancelBuildModalButton
key="cancel-build-button"
Expand Down
22 changes: 15 additions & 7 deletions src/components/SshCredentialsButton/SshCredentialsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@ import { ProgressButton } from 'components/ProgressButton/ProgressButton';
import { ProtectedComponent } from 'components/ProtectedContent/ProtectedComponent';
import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';

export enum BUILD_STATUS {
InProgress,
Success,
Failed,
}

interface ISshCredentialsButtonProps {
serviceContainerSshCredentials: IServiceContainerState<SSHCredentials>;
buildBelongToCurrentUser: boolean;
hasBuildFailed: boolean;
buildStatus: BUILD_STATUS;
}

export const SshCredentialsButton = ({
serviceContainerSshCredentials,
buildBelongToCurrentUser,
hasBuildFailed,
buildStatus,
}: ISshCredentialsButtonProps) => {
const disabledReason = !buildBelongToCurrentUser
? 'Build does not belong to the currently logged in user.'
: !hasBuildFailed
? 'Build has not failed.'
? 'Only user who executed the build and PNC admins are allowed to get the SSH Credentials.'
: buildStatus === BUILD_STATUS.InProgress
? 'The build is currently in progress; SSH Credentials are only available for unsuccessful builds with "keep pod alive" option.'
: buildStatus === BUILD_STATUS.Success
? 'SSH Credentials are only available for unsuccessful builds with "keep pod alive" option.'
: !serviceContainerSshCredentials.data?.command
? "SSH credentials are only available for those unsuccessful builds with 'keep pod alive' option. Alternatively you can modify your build script to intentionally fail it and get the SSH credentials you need."
? "SSH credentials are only available for unsuccessful builds with 'keep pod alive' option. Alternatively you can modify your build script to intentionally fail it and get the SSH credentials you need."
: undefined;

return (
Expand All @@ -52,7 +60,7 @@ export const SshCredentialsButton = ({
>
<TooltipWrapper tooltip={disabledReason}>
<ProgressButton
variant="control"
variant="tertiary"
isSmall
serviceContainer={serviceContainerSshCredentials}
isDisabled={!!disabledReason || !!serviceContainerSshCredentials.error}
Expand Down

0 comments on commit 970aadc

Please sign in to comment.