Skip to content

Commit

Permalink
Category 2
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Nov 17, 2023
1 parent a6d0027 commit 592fafd
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/Layout/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Route, Routes } from "react-router-dom";
import config from "config";
import AuthorsRoute from "pages/AuthorsRoute";
import { CreateCorpus, CreateDictionary } from "pages/CreateDictionary";
import { CorpusDashboard, DictionaryDashboard } from "pages/Dashboard";
import { CorpusDashboard, DictionaryDashboard, ParallelCorporaDashboard } from "pages/Dashboard";
import DashboardRoute from "pages/DashboardRoute";
import Desktop from "pages/Desktop";
import DialeqtImport from "pages/DialeqtImport";
Expand Down Expand Up @@ -44,10 +44,12 @@ const AppRoutes = () => (
<Route path="/languages" element={<Languages />} />
<Route path="/dictionaries" element={<DictionaryDashboard />} />
<Route path="/corpora" element={<CorpusDashboard />} />
<Route path="/parallel_corpora" element={<ParallelCorporaDashboard />} />
<Route path="/corpora_all" element={<DictionariesAll forCorpora={true} />} />
<Route path="/create_dictionary" element={<CreateDictionary />} />
<Route path="/create_corpus" element={<CreateCorpus />} />
<Route path="/dictionaries_all" element={<DictionariesAll />} />
<Route path="/parallel_corpora_all" element={<DictionariesAll forParallelCorpora={true} />} />
<Route path="/grants" element={<Grants />} />
<Route path="/requests" element={<Requests />} />
<Route path="/map" element={<Map />} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/CreatePerspectiveModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CreatePerspectiveModal extends React.Component {
</h4>

<Fields
mode={category == 0 ? "dictionary" : "corpus"}
mode={category == 1 ? "corpus" : "dictionary"}
perspectives={perspective_info_list}
onChange={f =>
this.setState({
Expand Down
6 changes: 3 additions & 3 deletions src/components/DictionaryPropertiesModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ class Properties extends React.Component {
<Header as="h3">{this.context("Translations")}</Header>
<TranslationGist id={gistId} objectId={dictionary.id} editable updateAtomMutation={updateAtomMutation} />
</Segment>
{category === 0 ? (
<EditDictionaryMetadata mode="edit" metadata={dictionary.additional_metadata} onSave={this.saveMeta} />
) : (
{category === 1 ? (
<EditCorpusMetadata mode="edit" metadata={dictionary.additional_metadata} onSave={this.saveMeta} />
) : (
<EditDictionaryMetadata mode="edit" metadata={dictionary.additional_metadata} onSave={this.saveMeta} />
)}
<MarginForm>
<Segment>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Home/components/LangsNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const prepareData = (resultData, language) => {
resultDictsCount.dicts += 1;
} else if (item.category === 1) {
resultDictsCount.corps += 1;
} else if (item.category === 2) {
resultDictsCount.dicts += 1;
}
} else if (item.type === "language") {
const itemDictsCount = prepareData(resultData, item);
Expand Down
34 changes: 33 additions & 1 deletion src/pages/Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,27 @@ const CORPORA_TABS = getTranslation => {
];
};

const PARALLEL_CORPORA_TABS = getTranslation => {
return [
{
menuItem: getTranslation("My dictionaries"),
render: () => (
<Tab.Pane className="lingvo-tab__pane">
<Dictionaries category={2} mode={0} />
</Tab.Pane>
)
},
{
menuItem: getTranslation("Available dictionaries"),
render: () => (
<Tab.Pane className="lingvo-tab__pane">
<Dictionaries category={2} mode={1} />
</Tab.Pane>
)
}
];
};

const DictionaryDashboard = () => {
const getTranslation = useContext(TranslationContext);
return (
Expand All @@ -561,4 +582,15 @@ const CorpusDashboard = () => {
);
};

export { DictionaryDashboard, CorpusDashboard };
const ParallelCorporaDashboard = () => {
const getTranslation = useContext(TranslationContext);
return (
<div className="background-content">
<Tab className="inverted lingvo-tab" panes={PARALLEL_CORPORA_TABS(getTranslation)} renderActiveOnly />
<DictionaryProperties />
</div>
);
};


export { DictionaryDashboard, CorpusDashboard, ParallelCorporaDashboard };
12 changes: 8 additions & 4 deletions src/pages/DashboardRoute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function DashboardRoute() {
<label className="card-item__label">{getTranslation("Corpora")}</label>
<img className="card-item__img" src={imageCorpora} />
</Link>
<Link className="card-item" to="/parallel_corpora">
<label className="card-item__label">{getTranslation("Parallel corpora")}</label>
<img className="card-item__img" src={imageCorpora} />
</Link>
<Link className="card-item" to="/import_corpora">
<label className="card-item__label">{getTranslation("Import parallel corpora")}</label>
<img className="card-item__img card-item__img_import" src={imageImport} />
</Link>
<Link className="card-item" to="/import_dialeqt">
<label className="card-item__label">{getTranslation("Import Dialeqt dictionary")}</label>
<img className="card-item__img card-item__img_dialeqt" src={imageDialeqt} />
Expand All @@ -47,10 +55,6 @@ function DashboardRoute() {
<label className="card-item__label">{getTranslation("Import Excel and Starling dictionaries")}</label>
<img className="card-item__img card-item__img_import" src={imageImport} />
</Link>
<Link className="card-item" to="/import_corpora">
<label className="card-item__label">{getTranslation("Import parallel corpora")}</label>
<img className="card-item__img card-item__img_import" src={imageImport} />
</Link>
</div>
</div>
</div>
Expand Down
15 changes: 12 additions & 3 deletions src/pages/DictionariesAll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const Wrapper = ({ tree, ...rest }) => {
};

/** Dashboard dictionaries page */
const DictionariesAll = ({ forCorpora = false }) => {
const DictionariesAll = ({ forCorpora = false, forParallelCorpora = false }) => {
const { getTranslation } = useTranslations();

const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -227,7 +227,12 @@ const DictionariesAll = ({ forCorpora = false }) => {
return [mode, tab, id];
}, [searchParams]);

const category = forCorpora ? 1 : 0;
const category = (
forCorpora
? 1
: forParallelCorpora
? 2
: 0);

const entityIdValue = useMemo(() => {
let entityIdValue = null;
Expand Down Expand Up @@ -521,7 +526,11 @@ const DictionariesAll = ({ forCorpora = false }) => {
)
},
{
menuItem: getTranslation(forCorpora ? "Corpora" : "Dictionaries"),
menuItem: getTranslation(forCorpora
? "Corpora"
: forParallelCorpora
? "Parallel corpora"
: "Dictionaries"),
render: () => (
<Tab.Pane>
<Wrapper tree={treeAll} sortMode={sortMode} entityId={entityId} />
Expand Down
4 changes: 4 additions & 0 deletions src/pages/LanguagesDatabasesRoute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function TreeRoute() {
<label className="card-item__label">{getTranslation("Language corpora")}</label>
<img className="card-item__img card-item__img_corpora" src={imageCorpora} />
</Link>
<Link className="card-item" to="/parallel_corpora_all">
<label className="card-item__label">{getTranslation("Parallel corpora")}</label>
<img className="card-item__img card-item__img_corpora" src={imageCorpora} />
</Link>
</div>
</div>
</div>
Expand Down

0 comments on commit 592fafd

Please sign in to comment.