Skip to content

Commit

Permalink
chore: merge 2.26.0 (#11648)
Browse files Browse the repository at this point in the history
* [Release] Hotfix 2.25.0 => 2.25.1 (patch) (#11618)

* chore: bump version to 2.25.1

* fix: mask token order in swap (#11620)

* fix: mismatch number tag (#11624)

* fix: mask token order (#11626)

---------

Co-authored-by: nuanyang233 <nuanyang233@gmail.com>

* chore: bump version to 2.26.0

* refactor: support x.com in code (#11634)

* feat: update permission page (#11639)

* feat: update permission page

* chore: reply review

* chore: reply review

* fix: incorrect adaptor name (#11640)

* fix: bugfix for update permission (#11642)

* fix: bugfix for update permission on installed (#11644)

* chore: eslint

---------

Co-authored-by: nuanyang233 <nuanyang233@gmail.com>
Co-authored-by: Jack Works <5390719+Jack-Works@users.noreply.github.com>
  • Loading branch information
3 people committed May 24, 2024
1 parent c4d6831 commit 5ce0e10
Show file tree
Hide file tree
Showing 21 changed files with 452 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.25.0",
"version": "2.26.0",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion packages/mask/background/tasks/NotCancellable/OnInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ function openWelcome() {
})
}

type DashboardRoutes_Permission = DashboardRoutes.Permissions extends `${infer T}` ? T : never
function openPermission() {
const permissions: DashboardRoutes_Permission = '/setup/permissions'
browser.tabs.create({
url: browser.runtime.getURL(`dashboard.html#${permissions}`),
})
}

browser.runtime.onInstalled.addListener(async (detail) => {
if (detail.reason === 'install') {
openWelcome()
} else if (detail.reason === 'update') {
const connect = await import('../../services/site-adaptors/connect.js')
const groups = await connect.getOriginsWithoutPermission()
if (groups.length) openWelcome()
if (groups.length) openPermission()
const localStorage = (globalThis as any).localStorage
if (localStorage) {
const backupPassword = localStorage.getItem('backupPassword')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EncryptPayloadNetwork } from '@masknet/encryption'
import type { SiteAdaptor } from '@masknet/types'
import { EnhanceableSite, isDomainOrSubdomainOf } from '@masknet/shared-base'

const origins = ['https://mobile.twitter.com/*', 'https://twitter.com/*', 'https://mobile.x.com/*', 'https://x.com/*']
const origins = ['https://mobile.twitter.com/*', 'https://twitter.com/*', 'https://www.x.com/*', 'https://x.com/*']
export const twitterBase: SiteAdaptor.Base = {
networkIdentifier: EnhanceableSite.Twitter,
encryptPayloadNetwork: EncryptPayloadNetwork.Twitter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const SideBarNativeItemPaddingRef = new ValueRef('11px')

function toolboxInSidebarSelector() {
// Organization account don't have a [data-testid=AppTabBar_More_Menu] in page. see MF-3866
return querySelector<HTMLElement>('[role="banner"] nav[role="navigation"] > div[data-testid=AppTabBar_More_Menu]')
return querySelector<HTMLElement>(
'[role="banner"] nav[role="navigation"] > button[data-testid=AppTabBar_More_Menu]',
)
}

export function injectToolboxHintAtTwitter(signal: AbortSignal, category: 'wallet' | 'application') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ export function postEditorContentInPopupSelector() {
)
}
export function postEditorInPopupSelector() {
return querySelector<E>(
'[aria-labelledby="modal-header"] div[data-testid="toolBar"] [role="presentation"]:has(> div[data-testid="geoButton"])',
)
return querySelector<E>('div[data-testid="toolBar"] [role="presentation"]:has(> button[data-testid="geoButton"])')
}
export function sideBarProfileSelector() {
return querySelector<E>('[role="banner"] [role="navigation"] [data-testid="AppTabBar_Profile_Link"] > div')
Expand Down Expand Up @@ -298,7 +296,7 @@ export function searchRetweetAvatarSelector() {

export function searchReplyToolbarSelector() {
return querySelector<E>(
'div[data-testid="primaryColumn"] div[data-testid="toolBar"] [role="presentation"]:has(> div[data-testid="geoButton"])',
'div[data-testid="primaryColumn"] div[data-testid="toolBar"] [role="presentation"]:has(> button[data-testid="geoButton"])',
)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/mask/dashboard/components/OnboardingWriter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const useStyles = makeStyles()((theme) => ({
},
}))

interface OnboardingWriterProps {
interface OnboardingWriterProps extends withClasses<'typed' | 'endTyping'> {
words: JSX.Element[]
}

export function OnboardingWriter({ words }: OnboardingWriterProps) {
const { classes, cx } = useStyles()
export function OnboardingWriter({ words, ...props }: OnboardingWriterProps) {
const { classes, cx } = useStyles(undefined, { props })

const [index, setIndex] = useState(0)

Expand Down
6 changes: 4 additions & 2 deletions packages/mask/dashboard/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
"recovery_smart_pay_wallet_description_other": "{{count}} local SmartPay wallets have been detected and successfully recovered.",
"welcome_request_to_collect": "Allow us to collect your usage information to help us make improvements.",
"welcome_to_use_mask_network": "Welcome to use Mask Network",
"update_authorization_title": "Update X.com Authorization",
"create_step": "Step {{step}}/{{totalSteps}}",
"persona_create_title": "Create New Mask Identity",
"persona_create_tips": "Create your persona to get started",
Expand Down Expand Up @@ -495,7 +496,7 @@
"persona_phrase_copy_description": "The mnemonic has been copied, please keep it in a safe place.",
"persona_phrase_create_tips": "Never share 12-word secret recovery phrase with anyone!",
"persona_phrase_create_check_tips": "I wrote down the words in the correct order",
"persona_onboarding_to_twitter": "Experience in Twitter",
"persona_onboarding_to_twitter": "Experience in X",
"persona_onboarding_set_payment_password": "Set Payment Password",
"persona_onboarding_pin_tips": "Pin Mask Network to the toolbar for easier access:",
"persona_onboarding_creating_identity": "Creating your ",
Expand All @@ -514,5 +515,6 @@
"local_backup": "Local Backup",
"incorrect_verification_code": "Invalid verification code.",
"wallet_set_payment_password_successfully": "Set payment password successfully.",
"wallet_open_mask_wallet": "Open Mask Wallet"
"wallet_open_mask_wallet": "Open Mask Wallet",
"permission_onboarding": "We are pleased to inform you that the authorization update for X website has been successfully completed. You can now continue to enjoy all the features of Mask Network as usual. Thank you for your continuous support!"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { memo, useCallback, useMemo } from 'react'
import { useDashboardTrans } from '../../../locales/i18n_generated.js'
import { Box, Typography, useTheme } from '@mui/material'
import { SetupFrameController } from '../../../components/SetupFrame/index.js'
import { PrimaryButton } from '../../../components/PrimaryButton/index.js'
import { makeStyles } from '@masknet/theme'
import { Icons } from '@masknet/icons'
import { Trend } from '../../../assets/index.js'
import { EnhanceableSite, userGuideStatus } from '@masknet/shared-base'

import { delay } from '@masknet/kit'
import { OnboardingWriter } from '../../../components/OnboardingWriter/index.js'
import { compact } from 'lodash-es'
import { TwitterAdaptor } from '../../../../shared/site-adaptors/implementations/twitter.com.js'
import { requestPermissionFromExtensionPage } from '../../../../shared-ui/index.js'

const useStyles = makeStyles()((theme) => ({
card: {
position: 'fixed',
top: 24,
right: 24,
padding: theme.spacing(2),
border: `1px solid ${theme.palette.maskColor.line}`,
borderRadius: 12,
maxWidth: 360,
},
pin: {
fontSize: 16,
lineHeight: '20px',
color: theme.palette.maskColor.main,
},
skeleton: {
background: 'linear-gradient(270deg, #F6F6F6 0%, rgba(217, 217, 217, 0) 94.74%)',
width: 190,
height: 36,
borderRadius: 99,
marginLeft: 42,
},
plugins: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: 36,
height: 36,
borderRadius: 99,
// hard color
background: '#F0F0F4',
marginLeft: 18,
marginRight: 18,
},
more: {
transform: 'rotate(90deg)',
},
pinCard: {
marginTop: 18,
borderRadius: 8,
border: `1px solid ${theme.palette.maskColor.line}`,
background: theme.palette.maskColor.bottom,
padding: 16,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
},
trend: {
position: 'fixed',
top: 206,
right: 408,
},
twitter: {
color: theme.palette.maskColor.bottom,
},

typed: {
fontSize: 36,
lineHeight: 1.2,
fontWeight: 700,
'& > strong': {
color: theme.palette.maskColor.main,
},
},
endTyping: {
opacity: 1,
},
}))

export const Component = memo(function Onboarding() {
const t = useDashboardTrans()
const { classes } = useStyles()

const theme = useTheme()

const onSetupTwitter = useCallback(async () => {
if (!(await requestPermissionFromExtensionPage(EnhanceableSite.Twitter))) return
if (!userGuideStatus[EnhanceableSite.Twitter].value) userGuideStatus[EnhanceableSite.Twitter].value = '1'
await delay(300)
await browser.tabs.create({
active: true,
url: TwitterAdaptor.homepage,
})
window.close()
}, [])

const words = useMemo(() => {
return compact([
<Typography key="identity">
{''}
{t.permission_onboarding()}
</Typography>,
])
}, [t])

return (
<>
<Box className={classes.card}>
<Typography className={classes.pin}>{t.persona_onboarding_pin_tips()}</Typography>
<Box mt={2.25} display="flex" alignItems="center">
<Box className={classes.skeleton} />
<Box className={classes.plugins}>
<Icons.Plugins size={20} />
</Box>
<Icons.More className={classes.more} size={24} />
</Box>
<Box className={classes.pinCard}>
<Box display="flex" alignItems="center" columnGap={2.5}>
<Icons.MaskBlue size={32} />
{/* There is no need for i18n here. */}
<Typography>Mask Network</Typography>
</Box>
<Icons.BluePin size={14} width={9} />
</Box>
</Box>
<img className={classes.trend} src={Trend} />
<Box>
<OnboardingWriter classes={{ typed: classes.typed, endTyping: classes.endTyping }} words={words} />
</Box>
<SetupFrameController>
<PrimaryButton
onClick={onSetupTwitter}
size="large"
startIcon={
<Icons.TwitterX
variant={theme.palette.mode === 'dark' ? 'light' : 'dark'}
className={classes.twitter}
size={20}
/>
}>
{t.persona_onboarding_to_twitter()}
</PrimaryButton>
</SetupFrameController>
</>
)
})
Loading

0 comments on commit 5ce0e10

Please sign in to comment.