Skip to content

Commit

Permalink
Minor UI copy changes for maintainer token role auth flow
Browse files Browse the repository at this point in the history
  • Loading branch information
subbuvenk-atlas committed Dec 18, 2024
1 parent e130e9d commit 553ca9a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
38 changes: 19 additions & 19 deletions ui/src/components/AuthPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ import { AuthErrorTypes, ErrorTypes } from '../../resolverTypes';
import { useAppContext } from '../../hooks/useAppContext';
import { IncomingWebhookSectionMessage } from '../IncomingWebhookSectionMessage';
import { GitLabRoles } from '../../types';
import {
CopyIconWrapper,
FormWrapper,
ListItemContent,
ReloadButtonWrapper,
SectionMessageWrapper,
TokenRoleWrapper,
} from './styles';
import { CopyIconWrapper, FormWrapper, ReloadButtonWrapper, SectionMessageWrapper, TokenRoleWrapper } from './styles';

const buildValidationMethod = (errorType: ErrorTypes) => {
switch (errorType) {
Expand Down Expand Up @@ -260,6 +253,7 @@ export const AuthPage = () => {
};

const handleWebhookUrlCopy = useCallback(() => {
console.log('Copying webhook URL', webhookSetupConfig.triggerUrl);
return navigator.clipboard
.writeText(webhookSetupConfig.triggerUrl)
.then(() => {
Expand All @@ -271,7 +265,7 @@ export const AuthPage = () => {
.catch(() => {
console.log('Error copying webhook URL');
});
}, []);
}, [webhookSetupConfig]);

const ConnectionMessage = () =>
features.isGitlabMaintainerTokenEnabled && selectedRole === GitLabRoles.MAINTAINER ? (
Expand Down Expand Up @@ -324,11 +318,16 @@ export const AuthPage = () => {
</SectionMessageWrapper>
);

const WebhookCopyIcon = () => (
<Tooltip content={webhookCopyTooltipContent} testId='webhook-url-copy-tooltip'>
<CopyIconWrapper onClick={handleWebhookUrlCopy} data-testid='webhoook-url-copy-icon'>
<CopyIcon label='Copy webhook URL' />
</CopyIconWrapper>
const WebhookCopyButton = () => (
<Tooltip content={webhookCopyTooltipContent} testId='webhook-url-copy-tooltip' position='top-end'>
<Button
appearance='link'
spacing='compact'
onClick={handleWebhookUrlCopy}
iconAfter={<CopyIcon label='Copy webhook URL' />}
>
{webhookSetupConfig.triggerUrl}
</Button>
</Tooltip>
);

Expand All @@ -341,9 +340,7 @@ export const AuthPage = () => {

<ul>
<li>
<ListItemContent>
Create new webhook by copying the URL <WebhookCopyIcon />{' '}
</ListItemContent>
Create new webhook by copying the URL: <WebhookCopyButton />
</li>
<li>Add a secret token for webhook and input the same below</li>
<li>
Expand All @@ -353,7 +350,10 @@ export const AuthPage = () => {
<li>
Ensure that <b>Enable SSL Verification</b> is checked
</li>
<li>Webhook ID can be found as part of the URL when in edit mode</li>
<li>
Webhook ID can be found as part of the URL when in edit mode <br />
Example: https://gitlab.com/.../-/hooks/<b>webhook_id</b>/edit
</li>
</ul>
</SectionMessageWrapper>
);
Expand Down Expand Up @@ -385,7 +385,7 @@ export const AuthPage = () => {
)}
</TokenRoleWrapper>
<ConnectionMessage />
<IncomingWebhookSectionMessage />
<IncomingWebhookSectionMessage isMaintainerTokenEnabled={features.isGitlabMaintainerTokenEnabled} />
</>
)}

Expand Down
5 changes: 0 additions & 5 deletions ui/src/components/AuthPage/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,3 @@ export const CopyIconWrapper = styled.button`
color: ${token('color.icon')};
}
`;

export const ListItemContent = styled.span`
display: flex;
align-items: center;
`;
4 changes: 2 additions & 2 deletions ui/src/components/ConnectedPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ConnectedPage = () => {
const [groups, setGroups] = useState<GitlabAPIGroup[]>();

const navigate = useNavigate();
const { getConnectedInfo, clearGroup } = useAppContext();
const { features, getConnectedInfo, clearGroup } = useAppContext();
const { isImportInProgress } = useImportContext();

const handleDisconnectGroup = async (id: number) => {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const ConnectedPage = () => {
<h4>Connected group</h4>
<p>You can connect only one GitLab group to Compass at a time, and you must be an owner of that group.</p>
<br />
<IncomingWebhookSectionMessage />
<IncomingWebhookSectionMessage isMaintainerTokenEnabled={features.isGitlabMaintainerTokenEnabled} />
<br />
<ConnectInfoPanel
connectedGroup={groups[0]}
Expand Down
9 changes: 7 additions & 2 deletions ui/src/components/IncomingWebhookSectionMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import WebhookIcon from './assets/WebhookIcon.svg';
import { ForgeLink } from './ForgeLink';
import { INCOMING_WEBHOOK_SETTINGS_PAGE_LINK } from '../constants';

export const IncomingWebhookSectionMessage = () => {
type Props = {
isMaintainerTokenEnabled?: boolean;
};

export const IncomingWebhookSectionMessage = ({ isMaintainerTokenEnabled = false }: Props) => {
return (
<IncomingWebhookSectionWrapper>
<IncomingWebhookIcon src={WebhookIcon} />
<div>
<p>
If you're not a group owner or use the self-managed version of GitLab, you can use{' '}
If you're not a group owner{isMaintainerTokenEnabled ? '/maintainer' : ''} or use the self-managed version of
GitLab, you can use{' '}
<ForgeLink to={INCOMING_WEBHOOK_SETTINGS_PAGE_LINK} openInNewTab>
incoming webhooks
</ForgeLink>{' '}
Expand Down

0 comments on commit 553ca9a

Please sign in to comment.