Skip to content

Commit

Permalink
- added a Juxta mode that creates a translation burrito
Browse files Browse the repository at this point in the history
- added a 'factoryCreateContent.js'  file to help factorize some code for 'createObsContent', 'createVersificationUSFM' and 'createAudioVersification' in 'saveProjetcsMeta.js'

- fixing some typos, fixing lint
  • Loading branch information
danielc-n committed Jan 16, 2024
1 parent 4a4c71c commit 1d1626d
Show file tree
Hide file tree
Showing 30 changed files with 4,409 additions and 3,670 deletions.
435 changes: 212 additions & 223 deletions e2e-tests/common.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions renderer/src/components/EditorPage/ObsEditor/ObsEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ReferenceContext } from '@/components/context/ReferenceContext';
import writeToFile from '@/core/editor/writeToFile';
import { saveReferenceResource } from '@/core/projects/updateAgSettings';
import moment from 'moment';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import EditorPanel from './EditorPanel';
import * as logger from '../../../logger';
import { getDetails } from './utils/getDetails';
Expand Down Expand Up @@ -72,7 +72,7 @@ const ObsEditor = () => {
setDirectoryName(dirName);
// Fetching data from projectmeta and updating the navigation and lastSeen back
localforage.getItem('currentProject').then(async (projectName) => {
const _projectname = await splitStringByLastOccurance(projectName, '_');
const _projectname = await splitStringByLastOccurence(projectName, '_');
// const _projectname = projectName?.split('_');
localforage.getItem('projectmeta').then((value) => {
Object.entries(value).forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const TranslationHelps = ({
<>
{(() => {
switch (selectedResource) {
// Nicolas : do we add a juxta type here ?
case 'tn':
return (
<TranslationHelpsCard
Expand Down
16 changes: 16 additions & 0 deletions renderer/src/components/Projects/NewProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { environment } from '../../../environment';
import LayoutIcon from '@/icons/basil/Outline/Interface/Layout.svg';
import BullhornIcon from '@/icons/basil/Outline/Communication/Bullhorn.svg';
import ImageIcon from '@/icons/basil/Outline/Files/Image.svg';
import Book from '@/icons/basil/Outline/Files/Book.svg';
import { classNames } from '../../util/classNames';
import * as logger from '../../logger';
import ImportPopUp from './ImportPopUp';
Expand All @@ -45,6 +46,13 @@ const solutions = [
href: '##',
icon: ImageIcon,
},
// Nicolas : if I wanna add a mode on the UI, I can call it here
// NicolasEdits : added Juxta
{
name: 'Juxta',
href: '##',
icon: Book,
},
];

function TargetLanguageTag(props) {
Expand All @@ -54,6 +62,7 @@ function TargetLanguageTag(props) {
);
}

// Nicolas : the dropdown I'm looking for
function BibleHeaderTagDropDown(headerDropDown, handleDropDown, call) {
return (
call === 'new'
Expand Down Expand Up @@ -166,6 +175,7 @@ export default function NewProject({ call, project, closeEdit }) {

const createTheProject = (update) => {
logger.debug('NewProject.js', 'Creating new project.');
// headerDropDown === projectType
const value = createProject(call, metadata, update, headerDropDown);
value.then((status) => {
logger.debug('NewProject.js', status[0].value);
Expand All @@ -182,6 +192,7 @@ export default function NewProject({ call, project, closeEdit }) {
}
});
};
// Nicolas : the button that calls all the domino to create a project
const validate = async () => {
logger.debug('NewProject.js', 'Validating the fields.');
setLoading(true);
Expand Down Expand Up @@ -283,6 +294,11 @@ export default function NewProject({ call, project, closeEdit }) {
setHeaderDropDown('Audio');
break;

// NicolasEdits : added Juxta
case 'x-juxtalinear':
setHeaderDropDown('Juxta');
break;

default:
break;
}
Expand Down
8 changes: 8 additions & 0 deletions renderer/src/components/Resources/ListResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const ListResources = ({
const { t } = useTranslation();
const [translationWordList, settranslationWordList] = useState([]);
const [translationNote, setTranslationNote] = useState([]);
// Nicolas : added juxtalinear useState
// const [juxtalinear, setJuxtalinear] = useState([]);
const [translationQuestion, setTranslationQuestion] = useState([]);
const [translationWord, settranslationWord] = useState([]);
const [translationAcademy, setTranslationAcademy] = useState([]);
Expand Down Expand Up @@ -96,6 +98,10 @@ export const ListResources = ({
setLoading(true);
logger.debug('ResourcesPopUp.js', `get available selected resources ${selectResource}`);
switch (selectResource) {
// Nicolas : add a case here to list juxta in popup menu
// case 'jxl':
// await fetchTranslationResource('Juxtalinear', setJuxtalinear, selectResource, selectedPreProd, snackBarAction);
// break;
case 'tn':
await fetchTranslationResource('TSV Translation Notes', setTranslationNote, selectResource, selectedPreProd, snackBarAction);
break;
Expand Down Expand Up @@ -131,6 +137,8 @@ export const ListResources = ({
useEffect(() => {
const getCurrentOnlineOfflineHelpsResources = (selectResource) => {
const resources = [
// Nicolas : add another resource Juxtalinear
// { id: 'jxl', title: "Juxtalinear", resource: juxtalinear },
{ id: 'tn', title: t('label-resource-tn'), resource: translationNote },
{ id: 'twlm', title: t('label-resource-twl'), resource: translationWordList },
{ id: 'tw', title: t('label-resource-twlm'), resource: translationWord },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ConfirmationModal from '@/layouts/editor/ConfirmationModal';
import localForage from 'localforage';
import { ReferenceContext } from '@/components/context/ReferenceContext';
import { TrashIcon } from '@heroicons/react/24/outline';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import * as logger from '../../../logger';
import packageInfo from '../../../../../package.json';
// import TrashSvg from '@/icons/basil/Outline/Interface/Trash.svg';
Expand All @@ -19,7 +19,7 @@ const ResourceResetAfterCheckSameOnRefResourceAgSettings = async (setResetResour
logger.debug('RemoveResource.js', 'Search for multiple pane open same resource before download');
const refsHistory = [];
localForage.getItem('currentProject').then(async (projectName) => {
const _projectname = await splitStringByLastOccurance(projectName, '_');
const _projectname = await splitStringByLastOccurence(projectName, '_');
// const _projectname = projectName?.split('_');
localForage.getItem('projectmeta').then((value) => {
Object.entries(value).forEach(
Expand Down
7 changes: 7 additions & 0 deletions renderer/src/components/Resources/ResourcesSideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export default function ResourcesSidebar({
resourceType: 'translationNote',
Icon: DocumentTextIcon,
},
// Nicolas : added juxtalinear to resourcesList
// {
// id: 'jxl',
// title: 'juxta',
// resourceType: 'juxtalinear',
// Icon: DocumentTextIcon,
// },
{
id: 'twlm',
title: t('label-resource-twl'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function createData(name, language, owner) {
export const fetchTranslationResource = async (urlpath, setResource, selectResource, selectedPreProd, snackBarAction) => {
logger.debug('ResourcesPopUp.js', `fetchTranslationResource : ${selectResource}`);
// const baseUrl = 'https://git.door43.org/api/catalog/v5/search?';
// https://git.door43.org/api/v1/catalog/search?metadataType=rc
// https://qa.door43.org/api/v1/repos/search?flavor=x-juxtalinear
const baseUrl = `${environment.GITEA_API_ENDPOINT}/catalog/search?metadataType=rc&`;
let url = `${baseUrl}subject=${urlpath}`;
if (selectedPreProd) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-undef */
export default function getCurrentOnlineOfflineHelpsResources(selectResource) {
const resources = [
// Nicolas : add juxtalinear here ?
// { id: 'jxl', title: 'Juxtalinear', resource: juxtalinear },
{ id: 'tn', title: t('label-resource-tn'), resource: translationNote },
{ id: 'twlm', title: t('label-resource-twl'), resource: translationWordList },
{ id: 'tw', title: t('label-resource-twlm'), resource: translationWord },
Expand Down
8 changes: 5 additions & 3 deletions renderer/src/components/context/ProjectContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import * as localforage from 'localforage';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import { isElectron } from '../../core/handleElectron';
import * as logger from '../../logger';
import { saveProjectsMeta, saveSupabaseProjectsMeta } from '../../core/projects/saveProjetcsMeta';
Expand Down Expand Up @@ -402,6 +402,8 @@ const ProjectContextProvider = ({ children }) => {
}
};

// Nicolas : actually create the project
// Nicolas : ignore Supabase or Web... Code
const createProject = async (call, project, update, projectType) => {
logger.debug('ProjectContext.js', 'In createProject');
await createProjectCommonUtils();
Expand Down Expand Up @@ -481,7 +483,7 @@ const ProjectContextProvider = ({ children }) => {
projectMeta?.projects.forEach((meta) => {
const currentprojectId = Object.keys(meta.identification.primary[packageInfo.name])[0];
const currentprojectName = meta.identification.name.en;
splitStringByLastOccurance(projectName, '_').then((arr) => {
splitStringByLastOccurence(projectName, '_').then((arr) => {
if (arr.length > 0 && arr[0].toLowerCase() === currentprojectName.toLowerCase()
&& arr[1].toLowerCase() === currentprojectId.toLocaleLowerCase()) {
setSelectedProjectMeta(meta);
Expand All @@ -504,7 +506,7 @@ const ProjectContextProvider = ({ children }) => {
projectMeta?.projects.forEach((meta) => {
const currentprojectId = Object.keys(meta.identification.primary[packageInfo.name])[0];
const currentprojectName = meta.identification.name.en;
splitStringByLastOccurance(projectName, '_').then((arr) => {
splitStringByLastOccurence(projectName, '_').then((arr) => {
if (arr.length > 0 && arr[0].toLowerCase() === currentprojectName.toLowerCase()
&& arr[1].toLowerCase() === currentprojectId.toLocaleLowerCase()) {
setSelectedProjectMeta(meta);
Expand Down
5 changes: 3 additions & 2 deletions renderer/src/components/context/ReferenceContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
import PropTypes from 'prop-types';

import * as localforage from 'localforage';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import { saveReferenceResource } from '@/core/projects/updateAgSettings';
import { isElectron } from '../../core/handleElectron';
import * as logger from '../../logger';
Expand Down Expand Up @@ -95,7 +95,7 @@ export default function ReferenceContextProvider({ children }) {
localforage.getItem('currentProject').then(async (projectName) => {
if (projectName) {
// const _projectname = projectName?.split('_');
const _projectname = await splitStringByLastOccurance(projectName, '_');
const _projectname = await splitStringByLastOccurence(projectName, '_');
localforage.getItem('projectmeta').then((val) => {
Object?.entries(val).forEach(
([, _value]) => {
Expand All @@ -104,6 +104,7 @@ export default function ReferenceContextProvider({ children }) {
const id = Object.keys(resources.identification.primary[packageInfo.name]);
if (id[0] === _projectname[1]) {
switch (resources.type.flavorType.flavor.name) {
// Nicolas : add a case for juxta here ?
case 'textTranslation':
setBookmarksVerses(resources.project?.textTranslation.bookMarks);
setProjectScriptureDir(resources.project?.textTranslation?.scriptDirection?.toUpperCase());
Expand Down
15 changes: 15 additions & 0 deletions renderer/src/components/hooks/projects/useProjectsSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ function useProjectsSort() {
_project.type.flavorType.flavor
.name
) {
// Nicolas : add description for juxta here
// NicolasEdits : added Juxta
case 'x-juxtalinear':
lastSeen = _project.project
?.textTranslation
?.lastSeen;
description = _project.project
?.textTranslation
?.description;
isArchived = _project.project
?.textTranslation
?.isArchived;
starred = _project.project?.textTranslation?.starred;
flavorType = 'Juxtalinear';
break;
case 'textTranslation':
lastSeen = _project.project
?.textTranslation
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/core/editor/fetchSettingsResourceHistory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import localforage from 'localforage';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import isBackendProjectExist from '../projects/existProjectInBackEnd';
import * as logger from '../../logger';

Expand Down Expand Up @@ -59,7 +59,7 @@ export async function fetchSettingsResourceHistory(
const refsHistory = [];
const rows = [];
localforage.getItem('currentProject').then(async (projectName) => {
const _projectname = await splitStringByLastOccurance(projectName, '_');
const _projectname = await splitStringByLastOccurence(projectName, '_');
// const _projectname = projectName?.split('_');
// looping through all projects to get the history
localforage.getItem('projectmeta').then((value) => {
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/core/editor/saveSettingsResourceHistory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import localforage from 'localforage';
import { splitStringByLastOccurance } from '@/util/splitStringByLastMarker';
import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker';
import { saveReferenceResource } from '../projects/updateAgSettings';
import * as logger from '../../logger';

Expand Down Expand Up @@ -33,7 +33,7 @@ export async function saveSettingsResourceHistory(
logger.debug('SaveSettingsResourceHistory.js', `call from placeholder : ${sectionPlaceholderNum}`);
const refsHistory = [];
localforage.getItem('currentProject').then(async (projectName) => {
const _projectname = await splitStringByLastOccurance(projectName, '_');
const _projectname = await splitStringByLastOccurence(projectName, '_');
// const _projectname = projectName?.split('_');
localforage.getItem('projectmeta').then((value) => {
Object?.entries(value).forEach(
Expand Down
Loading

0 comments on commit 1d1626d

Please sign in to comment.