🔧 Hardening the import UX

This commit is contained in:
2023-08-23 11:48:13 -05:00
parent debd9a20bf
commit a5c02d3fc6
3 changed files with 25 additions and 17 deletions

View File

@@ -34,8 +34,8 @@ interface IProps {
export const Import = (props: IProps): ReactElement => { export const Import = (props: IProps): ReactElement => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const libraryQueueResults = useSelector( const successfulImportJobCount = useSelector(
(state: RootState) => state.fileOps.librarySearchResultCount, (state: RootState) => state.fileOps.successfulJobCount,
); );
const failedImportJobCount = useSelector( const failedImportJobCount = useSelector(
(state: RootState) => state.fileOps.failedJobCount, (state: RootState) => state.fileOps.failedJobCount,
@@ -149,16 +149,16 @@ export const Import = (props: IProps): ReactElement => {
<tbody> <tbody>
<tr> <tr>
<th> <th>
{libraryQueueResults && ( {successfulImportJobCount > 0 && (
<div className="box has-background-success-light has-text-centered"> <div className="box has-background-success-light has-text-centered">
<span className="is-size-2 has-text-weight-bold"> <span className="is-size-2 has-text-weight-bold">
{libraryQueueResults} {successfulImportJobCount}
</span> </span>
</div> </div>
)} )}
</th> </th>
<td> <td>
{!isUndefined(failedImportJobCount) && ( {failedImportJobCount > 0 && (
<div className="box has-background-danger has-text-centered"> <div className="box has-background-danger has-text-centered">
<span className="is-size-2 has-text-weight-bold"> <span className="is-size-2 has-text-weight-bold">
{failedImportJobCount} {failedImportJobCount}
@@ -171,7 +171,13 @@ export const Import = (props: IProps): ReactElement => {
</tr> </tr>
</tbody> </tbody>
</table> </table>
Imported <span className="has-text-weight-bold">{lastQueueJob}</span> {libraryQueueImportStatus !== "drained" &&
!isUndefined(libraryQueueImportStatus) && (
<>
Imported{" "}
<span className="has-text-weight-bold">{lastQueueJob}</span>
</>
)}
</section> </section>
</div> </div>
); );

View File

@@ -51,11 +51,12 @@ export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS =
"IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS"; "IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS";
export const IMS_COMIC_BOOK_GROUPS_CALL_FAILED = export const IMS_COMIC_BOOK_GROUPS_CALL_FAILED =
"IMS_COMIC_BOOK_GROUPS_CALL_FAILED"; "IMS_COMIC_BOOK_GROUPS_CALL_FAILED";
export const VOLUMES_FETCHED="VOLUMES_FETCHED"; export const VOLUMES_FETCHED = "VOLUMES_FETCHED";
// search results from the Search service // search results from the Search service
export const SS_SEARCH_RESULTS_FETCHED = "SS_SEARCH_RESULTS_FETCHED"; export const SS_SEARCH_RESULTS_FETCHED = "SS_SEARCH_RESULTS_FETCHED";
export const SS_SEARCH_RESULTS_FETCHED_SPECIAL = "SS_SEARCH_RESULTS_FETCHED_SPECIAL"; export const SS_SEARCH_RESULTS_FETCHED_SPECIAL =
"SS_SEARCH_RESULTS_FETCHED_SPECIAL";
export const SS_SEARCH_IN_PROGRESS = "SS_SEARCH_IN_PROGRESS"; export const SS_SEARCH_IN_PROGRESS = "SS_SEARCH_IN_PROGRESS";
export const SS_SEARCH_FAILED = "SS_SEARCH_FAILED"; export const SS_SEARCH_FAILED = "SS_SEARCH_FAILED";
@@ -124,13 +125,15 @@ export const AIRDCPP_TRANSFERS_FETCHED = "AIRDCPP_TRANSFERS_FETCHED";
// Comics marked as "wanted" // Comics marked as "wanted"
export const WANTED_COMICS_FETCHED = "WANTED_COMICS_FETCHED"; export const WANTED_COMICS_FETCHED = "WANTED_COMICS_FETCHED";
// LIBRARY SOCKET ENDPOINT // LIBRARY Service import queue-related action types
export const LS_IMPORT = "LS_IMPORT"; export const LS_IMPORT = "LS_IMPORT";
export const LS_COVER_EXTRACTED = "LS_COVER_EXTRACTED"; export const LS_COVER_EXTRACTED = "LS_COVER_EXTRACTED";
export const LS_COVER_EXTRACTION_FAILED = "LS_COVER_EXTRACTION_FAILED"; export const LS_COVER_EXTRACTION_FAILED = "LS_COVER_EXTRACTION_FAILED";
export const LS_COMIC_ADDED = "LS_COMIC_ADDED"; export const LS_COMIC_ADDED = "LS_COMIC_ADDED";
export const LS_IMPORT_QUEUE_DRAINED = "LS_IMPORT_QUEUE_DRAINED"; export const LS_IMPORT_QUEUE_DRAINED = "LS_IMPORT_QUEUE_DRAINED";
export const LS_SET_QUEUE_STATUS = "LS_SET_QUEUE_STATUS"; export const LS_SET_QUEUE_STATUS = "LS_SET_QUEUE_STATUS";
export const RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION =
"RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION";
// Settings // Settings
export const SETTINGS_CALL_IN_PROGRESS = "SETTINGS_CALL_IN_PROGRESS"; export const SETTINGS_CALL_IN_PROGRESS = "SETTINGS_CALL_IN_PROGRESS";

View File

@@ -35,6 +35,7 @@ import {
HEALTH_STATUS_TICK, HEALTH_STATUS_TICK,
LS_IMPORT_QUEUE_DRAINED, LS_IMPORT_QUEUE_DRAINED,
LS_SET_QUEUE_STATUS, LS_SET_QUEUE_STATUS,
RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION,
} from "../constants/action-types"; } from "../constants/action-types";
import { removeLeadingPeriod } from "../shared/utils/formatting.utils"; import { removeLeadingPeriod } from "../shared/utils/formatting.utils";
import { LIBRARY_SERVICE_HOST } from "../constants/endpoints"; import { LIBRARY_SERVICE_HOST } from "../constants/endpoints";
@@ -62,7 +63,7 @@ const initialState = {
volumes: [], volumes: [],
librarySearchResultsFormatted: [], librarySearchResultsFormatted: [],
lastQueueJob: "", lastQueueJob: "",
librarySearchResultCount: 0, successfulJobCount: 0,
failedJobCount: 0, failedJobCount: 0,
libraryQueueResults: [], libraryQueueResults: [],
librarySearchError: {}, librarySearchError: {},
@@ -160,21 +161,20 @@ function fileOpsReducer(state = initialState, action) {
LSQueueImportStatus: "running", LSQueueImportStatus: "running",
}; };
} }
case LS_COVER_EXTRACTED: { case LS_COVER_EXTRACTED: {
console.log("BASH", action);
if (state.recentComics.length === 5) { if (state.recentComics.length === 5) {
state.recentComics.pop(); state.recentComics.pop();
} }
return { return {
...state, ...state,
librarySearchResultCount: action.completedJobCount, successfulJobCount: action.completedJobCount,
lastQueueJob: action.importResult.rawFileDetails.name, lastQueueJob: action.importResult.rawFileDetails.name,
recentComics: [...state.recentComics, action.importResult], recentComics: [...state.recentComics, action.importResult],
}; };
} }
case LS_COVER_EXTRACTION_FAILED: { case LS_COVER_EXTRACTION_FAILED: {
console.log("FAILED", action);
return { return {
...state, ...state,
failedJobCount: action.failedJobCount, failedJobCount: action.failedJobCount,
@@ -182,19 +182,18 @@ function fileOpsReducer(state = initialState, action) {
} }
case LS_IMPORT_QUEUE_DRAINED: { case LS_IMPORT_QUEUE_DRAINED: {
console.log("drained");
return { return {
...state, ...state,
LSQueueImportStatus: "drained", LSQueueImportStatus: "drained",
}; };
} }
case "RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION": { case RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION: {
console.log(action);
return { return {
...state, ...state,
librarySearchResultCount: action.completedJobCount, successfulJobCount: action.completedJobCount,
failedJobCount: action.failedJobCount, failedJobCount: action.failedJobCount,
LSQueueImportStatus: action.queueStatus,
}; };
} }