From 46ff75acf52dccd2121e3844b2c841006e5e97a9 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 15 Nov 2024 14:04:22 +0300 Subject: [PATCH 01/37] feat: add getWord --- utils/helper.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/helper.js b/utils/helper.js index af99ac50..5b31e9a5 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -699,6 +699,26 @@ export const getWords = async ({ zip, repo, wordObjects }) => { return await Promise.all(promises) } +export const getWord = async ({ zip, repo, TWLink }) => { + if (!zip || !repo || !TWLink) { + return null + } + let uriMd = repo + '/bible/' + TWLink + uriMd = uriMd.replace('/../', '/') + + try { + const markdown = await zip.files[uriMd].async('string') + const splitter = markdown?.search('\n') + return { + title: markdown?.slice(0, splitter), + text: markdown?.slice(splitter), + } + } catch (error) { + console.error('Error fetching markdown:', error) + return null + } +} + export const stepValidation = (step) => { try { const obj = JSON.parse(JSON.stringify(step)) From 32af2e444e3a87c5ccf830b093bebe5472344002 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 15 Nov 2024 14:11:07 +0300 Subject: [PATCH 02/37] feat: add new parsing ref --- components/MarkdownExtended.js | 48 +++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/components/MarkdownExtended.js b/components/MarkdownExtended.js index 36fde654..c3e4319a 100644 --- a/components/MarkdownExtended.js +++ b/components/MarkdownExtended.js @@ -4,25 +4,59 @@ import remarkGfm from 'remark-gfm' import 'github-markdown-css/github-markdown-light.css' -function MarkdownExtended({ children, className }) { +function MarkdownExtended({ children, className, onLinkClick }) { const content = (typeof children === 'string' ? children : '') .replace(/< *br *\/?>/gi, '\n') .replaceAll('\\n', '\n') - const convertYoutube = (props) => { + const handleLinkClick = (href) => { + if (href.endsWith('.md')) { + onLinkClick?.(href) + } + } + + const parsingRef = (props) => { function getVideoID(userInput) { - var res = userInput.match( + const res = userInput.match( /^.*(?:(?:youtu.be\/)|(?:v\/)|(?:\/u\/\w\/)|(?:embed\/)|(?:watch\?))\??v?=?([^#\&\?]*).*/ ) - if (res) return res[1] - return false + return res ? res[1] : false + } + + if (props?.node?.properties?.href?.includes('translate')) { + return ( + { + e.preventDefault() + handleLinkClick(props?.node?.properties?.href) + }} + > + {props.children} + + ) } + + if (props.href.endsWith('.md')) { + return ( + { + e.preventDefault() + handleLinkClick(props.href) + }} + > + {props.children} + + ) + } + const youtubeId = getVideoID(props?.href) return youtubeId ? ( @@ -36,7 +70,7 @@ function MarkdownExtended({ children, className }) { rehypePlugins={[rehypeRaw]} className={className} components={{ - a: convertYoutube, + a: parsingRef, }} remarkPlugins={[remarkGfm]} > From 3ed98535f456904444519d5b1664aac8846ae5ec Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 15 Nov 2024 14:12:09 +0300 Subject: [PATCH 03/37] feat: add update TNTWLContent --- components/Panel/Resources/TWL.js | 32 +++++++++++++++++++++++++---- components/Panel/UI/TNTWLContent.js | 10 +++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/components/Panel/Resources/TWL.js b/components/Panel/Resources/TWL.js index afebf3c8..a7225829 100644 --- a/components/Panel/Resources/TWL.js +++ b/components/Panel/Resources/TWL.js @@ -6,13 +6,37 @@ import ReactMarkdown from 'react-markdown' import { Placeholder, TNTWLContent } from '../UI' import { getFile } from 'utils/apiHelper' -import { checkLSVal, filterNotes, getWords } from 'utils/helper' +import { checkLSVal, filterNotes, getWord, getWords } from 'utils/helper' import { useGetResource, useScroll } from 'utils/hooks' import Down from 'public/icons/arrow-down.svg' function TWL({ config, url, toolName }) { const [item, setItem] = useState(null) + const [href, setHref] = useState(null) + const [zip, setZip] = useState(null) + useEffect(() => { + const fetchWordData = async () => { + if (href && data.length > 0) { + const word = await getWord({ + zip, + repo: config.resource.repo.slice(0, -1).replace('obs-', ''), + TWLink: href, + }) + const newItem = { + title: word?.title || '', + text: word?.text || '', + } + + setItem(newItem) + } + } + + fetchWordData() + + // eslint-disable-next-line + }, [href, config.resource.repo]) + const { isLoading, data } = useGetResource({ config, url }) const [wordObjects, setWordObjects] = useState([]) const [isLoadingTW, setIsLoadingTW] = useState(false) @@ -25,6 +49,7 @@ function TWL({ config, url, toolName }) { commit: config.resource.commit, apiUrl: '/api/git/tw', }) + setZip(zip) const words = await getWords({ zip, repo: config.resource.repo.slice(0, -1).replace('obs-', ''), @@ -48,7 +73,7 @@ function TWL({ config, url, toolName }) { id: ID, title, text, - url: TWLink, + url: TWLink, // TODO уточнить где используется isRepeatedInBook, isRepeatedInChapter, isRepeatedInVerse, @@ -67,7 +92,7 @@ function TWL({ config, url, toolName }) { return ( <>
- + { return checkLSVal('filter_words', 'disabled', 'string') }) diff --git a/components/Panel/UI/TNTWLContent.js b/components/Panel/UI/TNTWLContent.js index 8c10d481..651f264f 100644 --- a/components/Panel/UI/TNTWLContent.js +++ b/components/Panel/UI/TNTWLContent.js @@ -4,7 +4,11 @@ import MarkdownExtended from 'components/MarkdownExtended' import Back from 'public/icons/left.svg' -function TNTWLContent({ setItem, item }) { +function TNTWLContent({ setItem, item, setHref }) { + const handleMdLinkClick = (href) => { + setHref(href) + } + return (
- {item?.text} + + {item?.text} +
) } From 74456ef213641289b52ed1f65331f6d8055013e4 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:11:15 +0300 Subject: [PATCH 04/37] feat: add transformHref and getWordsAcademy --- utils/helper.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/utils/helper.js b/utils/helper.js index 5b31e9a5..e1ee3017 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -676,6 +676,47 @@ export const validationBrief = (brief_data) => { return { error: null } } +const transformHref = (href) => { + if (href.startsWith('rc://')) { + const parts = href.slice(5).split('/') + return `${parts[0]}_${parts[1]}/${parts[3]}/${parts[4]}` + } + return href +} + +export const getWordsAcademy = async ({ zip, href }) => { + if (!zip || !href) { + console.error('The archive is not provided.') + return {} + } + const transformedHref = transformHref(href) + const targetFiles = [ + `${transformedHref}/title.md`, + `${transformedHref}/01.md`, + `${transformedHref}/sub-title.md`, + ] + + const results = await Promise.all( + targetFiles.map(async (filePath) => { + const file = zip.files[filePath] + if (!file) { + console.warn(`The ${filePath} file was not found.`) + return { path: filePath, content: null } + } + + const content = await file.async('text') + return { path: filePath, content } + }) + ) + + const fileObject = results.reduce((acc, { path, content }) => { + const key = path.split('/').pop().replace('.md', '') + acc[key] = content + return acc + }, {}) + return fileObject +} + export const getWords = async ({ zip, repo, wordObjects }) => { if (!zip || !repo || !wordObjects) { return [] From 1578118edfc78098ff7d4d3ecd27eacfa36e0fc1 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:28:04 +0300 Subject: [PATCH 05/37] feat: add show content ACdemy in TNotes --- components/MarkdownExtended.js | 40 +++++++++++--- components/Panel/Resources/TAContentInfo.js | 58 +++++++++++++++++++++ 2 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 components/Panel/Resources/TAContentInfo.js diff --git a/components/MarkdownExtended.js b/components/MarkdownExtended.js index c3e4319a..a381a0d5 100644 --- a/components/MarkdownExtended.js +++ b/components/MarkdownExtended.js @@ -4,14 +4,26 @@ import remarkGfm from 'remark-gfm' import 'github-markdown-css/github-markdown-light.css' -function MarkdownExtended({ children, className, onLinkClick }) { - const content = (typeof children === 'string' ? children : '') - .replace(/< *br *\/?>/gi, '\n') - .replaceAll('\\n', '\n') +import TaContentInfo from './Panel/Resources/TAContentInfo' + +function MarkdownExtended({ children, className, onLinkClick, config, setItem }) { + const convertRcLinksToMarkdownLinks = (text) => { + return text.replace(/\[\[(rc:\/\/\S+?)\]\]/g, (match, url) => `[${url}](${url})`) + } + + const content = convertRcLinksToMarkdownLinks( + (typeof children === 'string' ? children : '') + .replace(/< *br *\/?>/gi, '\n') + .replaceAll('\\n', '\n') + ) const handleLinkClick = (href) => { if (href.endsWith('.md')) { onLinkClick?.(href) + } else if (href.startsWith('rc://')) { + onLinkClick?.(href) + } else { + console.log(href, 16) } } @@ -23,13 +35,27 @@ function MarkdownExtended({ children, className, onLinkClick }) { return res ? res[1] : false } - if (props?.node?.properties?.href?.includes('translate')) { + const href = props?.node?.properties?.href + if (href?.includes('translate') && href.includes('ta')) { + return ( + + {props.children} + + ) + } + + if (href?.includes('translate')) { return ( { e.preventDefault() - handleLinkClick(props?.node?.properties?.href) + handleLinkClick(href) }} > {props.children} diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js new file mode 100644 index 00000000..9c230d86 --- /dev/null +++ b/components/Panel/Resources/TAContentInfo.js @@ -0,0 +1,58 @@ +import { useEffect, useState } from 'react' + +import { getFile } from 'utils/apiHelper' +import { getWordsAcademy } from 'utils/helper' + +function TaContentInfo({ href, config, setItem }) { + const [words, setWords] = useState(null) + const [isLoading, setIsLoading] = useState(true) + + useEffect(() => { + if (!config || !config.resource) { + console.error('Config object is missing or invalid.') + return + } + + const getData = async () => { + setIsLoading(true) + try { + const zip = await getFile({ + owner: config.resource.owner, + repo: config.resource.repo.slice(0, -2) + 'ta', + commit: config.resource.commit, + apiUrl: '/api/git/ta', + }) + const fetchedWords = await getWordsAcademy({ + zip, + href, + }) + setWords(fetchedWords) + } finally { + setIsLoading(false) + } + } + + getData() + }, [href, config]) + + if (isLoading) { + return Loading... + } + + const description = words?.['title'] || words?.title || href + const title = words?.['sub-title'] || words?.sub || href + const text = words?.['01'] || words?.['01'] || href + + return ( +
{ + e.preventDefault() + setItem?.({ title, text }) + }} + > + {description} +
+ ) +} +export default TaContentInfo From 9cad39b92fa9d4a1cb36784df605221c02488122 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:39:04 +0300 Subject: [PATCH 06/37] fix: edit getData from tWords --- components/Panel/Resources/TAContentInfo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js index 9c230d86..962d3345 100644 --- a/components/Panel/Resources/TAContentInfo.js +++ b/components/Panel/Resources/TAContentInfo.js @@ -18,7 +18,7 @@ function TaContentInfo({ href, config, setItem }) { try { const zip = await getFile({ owner: config.resource.owner, - repo: config.resource.repo.slice(0, -2) + 'ta', + repo: config.resource.repo.split('_')[0] + '_ta', commit: config.resource.commit, apiUrl: '/api/git/ta', }) @@ -45,7 +45,7 @@ function TaContentInfo({ href, config, setItem }) { return (
{ e.preventDefault() setItem?.({ title, text }) From 65755b1364c230d44fbaa674cd97a6f4cb4ecffc Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:39:34 +0300 Subject: [PATCH 07/37] feat: add api ta --- pages/api/git/ta.js | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 pages/api/git/ta.js diff --git a/pages/api/git/ta.js b/pages/api/git/ta.js new file mode 100644 index 00000000..c544d9ea --- /dev/null +++ b/pages/api/git/ta.js @@ -0,0 +1,51 @@ +import axios from 'axios' + +/** + * @swagger + * /api/git/ta: + * get: + * summary: Returns ta + * description: Returns ta + * parameters: + * - name: repo + * in: query + * description: code of repo + * required: true + * schema: + * type: string + * example: ru_ta + * - name: owner + * in: query + * description: owner + * required: true + * schema: + * type: string + * example: ru_gl + * tags: + * - git.door43 + * responses: + * '200': + * description: Returns ta in zip file + * + * '404': + * description: Bad request + */ + +export default async function taHandler(req, res) { + const { repo, owner, branch = 'master' } = req.query + const url = `${ + process.env.NODE_HOST ?? 'https://git.door43.org' + }/${owner}/${repo}/archive/${branch}.zip` + + try { + const response = await axios.get(url, { + responseType: 'arraybuffer', + }) + const zipBuffer = response.data + res.setHeader('Content-Type', 'application/zip') + res.setHeader('Content-Disposition', 'attachment; filename="archive.zip"') + return res.status(200).send(zipBuffer) + } catch (error) { + return res.status(404).json({ error }) + } +} From 34540a34a7f36a24487f3924d16ba4f04e0f8e81 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:42:03 +0300 Subject: [PATCH 08/37] feat: add config on props --- components/Panel/Resources/TN.js | 7 ++++++- components/Panel/Resources/TWL.js | 2 +- components/Panel/UI/TNTWLContent.js | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/Panel/Resources/TN.js b/components/Panel/Resources/TN.js index f7f8ff0c..54176441 100644 --- a/components/Panel/Resources/TN.js +++ b/components/Panel/Resources/TN.js @@ -50,7 +50,12 @@ function TN({ config, url, toolName }) { ) : (
{item ? ( - + ) : (
- + { setHref(href) } @@ -31,7 +31,12 @@ function TNTWLContent({ setItem, item, setHref }) { )}
- + {item?.text}
From 0d58893bf98b594865a362724035d01c99ca3a55 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 19 Nov 2024 18:43:13 +0300 Subject: [PATCH 09/37] fix: delete ResourcesList (unused) --- public/locales/ru/project-edit.json | 1 - 1 file changed, 1 deletion(-) diff --git a/public/locales/ru/project-edit.json b/public/locales/ru/project-edit.json index 1c4807b4..f19a411a 100644 --- a/public/locales/ru/project-edit.json +++ b/public/locales/ru/project-edit.json @@ -34,7 +34,6 @@ "RemovingCoordinator": "Удаление координатора", "RemovingModerator": "Удаление модератора", "RemovingTranslator": "Удаление переводчика", - "ResourcesList": "Список ресурсов", "Steps": "Шаги", "Summary": "Резюме", "Tools": "Инструменты", From 4f0dcd27dac91f4e3ac831711a4df97c743435bf Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 20 Nov 2024 10:30:20 +0300 Subject: [PATCH 10/37] feat: add contentRef and scrollTop = 0 --- components/Panel/UI/TNTWLContent.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/Panel/UI/TNTWLContent.js b/components/Panel/UI/TNTWLContent.js index 633e8ee2..137fba3a 100644 --- a/components/Panel/UI/TNTWLContent.js +++ b/components/Panel/UI/TNTWLContent.js @@ -1,3 +1,5 @@ +import React, { useEffect, useRef } from 'react' + import ReactMarkdown from 'react-markdown' import MarkdownExtended from 'components/MarkdownExtended' @@ -5,12 +7,21 @@ import MarkdownExtended from 'components/MarkdownExtended' import Back from 'public/icons/left.svg' function TNTWLContent({ setItem, item, setHref, config }) { + const contentRef = useRef(null) + + useEffect(() => { + if (contentRef.current) { + contentRef.current.scrollTop = 0 + } + }, [item]) + const handleMdLinkClick = (href) => { setHref(href) } return (
Date: Wed, 20 Nov 2024 15:52:03 +0300 Subject: [PATCH 11/37] feat: add click Back for other type content --- components/MarkdownExtended.js | 9 ++++--- components/Panel/Resources/TAContentInfo.js | 5 ++-- components/Panel/Resources/TN.js | 13 ++++++++-- components/Panel/Resources/TWL.js | 18 ++++++++++--- components/Panel/UI/TNTWLContent.js | 28 +++++++++++++++++---- 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/components/MarkdownExtended.js b/components/MarkdownExtended.js index a381a0d5..4016d98e 100644 --- a/components/MarkdownExtended.js +++ b/components/MarkdownExtended.js @@ -8,7 +8,12 @@ import TaContentInfo from './Panel/Resources/TAContentInfo' function MarkdownExtended({ children, className, onLinkClick, config, setItem }) { const convertRcLinksToMarkdownLinks = (text) => { - return text.replace(/\[\[(rc:\/\/\S+?)\]\]/g, (match, url) => `[${url}](${url})`) + if (!config?.resource?.repo) return text + const locale = config.resource.repo.split('_')[0] + + return text + .replace(/\*/g, locale) + .replace(/\[\[(rc:\/\/\S+?)\]\]/g, (_, url) => `[${url}](${url})`) } const content = convertRcLinksToMarkdownLinks( @@ -22,8 +27,6 @@ function MarkdownExtended({ children, className, onLinkClick, config, setItem }) onLinkClick?.(href) } else if (href.startsWith('rc://')) { onLinkClick?.(href) - } else { - console.log(href, 16) } } diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js index 962d3345..ad41fb0c 100644 --- a/components/Panel/Resources/TAContentInfo.js +++ b/components/Panel/Resources/TAContentInfo.js @@ -42,13 +42,14 @@ function TaContentInfo({ href, config, setItem }) { const description = words?.['title'] || words?.title || href const title = words?.['sub-title'] || words?.sub || href const text = words?.['01'] || words?.['01'] || href + const type = 'ta' return (
{ e.preventDefault() - setItem?.({ title, text }) + setItem?.({ title, text, type }) }} > {description} diff --git a/components/Panel/Resources/TN.js b/components/Panel/Resources/TN.js index 54176441..6de1d36e 100644 --- a/components/Panel/Resources/TN.js +++ b/components/Panel/Resources/TN.js @@ -12,6 +12,7 @@ import { useGetResource, useScroll } from 'utils/hooks' function TN({ config, url, toolName }) { const [item, setItem] = useState(null) + const [parentItem, setParentItem] = useState(null) const [tnotes, setTnotes] = useState([]) const { isLoading, data } = useGetResource({ config, url }) const { extraTNotes, setTnotes: updateTnotes } = useQuotesTranslation({ @@ -53,12 +54,14 @@ function TN({ config, url, toolName }) { ) : ( { handleSaveScroll(verseNumber, note.ID) + setParentItem({ + text: note.Note, + title: note.Quote || note.origQuote, + type: 'tn', + }) setItem({ text: note.Note, title: note.Quote || note.origQuote, + type: 'tn', }) }} > diff --git a/components/Panel/Resources/TWL.js b/components/Panel/Resources/TWL.js index 001a6a37..1e3cf755 100644 --- a/components/Panel/Resources/TWL.js +++ b/components/Panel/Resources/TWL.js @@ -13,6 +13,8 @@ import Down from 'public/icons/arrow-down.svg' function TWL({ config, url, toolName }) { const [item, setItem] = useState(null) + const [parentItem, setParentItem] = useState(null) + const [href, setHref] = useState(null) const [zip, setZip] = useState(null) useEffect(() => { @@ -26,6 +28,7 @@ function TWL({ config, url, toolName }) { const newItem = { title: word?.title || '', text: word?.text || '', + type: 'tw', } setItem(newItem) @@ -92,9 +95,17 @@ function TWL({ config, url, toolName }) { return ( <>
- + { return checkLSVal('filter_words', 'disabled', 'string') @@ -173,7 +184,8 @@ function TWLList({ setItem, data, toolName, isLoading }) { } hover:bg-th-secondary-100 ${highlightId === 'id' + item.id ? 'bg-th-secondary-100' : ''} `} onClick={() => { handleSaveScroll(verseNumber, item.id) - setItem({ text: item.text, title: item.title }) + setParentItem(item) + setItem({ text: item.text, title: item.title, type: 'twl' }) }} > {item.title} diff --git a/components/Panel/UI/TNTWLContent.js b/components/Panel/UI/TNTWLContent.js index 137fba3a..5070ee91 100644 --- a/components/Panel/UI/TNTWLContent.js +++ b/components/Panel/UI/TNTWLContent.js @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from 'react' +import React, { useEffect, useRef, useState } from 'react' import ReactMarkdown from 'react-markdown' @@ -6,17 +6,35 @@ import MarkdownExtended from 'components/MarkdownExtended' import Back from 'public/icons/left.svg' -function TNTWLContent({ setItem, item, setHref, config }) { +function TNTWLContent({ setItem, item, parentItem, setParentItem, setHref, config }) { const contentRef = useRef(null) useEffect(() => { if (contentRef.current) { contentRef.current.scrollTop = 0 } - }, [item]) + }, [item, parentItem]) const handleMdLinkClick = (href) => { - setHref(href) + if (setHref) { + setHref(href) + } + } + + const handleBackClick = () => { + if (item.type === 'ta' || item.type === 'tw') { + setItem(parentItem) + setParentItem(null) + if (setHref) { + setHref(null) + } + } else { + setItem(null) + setParentItem(null) + if (setHref) { + setHref(null) + } + } } return ( @@ -29,7 +47,7 @@ function TNTWLContent({ setItem, item, setHref, config }) {
setItem(null)} + onClick={handleBackClick} >
From d36d6df07f30986c218b9d6a2e1c2f15ec3f7ea0 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 11:12:44 +0300 Subject: [PATCH 12/37] feat: add show tAcademy in sidebar --- components/SideBar.js | 47 +++++++++++++++++++++++++++++++++++++++ components/state/atoms.js | 1 + 2 files changed, 48 insertions(+) diff --git a/components/SideBar.js b/components/SideBar.js index 2895352b..b2c032b3 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -13,6 +13,7 @@ import AboutProject from './AboutProject' import AvatarSelector from './AvatarSelector' import ModalInSideBar from './ModalInSideBar' import { PersonalNotes } from './Panel' +import TaTopics from './Panel/UI/TaTopics' import ProjectCreate from './ProjectCreate' import SignOut from './SignOut' import { modalsSidebar } from './state/atoms' @@ -58,6 +59,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { aboutVersion: modalType === 'aboutVersion' ? !prevModals.aboutVersion : false, avatarSelector: modalType === 'avatarSelector' ? !prevModals.avatarSelector : false, notepad: modalType === 'notepad' ? !prevModals.notepad : false, + tAcademy: modalType === 'tAcademy' ? !prevModals.tAcademy : false, })) } @@ -66,6 +68,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { aboutVersion: false, avatarSelector: false, notepad: false, + tAcademy: false, }) } @@ -134,6 +137,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { modalsSidebarState.notepad || modalsSidebarState.aboutVersion || modalsSidebarState.avatarSelector || + modalsSidebarState.tAcademy || showAbout ) { return @@ -381,6 +385,49 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) {
+ +
{ + openModal('tAcademy') + setShowAbout(false) + }} + > +
+ +
+ { + setModalsSidebarState((prev) => ({ + ...prev, + tAcademy: value, + })) + setCollapsed(!value) + setIsOpenSideBar(value) + }} + modalTitle={t('academyArticles')} + buttonTitle={t('academyArticles')} + collapsed={collapsed} + > + + +
+
{user?.is_admin && ( Date: Tue, 26 Nov 2024 11:27:31 +0300 Subject: [PATCH 13/37] feat: add TAContent --- components/Panel/UI/TAContent.js | 44 ++++++++++++++++++++++++++++++++ components/Panel/UI/index.js | 1 + 2 files changed, 45 insertions(+) create mode 100644 components/Panel/UI/TAContent.js diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js new file mode 100644 index 00000000..135fc604 --- /dev/null +++ b/components/Panel/UI/TAContent.js @@ -0,0 +1,44 @@ +import ReactMarkdown from 'react-markdown' + +import MarkdownExtended from 'components/MarkdownExtended' + +function TAContent({ item, setHref, config }) { + const handleMdLinkClick = (href) => { + if (setHref) { + setHref(href) + } + } + + return ( +
+
+
+ {!['intro', 'front'].includes(item?.title) && ( +
+ + {item?.title} + +
+ )} +
+ +
+ + {item?.text} + +
+
+
+ ) +} + +export default TAContent diff --git a/components/Panel/UI/index.js b/components/Panel/UI/index.js index ed0a5199..cbfb4633 100644 --- a/components/Panel/UI/index.js +++ b/components/Panel/UI/index.js @@ -1,3 +1,4 @@ export { default as Placeholder } from './Placeholder' export { default as AutoSizeTextArea } from './AutoSizeTextArea' export { default as TNTWLContent } from './TNTWLContent' +export { default as TAContent } from './TAContent' From ce1184a666fc169c70a7a5c90c7055d707afc042 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 13:29:55 +0300 Subject: [PATCH 14/37] feat: add show croff-reference tA --- components/Panel/Resources/TN.js | 42 +++++++++++++++++++++++++- components/Panel/Resources/TWL.js | 49 +++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 13 deletions(-) diff --git a/components/Panel/Resources/TN.js b/components/Panel/Resources/TN.js index 6de1d36e..eab89f5d 100644 --- a/components/Panel/Resources/TN.js +++ b/components/Panel/Resources/TN.js @@ -7,11 +7,14 @@ import { useQuotesTranslation } from '@texttree/tn-quote' import { Placeholder, TNTWLContent } from '../UI' -import { filterNotes } from 'utils/helper' +import { getFile } from 'utils/apiHelper' +import { filterNotes, getWordsAcademy } from 'utils/helper' import { useGetResource, useScroll } from 'utils/hooks' function TN({ config, url, toolName }) { const [item, setItem] = useState(null) + const [href, setHref] = useState(null) + const [parentItem, setParentItem] = useState(null) const [tnotes, setTnotes] = useState([]) const { isLoading, data } = useGetResource({ config, url }) @@ -29,6 +32,42 @@ function TN({ config, url, toolName }) { config.mainResource.repo, }, }) + + useEffect(() => { + const fetchWordData = async () => { + if (href && data.length > 0) { + if (href?.includes('-')) { + const result = href.split('/')[1] + const zip = await getFile({ + owner: config.resource.owner, + repo: config.resource.repo.split('_')[0] + '_ta', + commit: config.resource.commit, + apiUrl: '/api/git/ta', + }) + + const hrefNew = `rc://${config.resource.repo.split('_')[0]}/ta/man/translate/${result}` + const fetchedWords = await getWordsAcademy({ + zip, + href: hrefNew, + }) + const title = fetchedWords?.['sub-title'] || fetchedWords?.sub || href + const text = fetchedWords?.['01'] || href + const type = 'ta' + const item = { + title, + text, + type, + } + setItem?.(item) + } + } + } + + fetchWordData() + + // eslint-disable-next-line + }, [href, config.resource.repo]) + useEffect(() => { if (extraTNotes) { const _data = [] @@ -56,6 +95,7 @@ function TN({ config, url, toolName }) { item={item} parentItem={parentItem} setParentItem={setParentItem} + setHref={setHref} config={config} /> ) : ( diff --git a/components/Panel/Resources/TWL.js b/components/Panel/Resources/TWL.js index 1e3cf755..540ad4e7 100644 --- a/components/Panel/Resources/TWL.js +++ b/components/Panel/Resources/TWL.js @@ -6,7 +6,7 @@ import ReactMarkdown from 'react-markdown' import { Placeholder, TNTWLContent } from '../UI' import { getFile } from 'utils/apiHelper' -import { checkLSVal, filterNotes, getWord, getWords } from 'utils/helper' +import { checkLSVal, filterNotes, getWord, getWords, getWordsAcademy } from 'utils/helper' import { useGetResource, useScroll } from 'utils/hooks' import Down from 'public/icons/arrow-down.svg' @@ -20,18 +20,43 @@ function TWL({ config, url, toolName }) { useEffect(() => { const fetchWordData = async () => { if (href && data.length > 0) { - const word = await getWord({ - zip, - repo: config.resource.repo.slice(0, -1).replace('obs-', ''), - TWLink: href, - }) - const newItem = { - title: word?.title || '', - text: word?.text || '', - type: 'tw', - } + if (href?.includes('-')) { + const result = href.split('/')[1] + const zip = await getFile({ + owner: config.resource.owner, + repo: config.resource.repo.split('_')[0] + '_ta', + commit: config.resource.commit, + apiUrl: '/api/git/ta', + }) - setItem(newItem) + const hrefNew = `rc://${config.resource.repo.split('_')[0]}/ta/man/translate/${result}` + const fetchedWords = await getWordsAcademy({ + zip, + href: hrefNew, + }) + const title = fetchedWords?.['sub-title'] || fetchedWords?.sub || href + const text = fetchedWords?.['01'] || href + const type = 'ta' + const item = { + title, + text, + type, + } + setItem?.(item) + } else { + const word = await getWord({ + zip, + repo: config.resource.repo.slice(0, -1).replace('obs-', ''), + TWLink: href, + }) + const newItem = { + title: word?.title || '', + text: word?.text || '', + type: 'tw', + } + + setItem(newItem) + } } } From b2f4ee0093c39d3544111ea5bf0bd37291755293 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 13:57:46 +0300 Subject: [PATCH 15/37] fix: delete handleMdLinkClick --- components/Panel/UI/TNTWLContent.js | 10 +--- components/Panel/UI/TaTopics.js | 78 +++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 components/Panel/UI/TaTopics.js diff --git a/components/Panel/UI/TNTWLContent.js b/components/Panel/UI/TNTWLContent.js index 5070ee91..18f7b538 100644 --- a/components/Panel/UI/TNTWLContent.js +++ b/components/Panel/UI/TNTWLContent.js @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useRef } from 'react' import ReactMarkdown from 'react-markdown' @@ -15,12 +15,6 @@ function TNTWLContent({ setItem, item, parentItem, setParentItem, setHref, confi } }, [item, parentItem]) - const handleMdLinkClick = (href) => { - if (setHref) { - setHref(href) - } - } - const handleBackClick = () => { if (item.type === 'ta' || item.type === 'tw') { setItem(parentItem) @@ -62,7 +56,7 @@ function TNTWLContent({ setItem, item, parentItem, setParentItem, setHref, confi diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js new file mode 100644 index 00000000..a1cdba2f --- /dev/null +++ b/components/Panel/UI/TaTopics.js @@ -0,0 +1,78 @@ +import { useEffect, useState } from 'react' + +import { useTranslation } from 'next-i18next' + +import TaContentInfo from '../Resources/TAContentInfo' +import TAContent from './TAContent' + +import { getFile } from 'utils/apiHelper' +import { getWordsAcademy, resolvePath } from 'utils/helper' + +function TaTopics() { + const base = 'rc://ru/ta/man' + const [href, setHref] = useState('intro/ta-intro') + const [item, setItem] = useState(null) + + const updateHref = (newRelativePath) => { + const { absolutePath } = resolvePath(base, href, newRelativePath) + setHref(absolutePath.replace(base + '/', '')) + } + + useEffect(() => { + const getData = async () => { + const zip = await getFile({ + owner: config.resource.owner, + repo: config.resource.repo.split('_')[0] + '_ta', + commit: config.resource.commit, + apiUrl: '/api/git/ta', + }) + + const fetchedWords = await getWordsAcademy({ + zip, + href: `${base}/${href}`, + }) + + const title = fetchedWords?.['sub-title'] || href + const text = fetchedWords?.['01'] || href + const item = { + title, + text, + type: 'ta', + } + setItem?.(item) + } + + getData() + }, [href]) + + const { t } = useTranslation(['common', 'error']) + + const config = { + resource: { + repo: 'ru_tn', + owner: 'ru_gl', + }, + } + + return ( +
+
+ updateHref(newRelativePath)} + setItem={setItem} + parentItem={item} + /> +
+ +
+ ) +} + +export default TaTopics From a4b0b5fcd6b19cc42742f64a6ba35a55e702fab4 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 13:58:33 +0300 Subject: [PATCH 16/37] feat: add resolvePath --- utils/helper.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/utils/helper.js b/utils/helper.js index e1ee3017..a34e6a51 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -933,3 +933,28 @@ export const getImageUrl = (imageUrl) => { } return '' } + +export function resolvePath(base, currentPath, relativePath) { + let absolutePath = currentPath.startsWith('/') ? currentPath : `/${currentPath}` + const relativeParts = relativePath.split('/') + + if (relativeParts.length && relativeParts[relativeParts.length - 1].includes('.')) { + relativeParts.pop() + } + + const absoluteParts = absolutePath.split('/').filter(Boolean) + + relativeParts.forEach((segment) => { + if (segment === '..') { + absoluteParts.pop() + } else if (segment && segment !== '.') { + absoluteParts.push(segment) + } + }) + + absolutePath = `${base}/${absoluteParts.join('/')}` + + const updatedCurrentPath = `/${absoluteParts.join('/')}` + + return { absolutePath, updatedCurrentPath } +} From 6b3b8506d66eef1d82c67508582238351287fd58 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 13:58:55 +0300 Subject: [PATCH 17/37] fix: edit replace */ --- components/MarkdownExtended.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/MarkdownExtended.js b/components/MarkdownExtended.js index 4016d98e..0c4f4981 100644 --- a/components/MarkdownExtended.js +++ b/components/MarkdownExtended.js @@ -10,9 +10,8 @@ function MarkdownExtended({ children, className, onLinkClick, config, setItem }) const convertRcLinksToMarkdownLinks = (text) => { if (!config?.resource?.repo) return text const locale = config.resource.repo.split('_')[0] - return text - .replace(/\*/g, locale) + .replace(/\*\//g, locale + '/') .replace(/\[\[(rc:\/\/\S+?)\]\]/g, (_, url) => `[${url}](${url})`) } From 0c386ead0642a7029f17a9516084c41ee7516eb9 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 13:59:57 +0300 Subject: [PATCH 18/37] feat: add goBack for TA --- components/Panel/Resources/TAContentInfo.js | 36 +++++++++++++++------ components/Panel/UI/TAContent.js | 18 ++++++++--- components/Panel/UI/TaTopics.js | 12 +++++++ 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js index ad41fb0c..f8d2867c 100644 --- a/components/Panel/Resources/TAContentInfo.js +++ b/components/Panel/Resources/TAContentInfo.js @@ -1,11 +1,12 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { getFile } from 'utils/apiHelper' import { getWordsAcademy } from 'utils/helper' -function TaContentInfo({ href, config, setItem }) { +function TaContentInfo({ href, config, setItem, returnImmediately = false }) { const [words, setWords] = useState(null) const [isLoading, setIsLoading] = useState(true) + const hrefRef = useRef(href) useEffect(() => { if (!config || !config.resource) { @@ -24,32 +25,49 @@ function TaContentInfo({ href, config, setItem }) { }) const fetchedWords = await getWordsAcademy({ zip, - href, + href: hrefRef.current, }) setWords(fetchedWords) + + if (returnImmediately) { + const title = + fetchedWords?.['sub-title'] || fetchedWords?.sub || hrefRef.current + const text = fetchedWords?.['01'] || hrefRef.current + const item = { + title, + text, + type: 'ta', + } + setItem?.(item) + } } finally { setIsLoading(false) } } getData() - }, [href, config]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [returnImmediately, setItem]) if (isLoading) { return Loading... } - const description = words?.['title'] || words?.title || href - const title = words?.['sub-title'] || words?.sub || href - const text = words?.['01'] || words?.['01'] || href - const type = 'ta' + const description = words?.['title'] || words?.title || hrefRef.current + const title = words?.['sub-title'] || words?.sub || hrefRef.current + const text = words?.['01'] || hrefRef.current + const item = { title, text, type: 'ta' } + + if (returnImmediately) { + return null + } return (
{ e.preventDefault() - setItem?.({ title, text, type }) + setItem?.(item) }} > {description} diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js index 135fc604..8538b7a8 100644 --- a/components/Panel/UI/TAContent.js +++ b/components/Panel/UI/TAContent.js @@ -2,10 +2,12 @@ import ReactMarkdown from 'react-markdown' import MarkdownExtended from 'components/MarkdownExtended' -function TAContent({ item, setHref, config }) { - const handleMdLinkClick = (href) => { - if (setHref) { - setHref(href) +import Back from 'public/icons/left.svg' + +function TAContent({ item, setHref, config, goBack }) { + const handleBackClick = () => { + if (goBack) { + goBack() } } @@ -17,6 +19,12 @@ function TAContent({ item, setHref, config }) { >
+
+ +
{!['intro', 'front'].includes(item?.title) && (
@@ -29,7 +37,7 @@ function TAContent({ item, setHref, config }) {
diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index a1cdba2f..e206dc56 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -12,12 +12,23 @@ function TaTopics() { const base = 'rc://ru/ta/man' const [href, setHref] = useState('intro/ta-intro') const [item, setItem] = useState(null) + const [history, setHistory] = useState([]) const updateHref = (newRelativePath) => { const { absolutePath } = resolvePath(base, href, newRelativePath) + setHistory((prev) => [...prev, href]) setHref(absolutePath.replace(base + '/', '')) } + const goBack = () => { + setHistory((prev) => { + const newHistory = [...prev] + const lastHref = newHistory.pop() + if (lastHref) setHref(lastHref) + return newHistory + }) + } + useEffect(() => { const getData = async () => { const zip = await getFile({ @@ -62,6 +73,7 @@ function TaTopics() { config={config} setHref={(newRelativePath) => updateHref(newRelativePath)} setItem={setItem} + goBack={goBack} parentItem={item} />
From 23ad6db40283c6fa509cff56f8ac9dd72645913c Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 14:15:15 +0300 Subject: [PATCH 19/37] feat: add scrollRef --- components/Panel/UI/TaTopics.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index e206dc56..cf9e1275 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'next-i18next' @@ -13,6 +13,7 @@ function TaTopics() { const [href, setHref] = useState('intro/ta-intro') const [item, setItem] = useState(null) const [history, setHistory] = useState([]) + const scrollRef = useRef(null) const updateHref = (newRelativePath) => { const { absolutePath } = resolvePath(base, href, newRelativePath) @@ -56,6 +57,15 @@ function TaTopics() { getData() }, [href]) + useEffect(() => { + if (scrollRef.current) { + const firstChild = scrollRef.current.firstElementChild + if (firstChild) { + firstChild.scrollIntoView({ behavior: 'auto', block: 'start' }) + } + } + }, [item]) + const { t } = useTranslation(['common', 'error']) const config = { @@ -67,7 +77,7 @@ function TaTopics() { return (
-
+
Date: Tue, 26 Nov 2024 15:11:15 +0300 Subject: [PATCH 20/37] feat: add academyLinks --- components/Panel/UI/TaTopics.js | 25 ++++++++++--------------- utils/config.js | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index cf9e1275..39bf201c 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -1,24 +1,28 @@ import { useEffect, useRef, useState } from 'react' -import { useTranslation } from 'next-i18next' +import { useRouter } from 'next/router' import TaContentInfo from '../Resources/TAContentInfo' import TAContent from './TAContent' import { getFile } from 'utils/apiHelper' +import { academyLinks } from 'utils/config' import { getWordsAcademy, resolvePath } from 'utils/helper' function TaTopics() { - const base = 'rc://ru/ta/man' + const { locale } = useRouter() + + const config = academyLinks[locale] || academyLinks['en'] + const [href, setHref] = useState('intro/ta-intro') const [item, setItem] = useState(null) const [history, setHistory] = useState([]) const scrollRef = useRef(null) const updateHref = (newRelativePath) => { - const { absolutePath } = resolvePath(base, href, newRelativePath) + const { absolutePath } = resolvePath(config.base, href, newRelativePath) setHistory((prev) => [...prev, href]) - setHref(absolutePath.replace(base + '/', '')) + setHref(absolutePath.replace(config.base + '/', '')) } const goBack = () => { @@ -41,7 +45,7 @@ function TaTopics() { const fetchedWords = await getWordsAcademy({ zip, - href: `${base}/${href}`, + href: `${config.base}/${href}`, }) const title = fetchedWords?.['sub-title'] || href @@ -55,7 +59,7 @@ function TaTopics() { } getData() - }, [href]) + }, [href, config.base, config.resource]) useEffect(() => { if (scrollRef.current) { @@ -66,15 +70,6 @@ function TaTopics() { } }, [item]) - const { t } = useTranslation(['common', 'error']) - - const config = { - resource: { - repo: 'ru_tn', - owner: 'ru_gl', - }, - } - return (
diff --git a/utils/config.js b/utils/config.js index 2f6b224c..e1355492 100644 --- a/utils/config.js +++ b/utils/config.js @@ -258,3 +258,27 @@ export const bookChapters = { rev: 22, obs: 50, } + +export const academyLinks = { + ru: { + resource: { + repo: 'ru_tn', + owner: 'ru_gl', + }, + base: 'rc://ru/ta/man', + }, + en: { + resource: { + repo: 'en_tn', + owner: 'unfoldingWord', + }, + base: 'rc://en/ta/man', + }, + es: { + resource: { + repo: 'es_tn', + owner: 'es_gl', + }, + base: 'rc://es/ta/man', + }, +} From f4ca4f24526611dd18a566b5fe9a48599fc3075f Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:18:05 +0300 Subject: [PATCH 21/37] feat: add AcademicCap svg --- components/SideBar.js | 3 ++- public/icons/academicCap.svg | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 public/icons/academicCap.svg diff --git a/components/SideBar.js b/components/SideBar.js index b2c032b3..00709726 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -24,6 +24,7 @@ import TranslatorImage from './TranslatorImage' import { useCurrentUser } from 'lib/UserContext' import About from 'public/icons/about.svg' +import AcademicCap from 'public/icons/academicCap.svg' import Account from 'public/icons/account.svg' import Burger from 'public/icons/burger.svg' import Camera from 'public/icons/camera.svg' @@ -402,7 +403,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { }} >
- + + From 890f7d11307789b7d60ad0afacb64aa00406c83d Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:35:39 +0300 Subject: [PATCH 22/37] fix: delete academyLinks for es --- utils/config.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/utils/config.js b/utils/config.js index e1355492..af07fd76 100644 --- a/utils/config.js +++ b/utils/config.js @@ -274,11 +274,4 @@ export const academyLinks = { }, base: 'rc://en/ta/man', }, - es: { - resource: { - repo: 'es_tn', - owner: 'es_gl', - }, - base: 'rc://es/ta/man', - }, } From 371628132d272ec26111918a4e506d38e0652cce Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:36:14 +0300 Subject: [PATCH 23/37] fix: select academyLinks for others lang --- components/Panel/UI/TaTopics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index 39bf201c..b0a0afeb 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -12,7 +12,7 @@ import { getWordsAcademy, resolvePath } from 'utils/helper' function TaTopics() { const { locale } = useRouter() - const config = academyLinks[locale] || academyLinks['en'] + const config = locale === 'ru' ? academyLinks['ru'] : academyLinks['en'] const [href, setHref] = useState('intro/ta-intro') const [item, setItem] = useState(null) From 7ffbca50e75ba0b5cc8dfecfdb9f7aa661a5ad6b Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:36:35 +0300 Subject: [PATCH 24/37] feat: add locales translationAcademy --- components/SideBar.js | 4 ++-- public/locales/en/common.json | 19 ++++++++++--------- public/locales/es/common.json | 19 ++++++++++--------- public/locales/ru/common.json | 19 ++++++++++--------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/components/SideBar.js b/components/SideBar.js index 00709726..e2ef11a3 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -421,8 +421,8 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { setCollapsed(!value) setIsOpenSideBar(value) }} - modalTitle={t('academyArticles')} - buttonTitle={t('academyArticles')} + modalTitle={t('translationAcademy')} + buttonTitle={t('translationAcademy')} collapsed={collapsed} > diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 1a26420e..b4dfdbcf 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -1,6 +1,8 @@ { + "About": "About", "AboutStep": "About step", "AboutTranslation": "About translation", + "Account": "Account", "Added": "Add", "AddWord": "Add word", "AllNotes": "All notes", @@ -46,6 +48,7 @@ "Create": "Create", "CreateBook": "Create a book", "CreateFailed": "Creation Error", + "CreateProject": "Create project", "Delete": "Delete", "Description": "Description", "DescriptionConfession": "consistent with the historical symbols of faith:
The Apostolic Creed, the Nicene Creed, and the Athanasian Creed; as well as the Lausanne Covenant.", @@ -85,7 +88,10 @@ "info": "Info", "intro": "Introduction to the chapter", "IntroStep": "Intro", + "Language": "Language", + "LEVEL": "LEVEL", "LevelChecks": "Verification levels", + "LEVELLanguages": "Languages of the LEVEL", "LevelTranslationChecks": "Levels of translation verification", "ListResources": "List of resources", "Loading": "Loading", @@ -117,6 +123,7 @@ "personalNotes": "Personal notes", "PlatformForBibleTranslate": "Guided Bible translation platform", "Progress": "Progress", + "Projects": "Projects", "ProjectSettings": "Project settings", "Properties": "Properties", "Questions": "Questions", @@ -146,6 +153,7 @@ "Step": "Step", "StudyNotes": "Study Notes", "Subtitle": "Subtitle", + "Symbols": "Symbols", "TableOfContents": "Table Of Contents", "teamNotes": "Team notes", "TextDescriptionWord": "Write the meaning of the word", @@ -155,6 +163,7 @@ "tquestions": "tQuestions", "Training": "Training", "translate": "Editor", + "translationAcademy": "Translation Academy", "TranslationGoal": "The purpose of the translation", "TranslationLink": "Link to the translation", "Translator": "Translator", @@ -165,8 +174,6 @@ "Upload": "Upload", "UploadAvatar": "Upload avatar", "UploadFailed": "Upload failed", - "LEVEL": "LEVEL", - "LEVELLanguages": "Languages of the LEVEL", "Ver": "ver", "Verse": "Verse", "Verse_few": "{{count}} verses", @@ -184,11 +191,5 @@ "WithoutImages": "Without images", "WordExist": "Duplicated word exists:", "WrongResource": "Wrong resource", - "Yes": "Yes", - "Symbols": "Symbols", - "Account": "Account", - "Projects": "Projects", - "CreateProject": "Create project", - "About": "About", - "Language": "Language" + "Yes": "Yes" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 573d5cd2..9b48cd32 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -1,6 +1,8 @@ { + "About": "Sobre el proyecto", "AboutStep": "Acerca del paso", "AboutTranslation": "Acerca de la traducción", + "Account": "Cuenta", "Added": "Add", "AddWord": "Añada palabra", "AllNotes": "All notes", @@ -46,6 +48,7 @@ "Create": "Create", "CreateBook": "Create a book", "CreateFailed": "Creation Error", + "CreateProject": "Crear un proyecto", "Delete": "Eliminar", "Description": "Descripción", "DescriptionConfession": "consistent with the historical symbols of faith:
The Apostolic Creed, the Nicene Creed, and the Athanasian Creed; as well as the Lausanne Covenant.", @@ -85,7 +88,10 @@ "info": "Info", "intro": "Intro", "IntroStep": "Intro", + "Language": "Idioma", + "LEVEL": "LEVEL", "LevelChecks": "Niveles de verificación", + "LEVELLanguages": "Languages of the LEVEL", "LevelTranslationChecks": "Niveles de verificación de traducción", "ListResources": "List of resources", "Loading": "Loading", @@ -117,6 +123,7 @@ "personalNotes": "Personal notes", "PlatformForBibleTranslate": "Plataforma de traducción bíblica guiada", "Progress": "Progress", + "Projects": "Proyectos", "ProjectSettings": "Project settings", "Properties": "Properties", "Questions": "Questions", @@ -146,6 +153,7 @@ "Step": "Step", "StudyNotes": "Study Notes", "Subtitle": "Subtítulo", + "Symbols": "Símbolos", "TableOfContents": "Tabla de contenido", "teamNotes": "Team notes", "TextDescriptionWord": "Write the meaning of the word", @@ -155,6 +163,7 @@ "tquestions": "tQuestions", "Training": "Training", "translate": "Editor", + "translationAcademy": "Academia de traducción", "TranslationGoal": "The purpose of the translation", "TranslationLink": "Enlace a la traducción", "Translator": "Traductor", @@ -165,8 +174,6 @@ "Upload": "Subir", "UploadAvatar": "Subir avatar", "UploadFailed": "No subir", - "LEVEL": "LEVEL", - "LEVELLanguages": "Languages of the LEVEL", "Ver": "ver", "Verse": "Verso", "Verse_few": "{{count}} versículos", @@ -184,11 +191,5 @@ "WithoutImages": "Without images", "WordExist": "Duplicated word exists:", "WrongResource": "Wrong resource", - "Yes": "Yes", - "Symbols": "Símbolos", - "Account": "Cuenta", - "Projects": "Proyectos", - "CreateProject": "Crear un proyecto", - "About": "Sobre el proyecto", - "Language": "Idioma" + "Yes": "Yes" } diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 2b33b933..1253578a 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -1,6 +1,8 @@ { + "About": "О проекте", "AboutStep": "О шаге", "AboutTranslation": "О переводе", + "Account": "Аккаунт", "Added": "Добавить", "AddWord": "Добавить слово", "AllNotes": "Все заметки", @@ -46,6 +48,7 @@ "Create": "Создать", "CreateBook": "Создать книгу", "CreateFailed": "Ошибка при создании", + "CreateProject": "Создать проект", "Delete": "Удалить", "Description": "Описание", "DescriptionConfession": "согласуется с историческими символами веры:
Апостольский символ веры, Никейский символ веры, и Афанасьевский символ веры; а также Lausanne Covenant.", @@ -85,7 +88,10 @@ "info": "Инфо", "intro": "Введение в главу", "IntroStep": "Введение", + "Language": "Язык", + "LEVEL": "LEVEL", "LevelChecks": "Уровни проверки", + "LEVELLanguages": "LEVEL языки", "LevelTranslationChecks": "Уровни проверки перевода", "ListResources": "Список ресурсов", "Loading": "Загрузка", @@ -117,6 +123,7 @@ "personalNotes": "Блокнот", "PlatformForBibleTranslate": "Платформа для пошагового перевода Библии", "Progress": "Прогресс", + "Projects": "Проекты", "ProjectSettings": "Настройки проекта", "Properties": "Свойства", "Questions": "Вопросы", @@ -146,6 +153,7 @@ "Step": "Шаг", "StudyNotes": "Study Notes", "Subtitle": "Подзаголовок", + "Symbols": "Символы", "TableOfContents": "Содержание", "teamNotes": "Тимнот", "TextDescriptionWord": "Напишите значение слова", @@ -155,6 +163,7 @@ "tquestions": "tQuestions", "Training": "Обучение", "translate": "Редактор", + "translationAcademy": "Академия перевода", "TranslationGoal": "Цель перевода", "TranslationLink": "Ссылка на перевод", "Translator": "Переводчик", @@ -165,8 +174,6 @@ "Upload": "Загрузить", "UploadAvatar": "Загрузить аватар", "UploadFailed": "Ошибка загрузки", - "LEVEL": "LEVEL", - "LEVELLanguages": "LEVEL языки", "Ver": "ст.", "Verse": "Стих", "Verse_few": "{{count}} стиха", @@ -184,11 +191,5 @@ "WithoutImages": "Без изображений", "WordExist": "Такое слово уже существует:", "WrongResource": "Ошибка загрузки ресурса", - "Yes": "Да", - "Symbols": "Символы", - "Account": "Аккаунт", - "Projects": "Проекты", - "CreateProject": "Создать проект", - "About": "О проекте", - "Language": "Язык" + "Yes": "Да" } From 7b170a1ee4bb7b7667f2d6f48f4dd9b7097ede23 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:43:12 +0300 Subject: [PATCH 25/37] style: edit color links tA --- components/Panel/Resources/TAContentInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js index f8d2867c..cdcfc638 100644 --- a/components/Panel/Resources/TAContentInfo.js +++ b/components/Panel/Resources/TAContentInfo.js @@ -64,7 +64,7 @@ function TaContentInfo({ href, config, setItem, returnImmediately = false }) { return (
{ e.preventDefault() setItem?.(item) From 59a0f39a921d1816406187834b89b29471865071 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Tue, 26 Nov 2024 15:58:46 +0300 Subject: [PATCH 26/37] feat: add Loading for TA --- components/Panel/UI/TaTopics.js | 53 +++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index b0a0afeb..6b733610 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -9,6 +9,8 @@ import { getFile } from 'utils/apiHelper' import { academyLinks } from 'utils/config' import { getWordsAcademy, resolvePath } from 'utils/helper' +import Loading from 'public/icons/progress.svg' + function TaTopics() { const { locale } = useRouter() @@ -17,6 +19,7 @@ function TaTopics() { const [href, setHref] = useState('intro/ta-intro') const [item, setItem] = useState(null) const [history, setHistory] = useState([]) + const [loading, setLoading] = useState(false) const scrollRef = useRef(null) const updateHref = (newRelativePath) => { @@ -36,26 +39,33 @@ function TaTopics() { useEffect(() => { const getData = async () => { - const zip = await getFile({ - owner: config.resource.owner, - repo: config.resource.repo.split('_')[0] + '_ta', - commit: config.resource.commit, - apiUrl: '/api/git/ta', - }) - - const fetchedWords = await getWordsAcademy({ - zip, - href: `${config.base}/${href}`, - }) - - const title = fetchedWords?.['sub-title'] || href - const text = fetchedWords?.['01'] || href - const item = { - title, - text, - type: 'ta', + setLoading(true) + try { + const zip = await getFile({ + owner: config.resource.owner, + repo: config.resource.repo.split('_')[0] + '_ta', + commit: config.resource.commit, + apiUrl: '/api/git/ta', + }) + + const fetchedWords = await getWordsAcademy({ + zip, + href: `${config.base}/${href}`, + }) + + const title = fetchedWords?.['sub-title'] || href + const text = fetchedWords?.['01'] || href + const item = { + title, + text, + type: 'ta', + } + setItem?.(item) + } catch (error) { + console.error('Error fetching data:', error) + } finally { + setLoading(false) } - setItem?.(item) } getData() @@ -72,6 +82,11 @@ function TaTopics() { return (
+ {loading && ( +
+ +
+ )}
Date: Wed, 27 Nov 2024 13:13:28 +0300 Subject: [PATCH 27/37] fix: edit svg academic --- public/icons/academicCap.svg | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/icons/academicCap.svg b/public/icons/academicCap.svg index 11895c66..e864bfc4 100644 --- a/public/icons/academicCap.svg +++ b/public/icons/academicCap.svg @@ -1,3 +1,7 @@ - - + + From 10deb652efdc196ba620f7fe99a4c003f04b7fff Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 13:13:53 +0300 Subject: [PATCH 28/37] style: add min-w for sidebar --- components/SideBar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/SideBar.js b/components/SideBar.js index e2ef11a3..f51bb3a3 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -125,7 +125,9 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { > e.stopPropagation()} onMouseEnter={() => { @@ -406,7 +408,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { From f53896607473b301acd2ed734c70afdcdc9ec07a Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 13:54:25 +0300 Subject: [PATCH 29/37] style: edit Back button and title --- components/Panel/UI/TAContent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js index 8538b7a8..69615e3d 100644 --- a/components/Panel/UI/TAContent.js +++ b/components/Panel/UI/TAContent.js @@ -18,7 +18,7 @@ function TAContent({ item, setHref, config, goBack }) { }`} >
-
+
Date: Wed, 27 Nov 2024 14:06:59 +0300 Subject: [PATCH 30/37] fix: show Back for root item --- components/Panel/UI/TAContent.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js index 69615e3d..f0eaad3d 100644 --- a/components/Panel/UI/TAContent.js +++ b/components/Panel/UI/TAContent.js @@ -19,19 +19,22 @@ function TAContent({ item, setHref, config, goBack }) { >
-
- -
- {!['intro', 'front'].includes(item?.title) && ( -
- - {item?.title} - + {![ + 'Что такое «Академия перевода»?', + 'What is unfoldingWord® Translation Academy?', + ].includes(item?.title) && ( +
+
)} +
+ + {item?.title} + +
From 55868e67788f86296d7db36371241ceef3e333bb Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 14:54:23 +0300 Subject: [PATCH 31/37] style: add contentClassName for ModalInSideBar --- components/ModalInSideBar.js | 5 ++++- components/SideBar.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/ModalInSideBar.js b/components/ModalInSideBar.js index 515c857c..4b266abb 100644 --- a/components/ModalInSideBar.js +++ b/components/ModalInSideBar.js @@ -7,6 +7,7 @@ function ModalInSideBar({ modalTitle, buttonTitle, collapsed, + contentClassName = 'p-4', }) { return ( <> @@ -31,7 +32,9 @@ function ModalInSideBar({
-
+
{children}
diff --git a/components/SideBar.js b/components/SideBar.js index f51bb3a3..465869a3 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -426,6 +426,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { modalTitle={t('translationAcademy')} buttonTitle={t('translationAcademy')} collapsed={collapsed} + contentClassName="p-0" > From a38537df1ccbdb23c8e8579c64bae48772bd8eae Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 15:29:14 +0300 Subject: [PATCH 32/37] fix: mirrior fix after comments --- components/MarkdownExtended.js | 1 + components/Panel/UI/TAContent.js | 4 ++-- components/Panel/UI/TNTWLContent.js | 16 ++++------------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/components/MarkdownExtended.js b/components/MarkdownExtended.js index 0c4f4981..6c773e17 100644 --- a/components/MarkdownExtended.js +++ b/components/MarkdownExtended.js @@ -13,6 +13,7 @@ function MarkdownExtended({ children, className, onLinkClick, config, setItem }) return text .replace(/\*\//g, locale + '/') .replace(/\[\[(rc:\/\/\S+?)\]\]/g, (_, url) => `[${url}](${url})`) + .replace(/\[(\d+:\d+)\]\(\.\.\/\d+\/\d+\.md\)/g, (_, time) => time) } const content = convertRcLinksToMarkdownLinks( diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js index f0eaad3d..e53e821b 100644 --- a/components/Panel/UI/TAContent.js +++ b/components/Panel/UI/TAContent.js @@ -23,12 +23,12 @@ function TAContent({ item, setHref, config, goBack }) { 'Что такое «Академия перевода»?', 'What is unfoldingWord® Translation Academy?', ].includes(item?.title) && ( -
-
+ )}
diff --git a/components/Panel/UI/TNTWLContent.js b/components/Panel/UI/TNTWLContent.js index 18f7b538..97dc8d67 100644 --- a/components/Panel/UI/TNTWLContent.js +++ b/components/Panel/UI/TNTWLContent.js @@ -16,18 +16,10 @@ function TNTWLContent({ setItem, item, parentItem, setParentItem, setHref, confi }, [item, parentItem]) const handleBackClick = () => { - if (item.type === 'ta' || item.type === 'tw') { - setItem(parentItem) - setParentItem(null) - if (setHref) { - setHref(null) - } - } else { - setItem(null) - setParentItem(null) - if (setHref) { - setHref(null) - } + setItem(item.type === 'ta' || item.type === 'tw' ? parentItem : null) + setParentItem(null) + if (setHref) { + setHref(null) } } From c314bd6d230cd61ddd64cc1fb3b0ffde89d1e2aa Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 15:36:14 +0300 Subject: [PATCH 33/37] feat: add info about new version --- public/updates_en.md | 10 ++++++++++ public/updates_es.md | 10 ++++++++++ public/updates_ru.md | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/public/updates_en.md b/public/updates_en.md index 69a59c80..c96e00c6 100644 --- a/public/updates_en.md +++ b/public/updates_en.md @@ -1,3 +1,13 @@ +# Version 0.26.0 +## Date: 27.11.2024 + +### **Added:** +- added the display of articles of the Translation Academy in the sidebar + +### **Changed** +- inside tWords, cross-references between words work +- links to articles of the Translation Academy work inside tWords and tNotes + # Version 0.25.1 ## Date: 11/08/2024 diff --git a/public/updates_es.md b/public/updates_es.md index 39be20b9..2a1c6fab 100644 --- a/public/updates_es.md +++ b/public/updates_es.md @@ -1,3 +1,13 @@ +# Versión 0.26.0 +## Date: 27.11.2024 + +### **Agregado:** +- se ha añadido la visualización de los artículos De la Academia de traducción en la barra lateral + +### * * Modificado** +- dentro de tWords funcionan los enlaces cruzados entre palabras +- dentro de tWords y tNotes funcionan enlaces a artículos De la Academia de traducción + # Versión 0.25.1 ## Date: 11/08/2024 diff --git a/public/updates_ru.md b/public/updates_ru.md index ac2dd9de..fde8584b 100644 --- a/public/updates_ru.md +++ b/public/updates_ru.md @@ -1,3 +1,13 @@ +# Версия 0.26.0 +## Date: 27.11.2024 + +### **Добавлено:** +- добавлено отображение статей Академии перевода в сайдбаре + +### **Изменено** +- внутри tWords работают перекрестные ссылки между словами +- внутри tWords и tNotes работают ссылки на статьи Академии перевода + # Версия 0.25.1 ## Date: 08.11.2024 From dbfa90ae08d5b73f03e14ea5314fd7b41adc2cdf Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 19:07:28 +0300 Subject: [PATCH 34/37] fix: edit file version --- public/updates_en.md | 2 +- public/updates_es.md | 2 +- public/updates_ru.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/updates_en.md b/public/updates_en.md index c96e00c6..c7ea5702 100644 --- a/public/updates_en.md +++ b/public/updates_en.md @@ -2,7 +2,7 @@ ## Date: 27.11.2024 ### **Added:** -- added the display of articles of the Translation Academy in the sidebar +- Translation Academy in sidebar ### **Changed** - inside tWords, cross-references between words work diff --git a/public/updates_es.md b/public/updates_es.md index 2a1c6fab..f19d96f6 100644 --- a/public/updates_es.md +++ b/public/updates_es.md @@ -2,7 +2,7 @@ ## Date: 27.11.2024 ### **Agregado:** -- se ha añadido la visualización de los artículos De la Academia de traducción en la barra lateral +- Academia de traducción en sidbar ### * * Modificado** - dentro de tWords funcionan los enlaces cruzados entre palabras diff --git a/public/updates_ru.md b/public/updates_ru.md index fde8584b..f0b319d5 100644 --- a/public/updates_ru.md +++ b/public/updates_ru.md @@ -2,7 +2,7 @@ ## Date: 27.11.2024 ### **Добавлено:** -- добавлено отображение статей Академии перевода в сайдбаре +- Академия перевода в сайдбаре ### **Изменено** - внутри tWords работают перекрестные ссылки между словами From 4eee22b8309969a37051c1301bf48bc7fee4d590 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 19:17:18 +0300 Subject: [PATCH 35/37] style: mirror fixed style button Back --- components/ModalInSideBar.js | 2 +- components/Panel/UI/TAContent.js | 2 +- components/SideBar.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/ModalInSideBar.js b/components/ModalInSideBar.js index 4b266abb..2353ab6b 100644 --- a/components/ModalInSideBar.js +++ b/components/ModalInSideBar.js @@ -33,7 +33,7 @@ function ModalInSideBar({
{children}
diff --git a/components/Panel/UI/TAContent.js b/components/Panel/UI/TAContent.js index e53e821b..7c9873af 100644 --- a/components/Panel/UI/TAContent.js +++ b/components/Panel/UI/TAContent.js @@ -18,7 +18,7 @@ function TAContent({ item, setHref, config, goBack }) { }`} >
-
+
{![ 'Что такое «Академия перевода»?', 'What is unfoldingWord® Translation Academy?', diff --git a/components/SideBar.js b/components/SideBar.js index 465869a3..bc2871b6 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -426,7 +426,7 @@ function SideBar({ setIsOpenSideBar, access, isOpenSideBar }) { modalTitle={t('translationAcademy')} buttonTitle={t('translationAcademy')} collapsed={collapsed} - contentClassName="p-0" + contentClassName="mt-4 p-0" > From a7c4a5fec443a62f8b4b2a11762c03b98c81fc7f Mon Sep 17 00:00:00 2001 From: DenisArger Date: Wed, 27 Nov 2024 19:28:47 +0300 Subject: [PATCH 36/37] fix: edit updateHref --- components/Panel/UI/TaTopics.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/Panel/UI/TaTopics.js b/components/Panel/UI/TaTopics.js index 6b733610..4587890e 100644 --- a/components/Panel/UI/TaTopics.js +++ b/components/Panel/UI/TaTopics.js @@ -24,8 +24,15 @@ function TaTopics() { const updateHref = (newRelativePath) => { const { absolutePath } = resolvePath(config.base, href, newRelativePath) - setHistory((prev) => [...prev, href]) - setHref(absolutePath.replace(config.base + '/', '')) + const newHref = absolutePath.replace(config.base + '/', '') + + if (newHref === href) { + setHref('') + setTimeout(() => setHref(newHref), 0) + } else { + setHistory((prev) => [...prev, href]) + setHref(newHref) + } } const goBack = () => { From da01534800b17f6bda84ee2c9a83d55cfd39dad7 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Thu, 28 Nov 2024 11:09:19 +0300 Subject: [PATCH 37/37] style: add loading for TaContentInfo --- components/Panel/Resources/TAContentInfo.js | 33 +++++++++------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/components/Panel/Resources/TAContentInfo.js b/components/Panel/Resources/TAContentInfo.js index cdcfc638..c824c057 100644 --- a/components/Panel/Resources/TAContentInfo.js +++ b/components/Panel/Resources/TAContentInfo.js @@ -3,6 +3,8 @@ import { useEffect, useRef, useState } from 'react' import { getFile } from 'utils/apiHelper' import { getWordsAcademy } from 'utils/helper' +import Loading from 'public/icons/progress.svg' + function TaContentInfo({ href, config, setItem, returnImmediately = false }) { const [words, setWords] = useState(null) const [isLoading, setIsLoading] = useState(true) @@ -28,34 +30,27 @@ function TaContentInfo({ href, config, setItem, returnImmediately = false }) { href: hrefRef.current, }) setWords(fetchedWords) - - if (returnImmediately) { - const title = - fetchedWords?.['sub-title'] || fetchedWords?.sub || hrefRef.current - const text = fetchedWords?.['01'] || hrefRef.current - const item = { - title, - text, - type: 'ta', - } - setItem?.(item) - } + } catch (error) { + console.error('Error fetching data:', error) } finally { setIsLoading(false) } } getData() - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [returnImmediately, setItem]) + }, [config, returnImmediately, setItem]) if (isLoading) { - return Loading... + return ( + + ) } - const description = words?.['title'] || words?.title || hrefRef.current - const title = words?.['sub-title'] || words?.sub || hrefRef.current - const text = words?.['01'] || hrefRef.current + if (!words) return null + + const description = words['title'] || words.title || hrefRef.current + const title = words['sub-title'] || words.sub || hrefRef.current + const text = words['01'] || hrefRef.current const item = { title, text, type: 'ta' } if (returnImmediately) { @@ -64,7 +59,7 @@ function TaContentInfo({ href, config, setItem, returnImmediately = false }) { return (
{ e.preventDefault() setItem?.(item)