Skip to content

Commit

Permalink
Renaming the title to scope management and fixing the edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinpaul committed Sep 6, 2024
1 parent 8800c1d commit 38a1430
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function ProjectMangement(props) {

<div className="flex justify-between items-center bg-secondary">
<div className="uppercase bg-secondary text-white py-2 px-2 text-xs tracking-widest leading-snug rounded-tl text-center flex gap-2">
<span>Project Management</span>
<span>Scope Management</span>
<span>:</span>
<span>{project?.name}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function ScopeManagement({
<div className="border border-[#eeecec] shadow-sm rounded-lg bg-[#F9F9F9]
grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-1 p-4 text-xxs text-left uppercase"
>
{backendScope && bookList?.slice(0, 39)?.map((book) => {
{bookList?.slice(0, 39)?.map((book) => {
const isScope = book?.key?.toUpperCase() in currentScope;
return (
<BookItem
Expand All @@ -198,7 +198,7 @@ function ScopeManagement({
handleRemoveScope={handleRemoveScope}
handleSelectBook={handleSelectBook}
isInScope={isScope}
disable={book?.key?.toUpperCase() in backendScope}
disable={backendScope && book?.key?.toUpperCase() in backendScope}
/>
);
})}
Expand All @@ -207,7 +207,7 @@ function ScopeManagement({
<div className="border border-[#eeecec] shadow-sm rounded-lg bg-[#F9F9F9]
grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-1 p-4 text-xxs text-left uppercase content-start"
>
{backendScope && bookList?.slice(39)?.map((book) => {
{bookList?.slice(39)?.map((book) => {
const isScope = book?.key?.toUpperCase() in currentScope;
return (
<BookItem
Expand All @@ -216,7 +216,7 @@ function ScopeManagement({
handleRemoveScope={handleRemoveScope}
handleSelectBook={handleSelectBook}
isInScope={isScope}
disable={book?.key?.toUpperCase() in backendScope}
disable={backendScope && book?.key?.toUpperCase() in backendScope}
/>
);
})}
Expand Down Expand Up @@ -270,7 +270,7 @@ function ScopeManagement({
<div className="border border-[#eeecec] shadow-sm rounded-lg bg-[#F9F9F9] flex flex-wrap gap-2 p-4 text-xxs text-left uppercase">
{chapterList?.map(({ key, name }) => {
const isInScope = selectedChaptersSet.has(key);
const disable = backendScope[bookId.toUpperCase()]?.includes(key);
const disable = backendScope && backendScope[bookId.toUpperCase()]?.includes(key);
return (
<BookButton
onClick={(e) => handleChapterSelection(e, name)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,32 @@ const getDirectories = (readdirSync, source) => readdirSync(source, { withFileTy
.map((dirent) => dirent.name);

// This function returns the Object of books & chapters which has atleast 1 audio file in it.
export const getScope = (project) => {
export const getScope = async (project) => {
const path = require('path');
const scope = {};
const { readdirSync } = window.require('fs');
const fs = window.require('fs');
const list = getDirectories(readdirSync, project);
list.forEach((book) => {

list.forEach(async (book) => {
const chapters = getDirectories(readdirSync, path.join(project, book));
const chapterFilter = [];
chapters.forEach((chapter) => {
let flag = false;
await Promise.all(chapters.map(async (chapter) => {
// for (const chapter of chapters) {
// Finding non empty directories/chapters
isDirEmpty(path.join(project, book, chapter), fs).then((value) => {
await isDirEmpty(path.join(project, book, chapter), fs).then((value) => {
if (value === true) {
chapterFilter.push(chapter);
flag = true;
return chapterFilter.push(chapter);
}
});
});
scope[book] = chapterFilter;
}));
if (flag === true) {
scope[book] = chapterFilter;
}
});
return scope;
return scope;
};
export const readProjectScope = async (projectName) => {
try {
Expand All @@ -48,7 +54,7 @@ export const readProjectScope = async (projectName) => {
if (metadataFile) {
logger.debug('readProjectScope.js', `read metadata file successfully - ${projectName}`);
const project = path.join(file, projectName, 'audio', 'ingredients');
const backendScope = getScope(project);
const backendScope = await getScope(project);
const json = await JSON.parse(metadataFile);
return { metadata: json, scope: backendScope };
}
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Projects/ProjectRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const ProjectRow = ({
} group rounded-md items-center w-full px-2 py-2 text-sm ${project.isArchived ? 'hidden' : 'flex'}`}
onClick={() => manageProject(project)}
>
Manage Project
Scope Management
</button>
)}
</Menu.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })
</BookNumberTag>
</div>
</div>

{projectType === 'Audio'
&& <span className="text-error">NOTE: Choose the book and chapter from the SCOPE MANAGEMENT option on the project listing page.</span>}
{/* <div className="relative"> */}
<div>
{/* <CustomList
Expand Down

0 comments on commit 38a1430

Please sign in to comment.