Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(uploads): SJIP-1091 display raw input for unmatch list #554

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions packages/ui/Release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 10.14.1 2024-11-14
- fix: SJIP-1091 display raw input for upload ids

### 10.14.0 2024-11-14
- feat: SJIP-1090 Add text transform mode to uploads modal. Update antd to 4.24.16

Expand Down
18 changes: 9 additions & 9 deletions packages/ui/package-lock.json

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

4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ferlab/ui",
"version": "10.14.0",
"version": "10.14.1",
"description": "Core components for scientific research data portals",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -117,7 +117,7 @@
"md5": "^2.3.0",
"npm": "^10.8.2",
"query-string": "^7.0.1",
"react-grid-layout": "^1.4.4",
"react-grid-layout": "^1.5.0",
"react-highlight-words": "^0.18.0",
"react-icons": "^4.2.0",
"react-sizeme": "^3.0.2",
Expand Down
40 changes: 26 additions & 14 deletions packages/ui/src/components/UploadIds/UploadModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,38 @@ const UploadModal = ({
const [unmatch, setUnmatch] = useState<UnmatchTableItem[] | undefined>(undefined);
const debouncedValue = useDebounce(value, 500);

const getRawValueList = () => {
let result = value.split(/[\n,\r ]/).filter((val) => !!val);
const getRawValueList = () => value.split(/[\n,\r ]/).filter((val) => !!val);
const getValueList = () =>
uniq(
getRawValueList().map((val) => {
if (textTransformMode === TextTransformMode.LOWER) {
return val.toLowerCase();
} else if (textTransformMode === TextTransformMode.UPPER) {
return val.toUpperCase();
}
return val;
}),
);

if (textTransformMode === TextTransformMode.LOWER) {
result = result.map((val) => val.toLowerCase());
} else if (textTransformMode === TextTransformMode.UPPER) {
result = result.map((val) => val.toUpperCase());
}

return result;
};
const getValueList = () => uniq(getRawValueList());

const getUnmatchList = (results: MatchTableItem[]) =>
difference(
const getUnmatchList = (results: MatchTableItem[]) => {
const rawList = getRawValueList();
const unmatchs = difference(
getValueList(),
results.map((item) => item.submittedId),
).map((id, index) => ({
key: index,
submittedId: id,
}));

return unmatchs.map((unmatch) => {
const submittedId = rawList.find((val) => val.toLowerCase() === unmatch.submittedId.toLowerCase());
return {
key: unmatch.key,
submittedId: submittedId ?? unmatch.submittedId,
};
});
};

const getMatchToCount = (match: MatchTableItem[]) =>
without(
uniqBy(match, ({ matchTo }) => matchTo).map(({ matchTo }) => matchTo),
Expand All @@ -103,6 +113,8 @@ const UploadModal = ({
setIsLoading(true);
const results = await fetchMatch(getValueList());
setMatch(results);

// use raw list
setUnmatch(getUnmatchList(results));
setIsLoading(false);
})();
Expand Down
Loading