Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Safe Apps): Add option for Safe Apps to include Telegram ID as a social media link #4762

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@safe-global/protocol-kit": "^4.1.3",
"@safe-global/safe-apps-sdk": "^9.1.0",
"@safe-global/safe-client-gateway-sdk": "v1.60.1",
"@safe-global/safe-gateway-typescript-sdk": "3.22.6-beta.0",
"@safe-global/safe-gateway-typescript-sdk": "3.22.6",
"@safe-global/safe-modules-deployments": "^2.2.1",
"@sentry/react": "^7.91.0",
"@spindl-xyz/attribution-lite": "^1.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ const githubSocialProfileMock = {
url: 'http://tx-builder-github',
}

const socialProfilesMock = [discordSocialProfileMock, twitterSocialProfileMock, githubSocialProfileMock]
const telegramSocialProfileMock = {
platform: SafeAppSocialPlatforms.TELEGRAM,
url: 'http://tx-builder-telegram',
}

const socialProfilesMock = [
discordSocialProfileMock,
twitterSocialProfileMock,
githubSocialProfileMock,
telegramSocialProfileMock,
]

describe('SafeAppSocialLinksCard', () => {
it('renders nothing if no social link is present in the safe app data', async () => {
Expand Down Expand Up @@ -76,6 +86,7 @@ describe('SafeAppSocialLinksCard', () => {
expect(screen.getByLabelText('Discord link')).toBeInTheDocument()
expect(screen.getByLabelText('Twitter link')).toBeInTheDocument()
expect(screen.getByLabelText('Github link')).toBeInTheDocument()
expect(screen.getByLabelText('Telegram link')).toBeInTheDocument()
})
})

Expand All @@ -93,6 +104,7 @@ describe('SafeAppSocialLinksCard', () => {
expect(screen.getByLabelText('Discord link')).toBeInTheDocument()
expect(screen.getByLabelText('Twitter link')).toBeInTheDocument()
expect(screen.getByLabelText('Github link')).toBeInTheDocument()
expect(screen.getByLabelText('Telegram link')).toBeInTheDocument()
})
})

Expand All @@ -109,6 +121,7 @@ describe('SafeAppSocialLinksCard', () => {
expect(screen.queryByLabelText('Discord link')).toBeInTheDocument()
expect(screen.queryByLabelText('Twitter link')).not.toBeInTheDocument()
expect(screen.queryByLabelText('Github link')).not.toBeInTheDocument()
expect(screen.queryByLabelText('Telegram link')).not.toBeInTheDocument()
})
})
})
32 changes: 30 additions & 2 deletions apps/web/src/components/safe-apps/SafeAppSocialLinksCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Divider from '@mui/material/Divider'
import { default as MuiLink } from '@mui/material/Link'
import HelpOutlineRoundedIcon from '@mui/icons-material/HelpOutlineRounded'
import GitHubIcon from '@mui/icons-material/GitHub'
import TelegramIcon from '@mui/icons-material/Telegram'
import TwitterIcon from '@mui/icons-material/Twitter'
import { SafeAppSocialPlatforms } from '@safe-global/safe-gateway-typescript-sdk'
import type { SafeAppData, SafeAppSocialProfile } from '@safe-global/safe-gateway-typescript-sdk'
Expand All @@ -30,6 +31,7 @@ const SafeAppSocialLinksCard = ({ safeApp }: SafeAppSocialLinksCardProps) => {
const discordSocialLink = getSocialProfile(socialProfiles, SafeAppSocialPlatforms.DISCORD)
const twitterSocialLink = getSocialProfile(socialProfiles, SafeAppSocialPlatforms.TWITTER)
const githubSocialLink = getSocialProfile(socialProfiles, SafeAppSocialPlatforms.GITHUB)
const telegramSocialLink = getSocialProfile(socialProfiles, SafeAppSocialPlatforms.TELEGRAM)

return (
<Card className={css.container}>
Expand Down Expand Up @@ -58,13 +60,25 @@ const SafeAppSocialLinksCard = ({ safeApp }: SafeAppSocialLinksCardProps) => {

<Box display="flex" mt={0.2} minHeight="40px">
{discordSocialLink && (
<IconButton aria-label="Discord link" component="a" target="_blank" href={discordSocialLink.url}>
<IconButton
aria-label="Discord link"
component="a"
target="_blank"
rel="noopener noreferrer"
href={discordSocialLink.url}
>
<DiscordIcon />
</IconButton>
)}

{twitterSocialLink && (
<IconButton aria-label="Twitter link" component="a" target="_blank" href={twitterSocialLink.url}>
<IconButton
aria-label="Twitter link"
component="a"
target="_blank"
rel="noopener noreferrer"
href={twitterSocialLink.url}
>
<TwitterIcon color="border" />
</IconButton>
)}
Expand All @@ -75,11 +89,25 @@ const SafeAppSocialLinksCard = ({ safeApp }: SafeAppSocialLinksCardProps) => {
component="a"
href={githubSocialLink.url}
target="_blank"
rel="noopener noreferrer"
style={{ height: '40px', width: '40px' }}
>
<GitHubIcon color="border" />
</IconButton>
)}

{telegramSocialLink && (
<IconButton
aria-label="Telegram link"
component="a"
href={telegramSocialLink.url}
target="_blank"
rel="noopener noreferrer"
style={{ height: '40px', width: '40px' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add rel="noopener noreferrer" to this and the other IcoButtons in this file?

Might be good to create a component to not repeat the same 6 lines for each button.

function IconButtonLink({ href, label, children }) {
  return (
    <IconButton
                  aria-label={label}
                  component="a"
                  href={href}
                  target="_blank"
                  rel="noopener noreferrer"
                  style={{ height: '40px', width: '40px' }}>
                    {children}
    </IconButton>
  )
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katspaugh I added the rel attribute.
7922961

I suggest postponing the creation of a new component to a separate PR.

>
<TelegramIcon color="border" />
</IconButton>
)}
</Box>
</div>
)}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7523,10 +7523,10 @@ __metadata:
languageName: node
linkType: hard

"@safe-global/safe-gateway-typescript-sdk@npm:3.22.6-beta.0":
version: 3.22.6-beta.0
resolution: "@safe-global/safe-gateway-typescript-sdk@npm:3.22.6-beta.0"
checksum: 10/9a4d0a1ac5d4e82a7e53904f7a8b7d955624e910f3eb041e1c99d09673c71dd9f8252bd33d1708470b1ecf1c80feeeb3d6f33e72e68ee2f4ba248e7ebbd4e80d
"@safe-global/safe-gateway-typescript-sdk@npm:3.22.6":
version: 3.22.6
resolution: "@safe-global/safe-gateway-typescript-sdk@npm:3.22.6"
checksum: 10/021f605143d507b1fc9b9be34a1a0f96aecd268d5349428e92bf636b64c9123dd992e27ce95c6c47a092a80f95a3fb1756a651322eda497d1ef867a62a8710da
languageName: node
linkType: hard

Expand Down Expand Up @@ -7613,7 +7613,7 @@ __metadata:
"@safe-global/safe-apps-sdk": "npm:^9.1.0"
"@safe-global/safe-client-gateway-sdk": "npm:v1.60.1"
"@safe-global/safe-core-sdk-types": "npm:^5.0.1"
"@safe-global/safe-gateway-typescript-sdk": "npm:3.22.6-beta.0"
"@safe-global/safe-gateway-typescript-sdk": "npm:3.22.6"
"@safe-global/safe-modules-deployments": "npm:^2.2.1"
"@sentry/react": "npm:^7.91.0"
"@sentry/types": "npm:^7.74.0"
Expand Down
Loading