Skip to content
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
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Thanks for contributing! 🦋🙌
- [](# "tags-on-commits-list") [Displays the corresponding tags next to commits.](https://user-images.githubusercontent.com/14323370/66400400-64ba7280-e9af-11e9-8d6c-07b35afde91f.png)
- [](# "mark-merge-commits-in-list") [Marks merge commits in commit lists.](https://user-images.githubusercontent.com/16872793/75561016-457eb900-5a14-11ea-95e1-a89e81ee7390.png)
- [](# "deep-reblame") [When exploring blames, `Alt`-clicking the “Reblame” buttons will extract the associated PR’s commits first, instead of treating the commit a single change.](https://user-images.githubusercontent.com/16872793/77248541-8e3f2180-6c10-11ea-91d4-221ccc0ecebb.png)
- [](# "highlight-deleted-and-added-files-in-diffs") [Indicates with an icon whether files in commits and pull requests being added or removed.](https://user-images.githubusercontent.com/1402241/90332474-23262b00-dfb5-11ea-9a03-8fd676ea0fdd.png)
- [](# "new-or-deleted-file") [Indicates with an icon whether files in commits and pull requests being added or removed.](https://user-images.githubusercontent.com/1402241/90332474-23262b00-dfb5-11ea-9a03-8fd676ea0fdd.png)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New name ok?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't find it as clear as the old one. Maybe new-or-deleted-file-diff-indicator?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature names should no longer be fully descriptive, I'm only renaming long feature names because they're impossible to mention in commits or to remember. See also the other recent renames in options-storage

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #6707

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still think that we should include the word highlight

@fregante fregante May 31, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we're back to square one: highlight-new-or-delete-file is 5-words long and I don’t think it helps much;. The feature search also includes the description so we can always try to add more keywords there (but it already includes the word indicates, like github-actions-indicators does)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the new name isn't very descriptive, but between descriptiveness and brevity we should prefer the latter, as described in #6707.

Alternative short names are welcome; names that are only slightly shorter than what we have aren't enough.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file-diff-type-indicator?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While that sounds correct, it gives me even less information about what the indicator is about. "diff type" == ?

Maybe mark-new-or-deleted-file but that's so long too.

- [](# "easy-toggle-files") [Enables toggling file diffs by clicking on their header bar.](https://user-images.githubusercontent.com/47531779/99855419-be173e00-2b7e-11eb-9a55-0f6251aeb0ef.gif)
- [](# "same-branch-author-commits") [Preserves current branch and path when viewing all commits by an author.](https://user-images.githubusercontent.com/44045911/148764372-ee443213-e61a-4227-9219-0ee54ed832e8.png)
- [](# "easy-toggle-commit-messages") [Enables toggling commit messages by clicking on the commit box.](https://user-images.githubusercontent.com/1402241/152121837-ca13bf8a-9b7f-4517-8e8d-b58bb135523b.gif)
Expand Down
78 changes: 0 additions & 78 deletions source/features/highlight-deleted-and-added-files-in-diffs.tsx

This file was deleted.

53 changes: 53 additions & 0 deletions source/features/new-or-deleted-file.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

function add(filename: HTMLAnchorElement): void {
const list = select('ul[aria-label="File Tree"]');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature used to use this dropdown:

Screenshot 4

but it only appears on PRs and it's actually been relegated to small screens, because the whole dropdown is hidden/duplicate of the sidebar on large screens.

It seems that the sidebar is actually part of the original HTML, so we don't even need to wait for it to load (at least some times)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up not using the API because I figured we'd still have trouble figuring out the exact changes/api to consider in case of single commits and multi-PR-commits. The sidebar is recent enough, hopefully it will last a while.

if (!list && pageDetect.isCommit()) {
// Silence error, single-file commits don't have the file list
return;
}

const fileInList = select(`[href="${filename.hash}"]`, list);
if (!fileInList) {
features.log.error(import.meta.url, 'Could not find file in sidebar, is the sidebar loaded?');
features.unload(import.meta.url);
return;
}

const icon = select('.octicon-diff-removed, .octicon-diff-added', fileInList)
?.cloneNode(true);
if (icon) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a bunch of conditions to have clear errors in case filelists are deferred in big PRs. I can drop the features.log.error condition if anyone finds one such big PR

// `span` needed for native vertical alignment
filename.parentElement!.append(<span className="ml-1">{icon}</span>);
}
}

async function init(signal: AbortSignal): Promise<void> {
// Link--primary excludes CODEOWNERS icon #5565
observe('.file-info a.Link--primary', add, {signal});
}

void features.add(import.meta.url, {
include: [
pageDetect.isPRFiles,
pageDetect.isCommit,
],
init,
});

/*

## Test URLs

Commit: https://github.com/refined-github/sandbox/commit/a00694ff7370d46b5f6d723a0b39141903dae45a
PR: https://github.com/refined-github/sandbox/pull/71/files
PR with CODEOWNERS: https://github.com/dotnet/winforms/pull/6028/files

Note: Not possible with 1-file commits: https://github.com/refined-github/sandbox/commit/1ed862e3abd13004009927b26355a51a109d6855

*/
1 change: 1 addition & 0 deletions source/options-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const renamedFeatures = new Map<string, string>([
['scheduled-and-manual-workflow-indicators', 'github-actions-indicators'],
['useful-forks', 'fork-notice'],
['set-default-repositories-type-to-sources', 'hide-user-forks'],
['highlight-deleted-and-added-files-in-diffs', 'new-or-deleted-file'],
]);

export function isFeatureDisabled(options: RGHOptions, id: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ import './features/clean-repo-filelist-actions.js';
import './features/prevent-duplicate-pr-submission.js';
import './features/quick-label-removal.js';
import './features/clean-conversation-headers.js';
import './features/highlight-deleted-and-added-files-in-diffs.js';
import './features/new-or-deleted-file.js';
import './features/convert-release-to-draft.js';
import './features/new-repo-disable-projects-and-wikis.js';
import './features/table-input.js';
Expand Down