+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
bfebd43
Add JSDoc comment for VirtualMetafile type
nelsonni Jan 4, 2023
25d5d93
Log Redux action.payload values on reject event
nelsonni Jan 4, 2023
d6bd822
Add `direct` option to metafileSelectors.selectByRoot to further cons…
nelsonni Jan 10, 2023
ce76411
isHydrated replaced by hasFilebasedUpdates to properly distinguish be…
nelsonni Jan 10, 2023
e76d854
shallowMetafilesEqualityFn prevents unnecessary re-renders when only …
nelsonni Jan 10, 2023
1b64d14
isUpdateable renamed to hasUpdates to adhere to @typescript-eslint/na…
nelsonni Jan 10, 2023
f3e233f
FileMetafile and DirectoryMetafile types updated to include `mtime` t…
nelsonni Jan 11, 2023
5cbd1e6
Fix updateFilebasedMetafile to check against `filetype` when determin…
nelsonni Jan 11, 2023
df19432
Convert getSourceMotif and getBranchMotif functions to custom React H…
nelsonni Jan 11, 2023
19698cd
Add metafileSelectors.selectDescendants selector for locating and spl…
nelsonni Jan 11, 2023
418bc09
Switch to useFileMotif hook instead of getSourceMotif function
nelsonni Jan 11, 2023
1718eec
Update mocked FileMetafile and DirectoryMetafile instances with `mtim…
nelsonni Jan 11, 2023
8d13395
Card components standardized on using `metafileId` props instead of p…
nelsonni Jan 12, 2023
88802f8
Tests updated for hasFilebasedUpdates to replace isHydrated function
nelsonni Jan 12, 2023
608c2b5
test:coverage split into test:coverage for individual files and test:…
nelsonni Jan 12, 2023
7d3b5d5
Default view set to `metadata` instead of `branches` to always displa…
nelsonni Jan 12, 2023
c67d3db
Fix for fileOpenDialog shim to resolve duplicate repository creation …
nelsonni Jan 16, 2023
870088b
Expand functionality of isVersionedMetafile to also check whether met…
nelsonni Jan 16, 2023
016aa5a
Remove unused import statement
nelsonni Jan 16, 2023
8ccfd14
showCache displays Cache entries from Redux store and FSCache instanc…
nelsonni Jan 16, 2023
07746b0
Renamed Return type to ReturnMap for clarity in FSCache context
nelsonni Jan 16, 2023
f6c7914
Listen for cache updates that indicate filesystem changes that should…
nelsonni Jan 16, 2023
5714f22
FileComponent retooled to be completely reactive to Redux store chang…
nelsonni Jan 16, 2023
ffdc366
FSCache split into FSCacheContext, FSCacheServices, and FSCacheProvid…
nelsonni Jan 16, 2023
4ae3f20
filteredEquility compares objects on specified properties only
nelsonni Jan 27, 2023
68d7838
filteredArrayEquality compares arrays of objects on specified propert…
nelsonni Jan 30, 2023
6796a58
Remove console.log call in filteredArrayEquality
nelsonni Jan 30, 2023
ee42af6
Rename filteredEquality to filteredObjectEquality to clarify usage
nelsonni Feb 7, 2023
fc33e92
Redux selectors migrated to re-reselect for performance improvements …
nelsonni Feb 14, 2023
4d829dd
cardUpdated reducer action uses reducer() and prepare() functions to …
nelsonni Feb 14, 2023
220e430
Simplified fetchMetafile async thunk and expanded tests
nelsonni Feb 14, 2023
046f960
Fix for wortkreePrune being unable to run during thunks/repos testing
nelsonni Feb 14, 2023
dfc1adf
Updated call sites for selectors that have signature changes from fc3…
nelsonni Feb 14, 2023
df942d9
Additional call signature updates from fc33e92939621e4aa89b9796748304…
nelsonni Feb 14, 2023
e6ec91a
Explorer updates to simplify React components and test suite
nelsonni Feb 14, 2023
0acaef5
Fixes for failing Editor tests
nelsonni Feb 14, 2023
a387cb7
Updated JSDoc comment for io.isDescendant
nelsonni Feb 14, 2023
db1f16f
revParse expanded to support --abbrev-ref option
nelsonni Feb 15, 2023
e45895c
CSS .unmerged renamed to .flagged to better document usage
nelsonni Feb 17, 2023
195cd78
Simplify branches/fetchBranch thunk for reduced runtime overhead
nelsonni Feb 18, 2023
1f8d999
revParse is significantly faster than listBranch for finding the curr…
nelsonni Feb 18, 2023
a926884
removeUndefinedProperties replaced with removeNullableProperties func…
nelsonni Feb 22, 2023
c3e434e
removeNullableProperties removes nullable props with NonNullablePrope…
nelsonni Feb 22, 2023
9e06258
removeNullableProperties fn properly conveys inaccessible nullable pr…
nelsonni Feb 22, 2023
5fac0c1
Safely resolve return types of utils.deserialize with satisfies keywo…
nelsonni Feb 24, 2023
eb8d476
Expand<T> and ExpandRecursively<T> utility types for expanding and re…
nelsonni Feb 24, 2023
99c4496
Resolve BranchOutput type for human-readable type hinting
nelsonni Feb 28, 2023
f6ed175
removeUndefinedProperties renaming to removeNullableProperties
nelsonni Mar 1, 2023
341ff52
git.showBranch implementation of git-show-branch for faster processin…
nelsonni Mar 1, 2023
a29a4df
git.getRemote implementation of git-remote for parsing tracked remote…
nelsonni Mar 1, 2023
093af9f
Improved link format in JSDoc comments
nelsonni Mar 1, 2023
1ae7795
removeUndefinedProperties to removeNullableProperties renaming
nelsonni Mar 1, 2023
d7abf4d
Expand BranchOutput type to remove Partial<Omit<Branch..>>> subtypes …
nelsonni Mar 1, 2023
316412c
Improved typing of BranchIdentifiers
nelsonni Mar 1, 2023
c261d16
hasFilebasedUpdates function for simplified determinations of potenti…
nelsonni Mar 1, 2023
8999805
Remove shallowMetafilesEqualityFn and relocate hasFilebasedUpdates fu…
nelsonni Mar 1, 2023
e76ae87
Expand thunks/branches test suite to include fetchBranches
nelsonni Mar 1, 2023
e63ecf4
git-remote and git-show-branch added to git namespace
nelsonni Mar 1, 2023
b0f1e45
fetchRepo simplified to check for existing branch with matching root …
nelsonni Mar 1, 2023
b009723
Replace git.listBranch with git.revParse for determining current bran…
nelsonni Mar 1, 2023
4c29c6e
Updated test mocks for git.showBranch instead of git.listBranch
nelsonni Mar 2, 2023
c786b2c
Set `end_of_line` to `lf` in .editorconfig
nelsonni Apr 5, 2023
ef92a78
Add .gitattributes file for setting automatic LF line endings
nelsonni Apr 5, 2023
05d59e8
Adding Prettier for opinionated code formatting
nelsonni Apr 5, 2023
23e2e8e
Add `redux-logger` for capturing detailed action and state information
nelsonni Apr 5, 2023
d1a69f3
Fix incorrectly named thunks/cache test case
nelsonni Apr 5, 2023
4614946
Enable `redux-logger` to capture all actions except `filetypes/` and …
nelsonni Apr 5, 2023
508e70a
Rename Cache actions to avoid naming collisions with NodeJS built-ins…
nelsonni Apr 5, 2023
bc72a36
Temporary Subscribe button for handling sub/unsub events for Cards ne…
nelsonni Apr 5, 2023
8769f80
Code format changes to adhere to Prettier line widths
nelsonni Apr 5, 2023
e45d13b
Temporary debugger console.log outputs, code formatting via Prettier,…
nelsonni Apr 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = false
insert_final_newline = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"endOfLine": "lf",
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"arrowParens": "avoid"
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"postversion": "git push --atomic --tags",
"lint": "eslint --ext .ts,.tsx .",
"test": "jest",
"test:coverage": "jest --coverage --collectCoverageFrom=\"./src/**\"",
"test:coverage": "jest --coverage --collectCoverageFrom=",
"test:coverageAll": "jest --coverage --collectCoverageFrom=\"./src/**\"",
"clean": "fse remove out; fse remove .webpack; fse remove dist",
"clean:tests": "jest --clearCache; fse remove coverage/",
"clean:builds": "yarn cache clean; yarn cache clean --mirror; fse remove yarn-error.log",
Expand Down Expand Up @@ -61,6 +62,7 @@
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.3",
"@types/react-transition-group": "^4.4.5",
"@types/redux-logger": "^3.0.9",
"@types/redux-mock-store": "^1.0.3",
"@types/semver": "^7.3.13",
"@types/sha1": "^1.1.3",
Expand Down Expand Up @@ -121,6 +123,7 @@
"parse-git-config": "^3.0.0",
"parse-path": "^7.0.0",
"parse-url": "^8.1.0",
"re-reselect": "^4.0.1",
"react": "^17.0.2",
"react-ace": "^10.1.0",
"react-dnd": "^15.1.1",
Expand All @@ -131,7 +134,9 @@
"react-transition-group": "^4.4.5",
"reactflow": "^11.4.0",
"redux": "^4.2.0",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"reselect": "^4.1.7",
"semver": "^7.3.8",
"sha1": "^1.1.1",
"uuid": "^9.0.0"
Expand Down
6 changes: 3 additions & 3 deletions src/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ body {
align-items: center;
}

.card-header.unmerged {
.card-header.flagged {
background: rgba(218, 100, 115, 1);
}

.card-header.unmerged .title {
.card-header.flagged .title {
color: rgba(0, 0, 0, 0.54);
}

Expand Down Expand Up @@ -274,7 +274,7 @@ img.diff_icon {
color: rgb(200, 210, 220);
}

.branch-ribbon-container.unmerged {
.branch-ribbon-container.flagged {
background-color: rgba(218, 100, 115, 1);
color: rgba(0, 0, 0, 0.54);
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/Branches/BranchItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DeleteForever as Delete } from '@material-ui/icons';
import React from 'react';
import { ConnectableElement, DropTargetMonitor, useDrag, useDrop } from 'react-dnd';
import { v4 } from 'uuid';
import { getBranchMotif } from '../../containers/motif';
import { removeUndefinedProperties } from '../../containers/utils';
import { useBranchMotif } from '../../containers/hooks/useMotif';
import { removeNullableProperties } from '../../containers/utils';
import { useAppDispatch, useAppSelector } from '../../store/hooks';
import branchSelectors from '../../store/selectors/branches';
import repoSelectors from '../../store/selectors/repos';
Expand Down Expand Up @@ -31,6 +31,7 @@ const BranchItem = ({ repoId, branchId, deletable = false, highlight = false, on
const branches = useAppSelector(state => branchSelectors.selectEntities(state));
const branch = useAppSelector(state => branchSelectors.selectById(state, branchId));
const repo = useAppSelector(state => repoSelectors.selectById(state, repoId));
const motif = useBranchMotif(branch);
const dispatch = useAppDispatch();

// Enable BranchItem as a drop source (i.e. allowing this component to be draggable)
Expand Down Expand Up @@ -83,8 +84,7 @@ const BranchItem = ({ repoId, branchId, deletable = false, highlight = false, on
}
}

const motif = branch ? getBranchMotif(branch) : undefined;
const optionals = removeUndefinedProperties({
const optionals = removeNullableProperties({
color: motif?.color,
labelInfo: deletable ? Delete : undefined,
labelInfoClickHandler: deletable ? handleLabelInfoClick : undefined
Expand Down
4 changes: 2 additions & 2 deletions src/components/Branches/BranchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BranchList = ({ cardId, repoId }: { cardId: UUID, repoId: UUID }) => {
const card = useAppSelector(state => cardSelectors.selectById(state, cardId));
const metafile = useAppSelector(state => metafileSelectors.selectById(state, card?.metafile ?? ''));
const repo = useAppSelector(state => repoSelectors.selectById(state, repoId));
const repoBranches = useAppSelector(state => branchSelectors.selectByRepo(state, repo, true));
const repoBranches = useAppSelector(state => branchSelectors.selectByRepo(state, repo?.id ?? '', true));
const branches = repoBranches.filter(branch => branch.ref !== 'HEAD').sort((a, b) => a.ref.localeCompare(b.ref));
const dispatch = useAppDispatch();

Expand All @@ -41,7 +41,7 @@ const BranchList = ({ cardId, repoId }: { cardId: UUID, repoId: UUID }) => {
console.log(`checkout: ${branchRef}`);
if (card && metafile && repo) {
try {
const updated = await dispatch(switchBranch({ metafileId: metafile.id, ref: branchRef, root: repo.root })).unwrap();
const updated = await dispatch(switchBranch({ metafileId: metafile.id, cardId: card.id, ref: branchRef, root: repo.root })).unwrap();
if (updated) dispatch(cardUpdated({
...card,
name: updated.name,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Branches/BranchRibbon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const BranchRibbon = ({ metafile, onClick }: { metafile: Metafile | undefined, o
<div onClick={onClick}
className={clsx('branch-ribbon-container', {
'preview': loading,
'unmerged': branch?.status === 'unmerged',
'flagged': branch?.status === 'unmerged',
})}>
{loading ?
<Skeleton variant='rect' aria-label='loading' animation='wave'>
Expand Down
17 changes: 1 addition & 16 deletions src/components/Branches/BranchSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@ import { Repository } from '../../store/slices/repos';
import { UUID } from '../../store/types';
import { Branch } from '../../store/slices/branches';

const emptyRepo: Repository = {
id: '',
name: '',
root: '',
corsProxy: '',
url: '',
default: '',
local: [],
remote: [],
oauth: 'github',
username: '',
password: '',
token: ''
}

type BranchSelectProps = {
label: string;
repo: Repository | undefined;
Expand All @@ -30,7 +15,7 @@ type BranchSelectProps = {
}

const BranchSelect = (props: BranchSelectProps) => {
const branches = useAppSelector(state => branchSelectors.selectByRepo(state, props.repo ? props.repo : emptyRepo, true));
const branches = useAppSelector(state => branchSelectors.selectByRepo(state, props.repo?.id ?? '', true));
const branchLookup = useAppSelector(state => branchSelectors.selectEntities(state));
const predicate = props.optionsFilter ? props.optionsFilter : undefined; // Cannot descriminate types from variables; see https://github.com/microsoft/TypeScript/issues/10530
const options = (predicate ? branches.filter(b => predicate(b)) : branches).map(b => { return { label: b.id, value: b.ref }; });
Expand Down
82 changes: 44 additions & 38 deletions src/components/Branches/Branches.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
import { makeStyles } from '@material-ui/core';
import { ArrowDropDown, ArrowRight, Error } from '@material-ui/icons';
import { TreeView } from '@material-ui/lab';
import React from 'react';
import { useAppSelector } from '../../store/hooks';
import repoSelectors from '../../store/selectors/repos';
import { StyledTreeItem } from '../StyledTreeComponent';
import RepoItem from './RepoItem';
import { makeStyles } from "@material-ui/core";
import { ArrowDropDown, ArrowRight, Error } from "@material-ui/icons";
import { TreeView } from "@material-ui/lab";
import React from "react";
import { useAppSelector } from "../../store/hooks";
import repoSelectors from "../../store/selectors/repos";
import { StyledTreeItem } from "../StyledTreeComponent";
import RepoItem from "./RepoItem";

export const useStyles = makeStyles({
formControl: {
color: 'rgba(171, 178, 191, 1.0)',
fontSize: 'small',
fontFamily: '\'Lato\', Georgia, Serif',
},
formControl: {
color: "rgba(171, 178, 191, 1.0)",
fontSize: "small",
fontFamily: "'Lato', Georgia, Serif",
},
});

/**
* React Component to display a list of git repositories and the local and remote branches tracked within them.
*
*
* @returns {React.Component} A React function component.
*/
const Branches = () => {
const repos = useAppSelector(state => repoSelectors.selectAll(state));
const [expanded, setExpanded] = React.useState(repos[0] ? [repos[0].id] : []); // initial state; expand first listed repo
const repos = useAppSelector((state) => repoSelectors.selectAll(state));
const [expanded, setExpanded] = React.useState(repos[0] ? [repos[0].id] : []); // initial state; expand first listed repo

const handleToggle = (_event: React.ChangeEvent<Record<string, unknown>>, nodeIds: string[]) => setExpanded(nodeIds);
const handleToggle = (
_event: React.ChangeEvent<Record<string, unknown>>,
nodeIds: string[]
) => setExpanded(nodeIds);

return (
<div className='list-component'>
<TreeView
defaultCollapseIcon={<ArrowDropDown />}
defaultExpandIcon={<ArrowRight />}
defaultEndIcon={<div style={{ width: 8 }} />}
expanded={expanded}
onNodeToggle={handleToggle}
>
{repos.length == 0 &&
<StyledTreeItem key={'no-repo'} nodeId={'no-repo'}
labelText={'[no repos tracked]'}
labelIcon={Error}
/>
}
{repos.length > 0 && repos.map(repo => <RepoItem key={repo.id} repoId={repo.id} />)}
</TreeView>
</div>
);
}
return (
<div className="list-component">
<TreeView
defaultCollapseIcon={<ArrowDropDown />}
defaultExpandIcon={<ArrowRight />}
defaultEndIcon={<div style={{ width: 8 }} />}
expanded={expanded}
onNodeToggle={handleToggle}
>
{repos.length == 0 && (
<StyledTreeItem
key={"no-repo"}
nodeId={"no-repo"}
labelText={"[no repos tracked]"}
labelIcon={Error}
/>
)}
{repos.length > 0 &&
repos.map((repo) => <RepoItem key={repo.id} repoId={repo.id} />)}
</TreeView>
</div>
);
};

export default Branches;
export default Branches;
2 changes: 1 addition & 1 deletion src/components/Branches/RepoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { fetchMetafile } from '../../store/thunks/metafiles';

const RepoItem = (props: { repoId: string }) => {
const repo = useAppSelector(state => repoSelectors.selectById(state, props.repoId));
const branches = useAppSelector(state => branchSelectors.selectByRepo(state, repo, true));
const branches = useAppSelector(state => branchSelectors.selectByRepo(state, repo?.id ?? '', true));
const sortedBranches = branches.filter(branch => branch.ref !== 'HEAD').sort((a, b) => a.ref.localeCompare(b.ref));
const dispatch = useAppDispatch();

Expand Down
2 changes: 1 addition & 1 deletion src/components/Browser/Browser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Browser from './Browser';
describe('Browser', () => {

it('Browser component is rendered', async () => {
render(<Browser card='1' />);
render(<Browser metafileId='1' />);
expect(screen.getByPlaceholderText('URL')).toBeInTheDocument();
});

Expand Down
17 changes: 9 additions & 8 deletions src/components/Browser/Browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useCallback, useEffect } from 'react';
import { makeStyles } from '@material-ui/core';
import { useHistory } from '../../containers/hooks/useHistory';
import UrlBar from './UrlBar';
import { UUID } from '../../store/types';

const useStyles = makeStyles((theme) => ({
webviewContent: {
Expand All @@ -16,18 +17,18 @@ const useStyles = makeStyles((theme) => ({

type Mode = 'light' | 'dark';

const Browser = ({ card, mode = 'dark' }: { card: string, mode?: Mode }) => {
const Browser = ({ metafileId: id, mode = 'dark' }: { metafileId: UUID, mode?: Mode }) => {
const styles = useStyles({ mode: mode });
const { state, set, goBack, goForward, canGoBack, canGoForward } = useHistory(new URL('https://epiclab.github.io/'));

const refresh = () => {
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${card}-webview"]`);
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${id}-webview"]`);
webview?.reload();
}

