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

chore(condo): DOMA-10737 improve lint-i18n-translations.js #5530

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
!**/.gitignore
**/__*
**/*.log
*.log
**/.DS_Store
**/Thumbs.db
**/Dockerfile
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ semgrep_results/*

# Backup artifacts
backups

# no logs
*.log
1 change: 1 addition & 0 deletions apps/condo/lang/ru/messages/RESET_PASSWORD/default.njk
Copy link
Contributor

@Alllex202 Alllex202 Nov 23, 2024

Choose a reason for hiding this comment

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

It looks like we don't use a "RESET_PASSWORD" message type, so you should remove translations for that type

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I want to add this check to the linter

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Перейдите по ссылке, чтобы установить новый пароль: {{ env.serverUrl }}/auth/change-password?token={{ message.meta.token }}
1 change: 1 addition & 0 deletions apps/condo/lang/ru/messages/RESET_PASSWORD/sms.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Перейдите по ссылке, чтобы установить новый пароль: {{ env.serverUrl }}/auth/change-password?token={{ message.meta.token }}
107 changes: 52 additions & 55 deletions apps/condo/pages/tls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { useIntl } from '@open-condo/next/intl'
import { Button, Card, Markdown, Space, Typography } from '@open-condo/ui'
import { colors } from '@open-condo/ui/dist/colors'

import { ConvertToUTF8 } from '../domains/banking/utils/serverSchema/converters/convertToUTF8'
import EmptyLayout from '@condo/domains/common/components/containers/EmptyLayout'
import { useLayoutContext } from '@condo/domains/common/components/LayoutContext'
import { LoginWithSBBOLButton } from '@condo/domains/common/components/LoginWithSBBOLButton'
Expand Down Expand Up @@ -98,7 +97,7 @@ const ICONS = {

export const Header: React.FC = (): JSX.Element => {
const intl = useIntl()
const BackMessage = intl.formatMessage( { id: 'pages.condo.tls.back' })
const BackMessage = intl.formatMessage({ id: 'pages.condo.tls.back' })

const { push } = useRouter()
const { isAuthenticated } = useAuth()
Expand Down Expand Up @@ -136,7 +135,7 @@ const BlankAnchor = styled(Anchor)`
}
/* This is a redundant element, that adds visual artefacts to the button */
.ant-anchor-ink {
display: none;
display: none;
}
`

Expand Down Expand Up @@ -178,7 +177,7 @@ const MoreLinkStyle = {

const PosterHeader: React.FC = (): JSX.Element => {
const intl = useIntl()
const MoreLinkMessage = intl.formatMessage( { id: 'pages.condo.tls.poster.more' })
const MoreLinkMessage = intl.formatMessage({ id: 'pages.condo.tls.poster.more' })
return (
<Space direction='vertical' size={8} align='end'>
<BlankAnchor affix={false}>
Expand All @@ -200,15 +199,15 @@ const PosterHeader: React.FC = (): JSX.Element => {

// NOTE(antonal): non-standard gap is a requirement from design team. `Space` cannot be used, because it requires `size` property to be set
const PosterFooterSpace = styled.div`
display: flex;
flex-direction: column;
gap: 100px;
align-items: center;
display: flex;
flex-direction: column;
gap: 100px;
align-items: center;
`

const PosterFooter: React.FC = (): JSX.Element => {
const intl = useIntl()
const TitleMessage = intl.formatMessage( { id: 'pages.condo.tls.title' })
const TitleMessage = intl.formatMessage({ id: 'pages.condo.tls.title' })
const DescriptionMessage = intl.formatMessage({ id: 'pages.condo.tls.description' })
const AlreadyHaveCertMessage = intl.formatMessage({ id: 'pages.condo.tls.poster.alreadyHaveCert' })
const Card1DescriptionMessage = intl.formatMessage({ id: 'pages.condo.tls.poster.card1.description' })
Expand Down Expand Up @@ -271,9 +270,9 @@ const TlsPagePoster: React.FC = (): JSX.Element => (
)

const TextWrapper = styled.div`
h3 {
color: ${colors.gray[7]};
}
h3 {
color: ${colors.gray[7]};
}
`

/**
Expand All @@ -285,30 +284,30 @@ const MarkdownWrapper = styled(TextWrapper)`
display: block;
max-width: 627px;
}

ol {
padding-left: 0;
list-style: none;
position: relative;
counter-reset: olCounter;

li {
padding-left: 2ex;
&:before {
counter-increment: olCounter;
content: counter(olCounter)".";
display: inline-block;
position: absolute;
left: 0;
}
&::marker {
display: none;
}
padding-left: 2ex;

&:before {
counter-increment: olCounter;
content: counter(olCounter) ".";
display: inline-block;
position: absolute;
left: 0;
}

&::marker {
display: none;
}
}
}

