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

Commit

Permalink
### Version 0.25.0 (Show Entry DBL Id)
Browse files Browse the repository at this point in the history
#### Features
- Show searchable DBL Id in entries
- Save user's workspace entry search results

#### Fixes
- fit entry rows into responsive grid
- fix wait until all entries are loaded before updating search input

(Merge branch 'v0.25.0_dblId')
  • Loading branch information
ericpyle committed Feb 5, 2019
2 parents 67506ab + 5fd9d8f commit cd01a8f
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 74 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### Version 0.25.0 (Show Entry DBL Id)
#### Features
- Show searchable DBL Id in entries
- Save user's workspace entry search results

#### Fixes
- fit entry rows into responsive grid
- fix wait until all entries are loaded before updating search input

### Version 0.24.0 (Change Workspaces location)
#### Features
- Allow user to change workspaces location
Expand Down
19 changes: 17 additions & 2 deletions app/actions/bundleFilter.actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import split from 'split-string';
import { findChunks } from 'highlight-words-core';
import waitUntil from 'node-wait-until';
import { bundleFilterConstants } from '../constants/bundleFilter.constants';
import { workspaceUserSettingsStoreServices } from '../services/workspaces.service';

export const bundleFilterActions = {
updateSearchInput,
Expand All @@ -12,12 +14,25 @@ export default bundleFilterActions;

const canceledState = { isCanceled: true };

function getAreBundlesLoading(getState) {
const { bundles } = getState();
if (bundles === undefined || bundles.loading === undefined) {
return true;
}
const areLoading = bundles.loading;
return areLoading;
}

export function updateSearchInput(searchInput) {
return (dispatch, getState) => {
return async (dispatch, getState) => {
const trimmedSearchInput = searchInput.trim();
const searchKeywords = split(trimmedSearchInput, { separator: ' ' });
await waitUntil(async () => !getAreBundlesLoading(getState));
const { workspaceFullPath, email } = workspaceUserSettingsStoreServices
.getCurrentWorkspaceFullPath(getState());
workspaceUserSettingsStoreServices.saveBundlesSearchInput(workspaceFullPath, email, searchInput);
const { bundles, bundlesFilter } = getState();
if (trimmedSearchInput.length > 0 && !bundles.loading) {
if (trimmedSearchInput.length > 0) {
const willRecomputeAllSearchResults = trimmedSearchInput !== bundlesFilter.searchInput;
dispatch({
type: bundleFilterConstants.UPDATE_SEARCH_INPUT,
Expand Down
4 changes: 2 additions & 2 deletions app/actions/user.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { alertActions } from './';
import { history } from '../store/configureStore';
import dblDotLocalConstants from '../constants/dblDotLocal.constants';
import { dblDotLocalService } from '../services/dbl_dot_local.service';
import { workspacesService } from '../services/workspaces.service';
import { workspaceUserSettingsStoreServices } from '../services/workspaces.service';
import { navigationConstants } from '../constants/navigation.constants';
import { setupBundlesEventSource } from '../actions/bundle.actions';

Expand Down Expand Up @@ -48,7 +48,7 @@ function login(username, password, _workspaceName) {
const whoami = await userService.whoami();
const workspacesLocation = dblDotLocalService.getWorkspacesDir();
const workspaceFullPath = path.join(workspacesLocation, _workspaceName);
workspacesService.saveUserLogin(workspaceFullPath, username);
workspaceUserSettingsStoreServices.saveUserLogin(workspaceFullPath, username);
dispatch(success(user, whoami, _workspaceName));
dispatch(connectSSE(user.auth_token));
dispatch(startPowerMonitor());
Expand Down
1 change: 0 additions & 1 deletion app/components/DBLEntryRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
display: table-cell;
text-align: left;
vertical-align: middle;
width: 75px;
padding-right: 10px;
}

Expand Down
115 changes: 67 additions & 48 deletions app/components/DBLEntryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import classNames from 'classnames';
import { createSelector } from 'reselect';
import LinearProgress from 'material-ui/LinearProgress';
import { Menu, MenuItem, Toolbar, Tooltip } from '@material-ui/core';
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import Badge from '@material-ui/core/Badge';
import VerifiedUserTwoTone from '@material-ui/icons/VerifiedUserTwoTone';
import VerifiedUserOutlined from '@material-ui/icons/VerifiedUserOutlined';
Expand Down Expand Up @@ -408,64 +410,81 @@ class DBLEntryRow extends PureComponent<Props> {
role="button"
style={{ borderBottom: '1px solid lightgray' }}
>
<div className={styles.bundleRowTop}>
<div className={styles.bundleRowTopLeftSideIcon}>
<Tooltip title={medium}>
{ mediumIconMarginRight }
</Tooltip>
</div>
<div className={styles.bundleRowTopLeftSideLanguageAndCountry}>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.languageAndCountry)} className={styles.languageAndCountryLabel} />
</div>
<div className={styles.bundleRowTopLeftSideName}>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.name)} />
</div>
<div className={styles.bundleRowTopMiddle}>
<Tooltip title="Switch revision">
<Button
variant="outlined"
size="small"
className={classNames(classes.button, this.pickBackgroundColor())}
disabled={dblId === undefined}
onClick={this.onClickManageResources('revisions')}
>
{ux.conditionallyRenderBadge(
{ classes: { badge: classes.badgeTight }, color: 'primary' }, laterRevisionsBadge,
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.revision)} />
)}
</Button>
</Tooltip>
</div>
<div className={styles.bundleRowTopMiddle}>
<Grid container justify="space-between" alignItems="center" wrap="nowrap">
<Grid container justify="center" lg={1} md={1} sm={1}>
<Grid item>
<Tooltip title={medium}>
{ mediumIconMarginRight }
</Tooltip>
</Grid>
</Grid>
<Grid item lg={1} md={1} sm={1}>
<div className={styles.bundleRowTopLeftSideLanguageAndCountry}>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.languageAndCountry)} className={styles.languageAndCountryLabel} />
</div>
</Grid>
<Grid item lg={2} md={2} sm={2}>
<Grid container direction="column">
<Grid item>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.name)} />
</Grid>
<Grid item>
<Typography variant="caption">
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.dblId)} />
</Typography>
</Grid>
</Grid>
</Grid>
<Grid container lg={2} md={2} sm={2} justify="flex-end">
<Grid item>
<Tooltip title="Switch revision">
<Button
variant="outlined"
size="small"
className={classNames(classes.button, this.pickBackgroundColor())}
disabled={dblId === undefined}
onClick={this.onClickManageResources('revisions')}
>
{ux.conditionallyRenderBadge(
{ classes: { badge: classes.badgeTight }, color: 'primary' }, laterRevisionsBadge,
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.revision)} />
)}
</Button>
</Tooltip>
</Grid>
</Grid>
<Grid item>
<Tooltip title="license">
<div>
{this.renderLicenseIcon(license)}
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.license)} />
</div>
</Tooltip>
</div>
<div className={styles.bundleRowTopLeftSideName}>
</Grid>
<Grid item lg={2} md={2} sm={2}>
<Tooltip title="Rightsholders">
<div>
<Copyright className={classNames(classes.leftIcon, classes.iconSmall)} />
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.rightsHolders)} />
</div>
</Tooltip>
</div>
<div className={styles.bundleRowTopRightSide}>
{this.showStoredButton() && (
<Button
variant="text"
size="small"
className={classNames(classes.button, this.pickBackgroundColor())}
onClick={this.onClickManageResources(resourceManagerMode)}
>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.status)} />
<Badge badgeContent={ux.getMediumIcon(medium, { className: classNames(classes.rightIcon, classes.iconSmaller) })} >
<Folder className={classNames(classes.rightIcon, classes.iconSmall)} />
</Badge>
</Button>
)}
</Grid>
<Grid container lg={2} md={2} sm={2} justify="flex-end">
<Grid item>
{this.showStoredButton() && (
<Button
variant="text"
size="small"
className={classNames(classes.button, this.pickBackgroundColor())}
onClick={this.onClickManageResources(resourceManagerMode)}
>
<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.status)} />
<Badge badgeContent={ux.getMediumIcon(medium, { className: classNames(classes.rightIcon, classes.iconSmaller) })} >
<Folder className={classNames(classes.rightIcon, classes.iconSmall)} />
</Badge>
</Button>
)}
</Grid>
{this.showStatusAsText() && (
<div style={{ paddingRight: '20px', paddingTop: '6px' }}>
{<ControlledHighlighter {...this.getHighlighterSharedProps(displayAs.status)} />}
Expand All @@ -483,8 +502,8 @@ class DBLEntryRow extends PureComponent<Props> {
<FileDownload className={classNames(classes.rightIcon, classes.iconSmall)} />
</Button>
)}
</div>
</div>
</Grid>
</Grid>
{status === 'IN_PROGRESS' && (
<div
className="row"
Expand Down
4 changes: 2 additions & 2 deletions app/components/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { loadHtmlBaseUrl } from '../actions/dblDotLocalConfig.actions';
import { utilities } from '../utils/utilities';
import MenuAppBar from '../components/MenuAppBar';
import { dblDotLocalService } from '../services/dbl_dot_local.service';
import { workspacesService } from '../services/workspaces.service';
import { workspaceUserSettingsStoreServices } from '../services/workspaces.service';

function mapStateToProps(state, props) {
const { workspaceName } = props.match.params;
Expand Down Expand Up @@ -40,7 +40,7 @@ function getLastUsersLoginSettings(workspaceName) {
return undefined;
}
const workspacePath = path.join(dblDotLocalService.getWorkspacesDir(), workspaceName);
const lastLoginSettings = workspacesService.getLastUserLoginSettings(workspacePath);
const lastLoginSettings = workspaceUserSettingsStoreServices.loadLastUserLoginSettings(workspacePath);
return lastLoginSettings;
}

Expand Down
24 changes: 21 additions & 3 deletions app/components/MenuAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { history } from '../store/configureStore';
import { navigationConstants } from '../constants/navigation.constants';
import { ux } from '../utils/ux';
import { updateSearchInput, clearSearch } from '../actions/bundleFilter.actions';
import { workspaceUserSettingsStoreServices } from '../services/workspaces.service';


function mapStateToProps(state, props) {
Expand All @@ -29,15 +30,18 @@ function mapStateToProps(state, props) {
const { isSearchActive } = bundlesFilter;
const { searchInputRaw } = bundlesFilter;
const { loggedIn, whoami, workspaceName = props.workspaceName } = authentication;
const { display_name: userName = 'DEMO USER' } = whoami || {};
const { workspaceFullPath } = workspaceUserSettingsStoreServices.getCurrentWorkspaceFullPath(state) || {};
const { display_name: userName = 'DEMO USER', email: userEmail } = whoami || {};
return {
loggedIn,
userName,
isLoadingSearch,
isSearchActive,
searchInputRaw,
workspaceName,
clipboard
clipboard,
workspaceFullPath,
userEmail
};
}

Expand All @@ -56,6 +60,8 @@ type Props = {
showSearch?: boolean,
showClipboard?: boolean,
clipboard: ?{},
workspaceFullPath?: string,
userEmail?: string,
updateSearchInput: () => {}
};

Expand Down Expand Up @@ -98,6 +104,16 @@ class MenuAppBar extends React.PureComponent {
anchorEl: null,
};

componentDidMount() {
if (this.props.workspaceFullPath && this.props.userEmail) {
const savedSearchInput = workspaceUserSettingsStoreServices
.loadBundlesSearchInput(this.props.workspaceFullPath, this.props.userEmail);
if (savedSearchInput && savedSearchInput.length > 0) {
this.props.updateSearchInput(savedSearchInput);
}
}
}

handleChange = (event, checked) => {
};

Expand Down Expand Up @@ -201,7 +217,9 @@ class MenuAppBar extends React.PureComponent {

MenuAppBar.defaultProps = {
showSearch: false,
showClipboard: false
showClipboard: false,
workspaceFullPath: undefined,
userEmail: undefined
};

export default compose(
Expand Down
6 changes: 0 additions & 6 deletions app/containers/BundlesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import Bundles from '../components/Bundles';
import MenuAppBar from '../components/MenuAppBar';
import DblDotLocalAppBar from '../components/DblDotLocalAppBar';
import { ux } from '../utils/ux';
import { loadHtmlBaseUrl } from '../actions/dblDotLocalConfig.actions';
import { createNewBundle } from '../actions/bundle.actions';

type Props = {
classes: {},
newMediaTypes: [],
loadHtmlBaseUrl: () => {},
createNewBundle: () => {}
};

Expand All @@ -38,7 +36,6 @@ const materialStyles = () => ({
});

const mapDispatchToProps = {
loadHtmlBaseUrl,
createNewBundle
};

Expand All @@ -47,9 +44,6 @@ class BundlesPage extends PureComponent<Props> {
state = {
anchorEl: null
}
componentDidMount() {
this.props.loadHtmlBaseUrl();
}

handleClick = event => {
this.setState({ anchorEl: event.currentTarget });
Expand Down
2 changes: 1 addition & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nathanael",
"productName": "nathanael",
"version": "0.24.0",
"version": "0.25.0",
"description": "Electron frontend to DBL dot Local",
"main": "./main.prod.js",
"author": {
Expand Down
5 changes: 3 additions & 2 deletions app/reducers/bundles.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ function formatDisplayAs(bundle) {
rightsHolders: bundle.rightsHolders,
license: ['owned', 'open-access'].includes(bundle.license) ? bundle.license : `#${bundle.license}`,
revision: (bundle.dblId ? revision : 'New'),
dblId: bundle.dblId,
status: formatStatus(bundle)
}
};
Expand Down Expand Up @@ -421,15 +422,15 @@ function formatStatus(bundle) {
if (bundle.resourceCountStored) {
newStatusDisplayAs = `Stored (${stored})`;
} else {
newStatusDisplayAs = 'Stored (metadata)';
newStatusDisplayAs = 'Stored';
}
} else if (['SAVETO'].includes(bundle.task) && bundle.status === 'COMPLETED') {
newStatusDisplayAs = 'Open in Folder';
} else if (bundle.status === 'DRAFT') {
if (bundle.resourceCountStored) {
newStatusDisplayAs = `DRAFT (${stored})`;
} else {
newStatusDisplayAs = 'DRAFT (metadata)';
newStatusDisplayAs = 'DRAFT';
}
} else {
newStatusDisplayAs = bundle.statusDisplayAs || bundle.status;
Expand Down
Loading

0 comments on commit cd01a8f

Please sign in to comment.