Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
### Version 0.28.0 (Navigation Drawer for Resources/Metadata)
Browse files Browse the repository at this point in the history
#### Features
- Add navigation drawer for switching between stored Resources and Metadata
- "Review metadata.xml" (in drawer) now opens in electron's native Chrome browser
- "Review metadata.xml" auto-refreshes when the metadata.xml changes on disk
- "Review metadata.xml" windows allows File > Save To
- dbl_dot_local_app 2/25/2019 (video/braille wizard fixes)

(Merge branch 'add_drawer_navigation')
  • Loading branch information
ericpyle committed Feb 25, 2019
2 parents d46df05 + c8dab5a commit 73a5772
Show file tree
Hide file tree
Showing 27 changed files with 876 additions and 365 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### Version 0.28.0 (Navigation Drawer for Resources/Metadata)
#### Features
- Add navigation drawer for switching between stored Resources and Metadata
- "Review metadata.xml" (in drawer) now opens in electron's native Chrome browser
- "Review metadata.xml" auto-refreshes when the metadata.xml changes on disk
- "Review metadata.xml" windows allows File > Save To
- dbl_dot_local_app 2/25/2019 (video/braille wizard fixes)

### Version 0.27.1
#### Fixes
- Fix crash after deleting draft when trying to re-save starred entries
Expand Down
50 changes: 27 additions & 23 deletions app/actions/bundleEditMetadata.actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import log from 'electron-log';
import waitUntil from 'node-wait-until';
import { bundleEditMetadataConstants } from '../constants/bundleEditMetadata.constants';
import { history } from '../store/configureStore';
import { navigationConstants } from '../constants/navigation.constants';
import { bundleService } from '../services/bundle.service';
import { utilities } from '../utils/utilities';
import editMetadataService from '../services/editMetadata.service';
import { bundleActions } from '../actions/bundle.actions';
import { utilities } from '../utils/utilities';
import { browserWindowService } from '../services/browserWindow.service';

const electron = require('electron');

const { remote = {} } = electron;
const { app } = remote;

