-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1304 from qdraw/feature/202312_code_smellse_9
- Loading branch information
Showing
38 changed files
with
203 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using build; | ||
|
||
namespace helpers | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-list-view/shift-selection-helper.spec.ts → ...iew/shared/shift-selection-helper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../item-list-view/shift-selection-helper.ts → ...ist-view/shared/shift-selection-helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...tapp/src/components/molecules/item-list-view/shared/warning-box-no-photos-filter.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { render } from "@testing-library/react"; | ||
import * as useGlobalSettingsModule from "../../../../hooks/use-global-settings"; | ||
import { PageType } from "../../../../interfaces/IDetailView"; | ||
import { SupportedLanguages } from "../../../../shared/language"; | ||
import { WarningBoxNoPhotosFilter } from "./warning-box-no-photos-filter"; | ||
|
||
describe("WarningBoxNoPhotosFilter", () => { | ||
beforeEach(() => { | ||
// Mock the useGlobalSettings hook | ||
jest.spyOn(useGlobalSettingsModule, "default").mockReturnValue({ | ||
language: SupportedLanguages.en | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
// Clear the mock after each test | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
test("renders no warning box when pageType is Loading", () => { | ||
const { container } = render( | ||
<WarningBoxNoPhotosFilter | ||
pageType={PageType.Loading} | ||
subPath="/some-path" | ||
items={[]} | ||
colorClassUsage={[]} | ||
/> | ||
); | ||
|
||
// Assert that no warning box is rendered | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
// ... (other test cases) | ||
|
||
test("renders warning box when colorClassUsage is not empty", () => { | ||
const component = render( | ||
<WarningBoxNoPhotosFilter | ||
pageType={PageType.Archive} | ||
subPath="/some-path" | ||
items={[]} | ||
colorClassUsage={[1, 2, 3]} | ||
/> | ||
); | ||
|
||
// Assert that the warning box is rendered with the correct message | ||
expect( | ||
component.getByTestId("list-view-message-items-outside-filter") | ||
).toBeTruthy(); | ||
|
||
component.unmount(); | ||
}); | ||
|
||
test("renders warning box when items are empty", () => { | ||
const component = render( | ||
<WarningBoxNoPhotosFilter | ||
pageType={PageType.Archive} | ||
subPath="/some-path" | ||
items={[]} | ||
colorClassUsage={[]} | ||
/> | ||
); | ||
|
||
// Assert that the warning box is rendered with the correct message | ||
expect(component.getByTestId("list-view-no-photos-in-folder")).toBeTruthy(); | ||
|
||
component.unmount(); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
...clientapp/src/components/molecules/item-list-view/shared/warning-box-no-photos-filter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { memo } from "react"; | ||
import useGlobalSettings from "../../../../hooks/use-global-settings"; | ||
import { PageType } from "../../../../interfaces/IDetailView"; | ||
import { IFileIndexItem } from "../../../../interfaces/IFileIndexItem"; | ||
import localization from "../../../../localization/localization.json"; | ||
import { Language } from "../../../../shared/language"; | ||
|
||
interface IWarningBoxNoPhotosFilterProps { | ||
pageType: PageType | undefined; | ||
subPath: string | undefined; | ||
items: IFileIndexItem[]; | ||
colorClassUsage: number[]; | ||
} | ||
|
||
export const WarningBoxNoPhotosFilter: React.FunctionComponent<IWarningBoxNoPhotosFilterProps> = | ||
memo(({ pageType, subPath, items, colorClassUsage }) => { | ||
const settings = useGlobalSettings(); | ||
const language = new Language(settings.language); | ||
|
||
const MessageNoPhotosInFolder = language.key( | ||
localization.MessageNoPhotosInFolder | ||
); | ||
const MessageItemsOutsideFilter = language.key( | ||
localization.MessageItemsOutsideFilter | ||
); | ||
|
||
let warningBox = null; | ||
|
||
if ( | ||
pageType !== PageType.Loading && | ||
subPath !== "/" && | ||
items.length === 0 | ||
) { | ||
if (colorClassUsage.length >= 1) { | ||
warningBox = ( | ||
<div | ||
className="warning-box warning-box--left" | ||
data-test="list-view-message-items-outside-filter" | ||
> | ||
{MessageItemsOutsideFilter} | ||
</div> | ||
); | ||
} else { | ||
warningBox = ( | ||
<div | ||
className="warning-box" | ||
data-test="list-view-no-photos-in-folder" | ||
> | ||
{MessageNoPhotosInFolder} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
return <>{warningBox}</>; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
0652813
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://starskyapp.netlify.app as production
🚀 Deployed on https://65756c87c999e57677826b12--starskyapp.netlify.app