strong a {
display: inline-block;
border-radius: 8px;
Expand All @@ -323,8 +322,8 @@ const MarkdownWrapper = styled(TextWrapper)`
`

// Due to specifics of Ant implementation, only `Collapse.Panel` can be the children of `Collapse`.
function renderGuideSectionCollapse ( { name, guidesContent, intl }): JSX.Element {
const TitleMessage = intl.formatMessage( { id: `pages.condo.tls.guide.section.${name}.title` })
function renderGuideSectionCollapse ({ name, guidesContent, intl }): JSX.Element {
const TitleMessage = intl.formatMessage({ id: `pages.condo.tls.guide.section.${name}.title` })

return (
<Collapse.Panel
Expand All @@ -351,29 +350,29 @@ const StyledCollapse = styled(Collapse)`
flex-direction: column;
gap: 12px;
border: none;

.ant-collapse-item {
border: 1px solid #d9d9d9;
border-radius: 12px !important;
overflow: hidden;

&.ant-collapse-item-active {
.ant-collapse-content {
border-top: none;
border: 1px solid #d9d9d9;
border-radius: 12px !important;
overflow: hidden;

&.ant-collapse-item-active {
.ant-collapse-content {
border-top: none;
}
}
}

.ant-collapse-header {
padding: 24px !important;

.ant-collapse-expand-icon {
order: 2;
.ant-collapse-header {
padding: 24px !important;

.ant-collapse-expand-icon {
order: 2;

> .ant-collapse-arrow {
margin-right: 0 !important;
}
> .ant-collapse-arrow {
margin-right: 0 !important;
}
}
}
}
}
`

Expand All @@ -385,8 +384,8 @@ type TlsPageGuideProps = {

const TlsPageGuide: React.FC<TlsPageGuideProps> = ({ guidesContent }): JSX.Element => {
const intl = useIntl()
const TitleMessage = intl.formatMessage( { id: 'pages.condo.tls.guide.title' })
const DescriptionMessage = intl.formatMessage( { id: 'pages.condo.tls.guide.description' })
const TitleMessage = intl.formatMessage({ id: 'pages.condo.tls.guide.title' })
const DescriptionMessage = intl.formatMessage({ id: 'pages.condo.tls.guide.description' })

return (
<div id='guide'>
Expand Down Expand Up @@ -438,7 +437,7 @@ const TlsPage: PageComponentType<TlsPageProps> = ({ guidesContent }) => {
<Header/>
<Space direction='vertical' size={60}>
<TlsPagePoster/>
<TlsPageGuide guidesContent={guidesContent} />
<TlsPageGuide guidesContent={guidesContent}/>
<TlsPageEpilog/>
</Space>
</Space>
Expand All @@ -464,17 +463,15 @@ export const getServerSideProps: GetServerSideProps<Result> = async ({ req }) =>
const locale = localeIndex !== -1 ? Object.keys(LOCALES)[localeIndex] : defaultLocale
let guidesFolderPath = path.resolve(conf.PROJECT_ROOT, 'apps/condo', 'lang', locale, 'pages/tls')
if (!fs.existsSync(guidesFolderPath)) {
guidesFolderPath = path.resolve(conf.PROJECT_ROOT, 'apps/condo', 'lang', defaultLocale, 'pages/tls')
guidesFolderPath = path.resolve(conf.PROJECT_ROOT, 'apps/condo', 'lang', defaultLocale, 'pages/tls')
}
const fileNames = fs.readdirSync(guidesFolderPath)

// Parse list of files like ['android.md', 'ios.md', 'linux.md', 'macos.md', 'windows.md']
const guidesContent: GuidesContent = {}
for (const fileName of fileNames) {
const key = fileName.match(/^(\w+)\.md$/)[1]
const fileBuffer = fs.readFileSync(path.resolve(guidesFolderPath, fileName))
const { result: fileContent } = new ConvertToUTF8(fileBuffer).convert()
guidesContent[key] = fileContent
guidesContent[key] = fs.readFileSync(path.resolve(guidesFolderPath, fileName), 'utf-8')
}
return { props: { guidesContent } }
}
Expand Down
15 changes: 9 additions & 6 deletions bin/gptquery.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
// NOTE: based on python version: https://gist.github.com/pahaz/17c66fd6d75b74ff307aca2b6bf942f3
const crypto = require('crypto')
const fs = require('fs')
const path = require('path')

const fetch = require('node-fetch') // Import fetch from node-fetch
const fetch = require('node-fetch')

const conf = require('@open-condo/config')

const DEFAULT_OUTPUT_DIR = 'out'
// NOTE: Please don't use this pattern. It's just for backward compatibility (we will drip it soon)
const GPT_KEY_FILE = path.resolve(process.env.HOME, '.openai.key')
// NOTE: Please don't use this pattern. It's essential for us to prevent unnecessary expenses
const GPT_CACHE_DIR = path.resolve(process.env.HOME, '.openai.cache')

function cleanAndTrimText (text) {
return text.replace(/[\n\r\t\f\v]/g, ' ').split(/\s+/).join(' ').slice(0, 50).trim()
}

function loadApiKey () {
if (fs.existsSync(GPT_KEY_FILE)) {
if (conf.OPENAI_API_KEY) {
return conf.OPENAI_API_KEY.trim()
} else if (fs.existsSync(GPT_KEY_FILE)) {
return fs.readFileSync(GPT_KEY_FILE, 'utf-8').trim()
} else if (process.env.OPENAI_API_KEY) {
return process.env.OPENAI_API_KEY.trim()
} else {
throw new Error('API key file not found and OPENAI_API_KEY environment variable is not set.')
throw new Error('OPENAI_API_KEY is not found!')
}
}

Expand Down
Loading
Loading