export const bundleEditMetadataActions = {
openEditMetadata,
Expand All @@ -19,15 +26,12 @@ export const bundleEditMetadataActions = {
saveMetadata,
saveFieldValuesForActiveForm,
reloadActiveForm,
setArchivistStatusOverrides
setArchivistStatusOverrides,
saveMetadatFileToTempBundleFolder
};

export default bundleEditMetadataActions;

function buildEditMetadataUrl(routeUrl, bundleId) {
return routeUrl.replace(':bundleId', bundleId);
}

async function getFormStructure(_bundleId) {
const response = await bundleService.getFormBundleTree(_bundleId);
return response;
Expand Down Expand Up @@ -139,8 +143,6 @@ export function setArchivistStatusOverrides(_bundleId) {
}
}

const { app } = require('electron').remote;

function getAppMetadataOverrides(formStructure) {
const { id: identificationStatusFormKey } = formStructure.find(section => section.id.endsWith('dentification'));
const bundleProducerDefault = `${app.getName()}/${app.getVersion()}`;
Expand Down Expand Up @@ -200,11 +202,10 @@ export function openEditMetadata(_bundleId, _moveNextStep) {
}
function navigate(bundleToEdit, moveNextStep) {
const { id: bundleId } = bundleToEdit;
const isDemoMode = history.location.pathname === navigationConstants.NAVIGATION_BUNDLES_DEMO;
const editMetadataPage = isDemoMode ?
navigationConstants.NAVIGATION_BUNDLE_EDIT_METADATA_DEMO :
navigationConstants.NAVIGATION_BUNDLE_EDIT_METADATA;
const editMetadataPageWithBundleId = buildEditMetadataUrl(editMetadataPage, bundleId);
const editMetadataPageWithBundleId = utilities.buildRouteUrl(
navigationConstants.NAVIGATION_BUNDLE_EDIT_METADATA,
{ bundleId }
);
history.push(editMetadataPageWithBundleId);
return success(bundleToEdit, moveNextStep);
}
Expand All @@ -224,18 +225,23 @@ export function closeEditMetadata(bundleId) {
}

export function openMetadataFile(bundleId) {
return async dispatch => {
return async (dispatch, getState) => {
dispatch({ type: bundleEditMetadataConstants.METADATA_FILE_SHOW_REQUEST, bundleId });
dispatch({ type: bundleEditMetadataConstants.METADATA_FILE_REQUEST, bundleId });
return dispatch(saveMetadatFileToTempBundleFolder(bundleId));
dispatch(saveMetadatFileToTempBundleFolder(bundleId));
const metadataFile = await waitUntil(
() => getState().bundleEditMetadata.showMetadataFile,
60000,
500
);
browserWindowService.openFileInChromeBrowser(metadataFile, true);
};
}

function saveMetadatFileToTempBundleFolder(bundleId) {
export function saveMetadatFileToTempBundleFolder(bundleId) {
return async dispatch => {
dispatch({ type: bundleEditMetadataConstants.METADATA_FILE_REQUEST, bundleId });
const metadataFile = await bundleService.saveMetadataToTempFolder(bundleId);
await utilities.sleep(1000); // give time for OS to release the file.
dispatch({ type: bundleEditMetadataConstants.METADATA_FILE_SAVED, bundleId, metadataFile });
return metadataFile;
};
Expand All @@ -259,6 +265,8 @@ export function deleteForm(bundleId, formKey, shouldReloadActiveForm) {
} catch (errorReadable) {
const error = await errorReadable.text();
dispatch(failure(error));
} finally {
await bundleService.waitStopCreateMode(bundleId);
}
};
function request() {
Expand All @@ -277,12 +285,7 @@ export function deleteForm(bundleId, formKey, shouldReloadActiveForm) {
}

function switchBackToBundlesPage() {
const isDemoMode =
history.location.pathname === navigationConstants.NAVIGATION_BUNDLE_EDIT_METADATA_DEMO;
const bundlesPage = isDemoMode ?
navigationConstants.NAVIGATION_BUNDLES_DEMO :
navigationConstants.NAVIGATION_BUNDLES;
history.push(bundlesPage);
history.push(navigationConstants.NAVIGATION_BUNDLES);
}

export function reloadActiveForm(shouldUpdateBundleFormErrors = false) {
Expand Down Expand Up @@ -418,6 +421,7 @@ function tryUpdatePublications(formKey, bundleId) {
}
} catch (error) {
log.error(`publication wizards error: ${error}`);
} finally {
await bundleService.waitStopCreateMode(bundleId);
}
};
Expand Down
23 changes: 18 additions & 5 deletions app/actions/bundleManageResources.actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import path from 'path';
import { bundleResourceManagerConstants } from '../constants/bundleResourceManager.constants';
import { navigationConstants } from '../constants/navigation.constants';
import { history } from '../store/configureStore';
import { bundleService } from '../services/bundle.service';
import { dblDotLocalService } from '../services/dbl_dot_local.service';
import { utilities } from '../utils/utilities';
import { openEditMetadata } from './bundleEditMetadata.actions';
import { openEditMetadata, saveMetadatFileToTempBundleFolder } from './bundleEditMetadata.actions';
import { bundleActions } from './bundle.actions';

export const bundleManageResourceActions = {
Expand All @@ -19,6 +18,7 @@ export const bundleManageResourceActions = {

export function openResourceManager(_bundleId, _mode) {
return async (dispatch, getState) => {
await bundleService.waitStopCreateMode(_bundleId);
dispatch(bundleActions.updateBundle(_bundleId, true));
const { addedByBundleIds } = getState().bundles;
const bundleId = _bundleId;
Expand All @@ -33,7 +33,10 @@ export function openResourceManager(_bundleId, _mode) {
}
function navigate(bundleId, mode) {
const manageResourcesUrl =
utilities.buildRouteUrl(navigationConstants.NAVIGATION_BUNDLE_MANAGE_RESOURCES, { bundleId, mode });
utilities.buildRouteUrl(
navigationConstants.NAVIGATION_BUNDLE_MANAGE_RESOURCES,
{ bundleId, mode }
);
history.push(manageResourcesUrl);
return success(bundleId, mode);
}
Expand Down Expand Up @@ -107,7 +110,11 @@ export function checkPublicationsHealth(_bundleId) {
error: 'NO_PUBLICATION_INSTANCE',
publications: [],
errorMessage: `${msgToAddOrRemoveResources}, first add a publication to Publications`,
goFix: () => dispatch(openEditMetadata(_bundleId, { formKey: '/publications/publication' }))
goFix: () => dispatch(openEditMetadata(
_bundleId,
{ formKey: '/publications/publication' },
false
))
});
}
const pubsMissingCanonSpecs = publicationInstanceIds.filter(pubId =>
Expand Down Expand Up @@ -157,7 +164,11 @@ export function checkPublicationsHealth(_bundleId) {
error: 'MISSING_CANON_SPECS',
publications: pubsMissingCanonSpecs,
errorMessage: `${msgToAddOrRemoveResources}, first add Canon Specification (ESPECIALLY Canon Components) to the following publications: ${pubsMissingCanonSpecs}`,
goFix: () => dispatch(openEditMetadata(_bundleId, { formKey: `/publications/publication/${p1}/canonSpec` }))
goFix: () => dispatch(openEditMetadata(
_bundleId,
{ formKey: `/publications/publication/${p1}/canonSpec` },
false
))
};
}
}
Expand Down Expand Up @@ -197,6 +208,7 @@ export function addManifestResources(_bundleId, _fileToContainerPaths, inputMapp
await updatePublications(getState, _bundleId);
await bundleService.waitStopCreateMode(_bundleId);
dispatch(done(_bundleId));
dispatch(saveMetadatFileToTempBundleFolder(_bundleId));
/*
await Promise.all(Object.entries(_fileToContainerPaths)
.map(async ([filePath, containerPath]) => {
Expand Down Expand Up @@ -257,6 +269,7 @@ export function deleteManifestResources(_bundleId, _uris) {
await updatePublications(getState, _bundleId);
await bundleService.waitStopCreateMode(_bundleId);
dispatch(success(_bundleId, _uris));
dispatch(saveMetadatFileToTempBundleFolder(_bundleId));
} catch (error) {
dispatch(failure(_bundleId, error));
}
Expand Down
16 changes: 16 additions & 0 deletions app/components/Conditionally.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Component } from 'react';

type Props = {
showHOC: boolean,
children: React.Node
};

export default class Conditionally extends Component<Props> {
props: Props;
render() {
const { showHOC, children: hoc } = this.props;
return (
<React.Fragment>{showHOC ? hoc : hoc.props.children}</React.Fragment>
);
}
}
4 changes: 2 additions & 2 deletions app/components/DBLEntryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ class DBLEntryRow extends PureComponent<Props> {

onClickManageResources = (mode) => (event) => {
const { bundleId } = this.props;
this.props.openResourceManager(bundleId, mode);
this.props.openResourceManager(bundleId, mode, true);
event.stopPropagation();
}

onClickEditMetadata = (event) => {
const { bundleId } = this.props;
this.props.openEditMetadata(bundleId);
this.props.openEditMetadata(bundleId, undefined, true);
event.stopPropagation();
}

Expand Down
Loading

0 comments on commit 73a5772

Please sign in to comment.