const go = (url: URL) => {
if (state.present.href !== url.href) {
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${card}-webview"]`);
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${id}-webview"]`);
webview?.loadURL(url.href);
set(url);
}
Expand All @@ -37,7 +38,7 @@ const Browser = ({ card, mode = 'dark' }: { card: string, mode?: Mode }) => {
if (canGoBack) {
const url = state.past[state.past.length - 1] as URL;
goBack();
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${card}-webview"]`);
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${id}-webview"]`);
webview?.loadURL(url.href);
}
}
Expand All @@ -46,7 +47,7 @@ const Browser = ({ card, mode = 'dark' }: { card: string, mode?: Mode }) => {
if (canGoForward) {
const url = state.future[0] as URL;
goForward();
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${card}-webview"]`);
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${id}-webview"]`);
webview?.loadURL(url.href);
}
}
Expand All @@ -56,13 +57,13 @@ const Browser = ({ card, mode = 'dark' }: { card: string, mode?: Mode }) => {
}, [set, state.present.href]);

useEffect(() => {
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${card}-webview"]`);
const webview: Electron.WebviewTag | null = document.querySelector(`[id="${id}-webview"]`);
webview?.addEventListener('did-navigate', handleNavigationEvent);
return () => {
webview?.removeEventListener('did-navigate', handleNavigationEvent);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [card]);
}, [id]);

