From ab82dde308174bfc1066c42328bb76980eda34eb Mon Sep 17 00:00:00 2001 From: Evan Krause Date: Thu, 31 Aug 2023 16:32:16 -0700 Subject: [PATCH] Show warning if some files are hidden from commit changed files list Summary: We only send the first 25 files down to the client, so if a commit has more, we don't show them in the UI. We should show a banner explaining that this is happening. We actually need to do this in a few other places too, this diff starts with just the changed files list. Reviewed By: quark-zju Differential Revision: D48812467 fbshipit-source-id: 97fedd25b379124a6547dc24439fd9384cb74b3e --- .../isl/src/CommitInfoView/CommitInfoView.tsx | 3 +- addons/isl/src/UncommittedChanges.css | 5 +++ addons/isl/src/UncommittedChanges.tsx | 21 ++++++++++--- .../isl/src/__tests__/CommitInfoView.test.tsx | 31 +++++++++++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/addons/isl/src/CommitInfoView/CommitInfoView.tsx b/addons/isl/src/CommitInfoView/CommitInfoView.tsx index a81d89d87d..73e99cd920 100644 --- a/addons/isl/src/CommitInfoView/CommitInfoView.tsx +++ b/addons/isl/src/CommitInfoView/CommitInfoView.tsx @@ -331,7 +331,8 @@ export function CommitInfoDetails({commit}: {commit: CommitInfo}) { = { }; export function ChangedFiles(props: { - files: Array; + filesSubset: Array; + totalFiles: number; comparison: Comparison; selection?: UseUncommittedSelection; }) { const displayType = useRecoilValue(changedFilesDisplayType); - const {files, ...rest} = props; - const processedFiles = useDeepMemo(() => processCopiesAndRenames(files), [files]); + const {filesSubset, totalFiles, ...rest} = props; + const processedFiles = useDeepMemo(() => processCopiesAndRenames(filesSubset), [filesSubset]); return (
+ {totalFiles > filesSubset.length ? ( + }> + + Showing first $numShown files out of $total total + + + ) : null} {displayType === 'tree' ? ( ) : ( @@ -566,14 +575,16 @@ export function UncommittedChanges({place}: {place: 'main' | 'amend sidebar' | '
{conflicts != null ? ( ) : ( { expect(amendButton?.disabled).not.toBe(true); }); + it('does not show banner if all files are shown', () => { + expect( + withinCommitInfo().queryByText(/Showing first .* files out of .* total/), + ).not.toBeInTheDocument(); + }); + + it('shows banner if not all files are shown', () => { + act(() => { + simulateCommits({ + value: [ + COMMIT('1', 'some public base', '0', {phase: 'public'}), + COMMIT('a', 'Head Commit', '1', { + isHead: true, + filesSample: new Array(25) + .fill(null) + .map((_, i) => ({path: `src/file${i}.txt`, status: 'M'})), + totalFileCount: 100, + }), + ], + }); + simulateUncommittedChangedFiles({ + value: [], + }); + }); + + expect(withinCommitInfo().queryByText(ignoreRTL('file1.txt'))).toBeInTheDocument(); + expect( + withinCommitInfo().queryByText('Showing first 25 files out of 100 total'), + ).toBeInTheDocument(); + }); + it('runs amend with selected files', async () => { expect(withinCommitInfo().queryByText(ignoreRTL('file1.js'))).toBeInTheDocument(); expect(withinCommitInfo().queryByText(ignoreRTL('file2.js'))).toBeInTheDocument();