return (
<>
Expand All @@ -71,7 +72,7 @@ const Browser = ({ card, mode = 'dark' }: { card: string, mode?: Mode }) => {
canGoForward={canGoForward} forward={forward}
/>
<div className={styles.webviewContent}>
<webview id={`${card}-webview`} src={'https://epiclab.github.io/'}
<webview id={`${id}-webview`} src={'https://epiclab.github.io/'}
style={{ height: '100%', width: '100%', borderRadius: '10px!important' }} />
</div>
</>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Button/Commit.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { v4 } from 'uuid';
import { IconButton, Tooltip } from '@material-ui/core';
import { Done } from '@material-ui/icons';
Expand Down Expand Up @@ -27,6 +27,8 @@ import { isStaged } from '../../containers/utils';
const CommitButton = ({ cardIds, enabled = true, mode = 'light' }: { cardIds: UUID[], enabled?: boolean, mode?: Mode }) => {
const cards = useAppSelector(state => cardSelectors.selectByIds(state, cardIds));
const metafiles = useAppSelector(state => metafileSelectors.selectByIds(state, cards.map(c => c.metafile)));
// const selectByIds = useMemo(metafileSelectors.makeSelectByIds, []); // create a memoized selector for each component instance, on mount
// const metafiles = useAppSelector(state => selectByIds(state, cards.map(c => c.metafile)));
const staged = metafiles.filter(m => isVersionedMetafile(m) && isStaged(m.status));
const classes = useIconButtonStyle({ mode: mode });
const dispatch = useAppDispatch();
Expand Down
9 changes: 5 additions & 4 deletions src/components/Button/Refresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Refresh } from '@material-ui/icons';
import React from 'react';
import { useAppDispatch, useAppSelector } from '../../store/hooks';
import metafileSelectors from '../../store/selectors/metafiles';
import { isFilebasedMetafile, isVersionedMetafile } from '../../store/slices/metafiles';
import { isFilebasedMetafile } from '../../store/slices/metafiles';
import { updateFilebasedMetafile, updateVersionedMetafile } from '../../store/thunks/metafiles';
import { UUID } from '../../store/types';
import { Mode, useIconButtonStyle } from './useStyledIconButton';
import { isDefined } from '../../containers/utils';

/**
* Button for refreshing filebased and versioned fields in metafiles.
Expand All @@ -25,9 +26,9 @@ const RefreshButton = ({ metafileIds, enabled = true, mode = 'light' }: { metafi
const refresh = async (event: React.MouseEvent) => {
event.stopPropagation(); // prevent propogating the click event to underlying components that might have click event handlers
return await Promise.all(metafiles.map(async metafile => {
if (metafile) {
if (isFilebasedMetafile(metafile)) await dispatch(updateFilebasedMetafile(metafile));
if (isVersionedMetafile(metafile)) await dispatch(updateVersionedMetafile(metafile));
if (isDefined(metafile) && isFilebasedMetafile(metafile)) {
await dispatch(updateFilebasedMetafile(metafile));
await dispatch(updateVersionedMetafile(metafile));
}
}));
}
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载