-
Notifications
You must be signed in to change notification settings - Fork 316
feat(auth-files): priority display, sorting & credential notes #149
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
Open
RGBadmin
wants to merge
2
commits into
router-for-me:main
Choose a base branch
from
RGBadmin:feat/auth-priority-sort
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ import { | |||||||||
| hasAuthFileStatusMessage, | ||||||||||
| isRuntimeOnlyAuthFile, | ||||||||||
| normalizeProviderKey, | ||||||||||
| parsePriorityValue, | ||||||||||
| type QuotaProviderType, | ||||||||||
| type ResolvedTheme, | ||||||||||
| } from '@/features/authFiles/constants'; | ||||||||||
|
|
@@ -74,6 +75,7 @@ export function AuthFilesPage() { | |||||||||
| const [detailModalOpen, setDetailModalOpen] = useState(false); | ||||||||||
| const [selectedFile, setSelectedFile] = useState<AuthFileItem | null>(null); | ||||||||||
| const [viewMode, setViewMode] = useState<'diagram' | 'list'>('list'); | ||||||||||
| const [sortMode, setSortMode] = useState<'default' | 'az' | 'priority'>('default'); | ||||||||||
| const [batchActionBarVisible, setBatchActionBarVisible] = useState(false); | ||||||||||
| const floatingBatchActionsRef = useRef<HTMLDivElement>(null); | ||||||||||
| const batchActionAnimationRef = useRef<AnimationPlaybackControlsWithThen | null>(null); | ||||||||||
|
|
@@ -281,10 +283,25 @@ export function AuthFilesPage() { | |||||||||
| }); | ||||||||||
| }, [filesMatchingProblemFilter, filter, search]); | ||||||||||
|
|
||||||||||
| const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize)); | ||||||||||
| const sorted = useMemo(() => { | ||||||||||
| if (sortMode === 'default') return filtered; | ||||||||||
| const copy = [...filtered]; | ||||||||||
| if (sortMode === 'az') { | ||||||||||
| copy.sort((a, b) => a.name.localeCompare(b.name)); | ||||||||||
| } else if (sortMode === 'priority') { | ||||||||||
| copy.sort((a, b) => { | ||||||||||
| const pa = parsePriorityValue(a.priority ?? a['priority']) ?? 0; | ||||||||||
| const pb = parsePriorityValue(b.priority ?? b['priority']) ?? 0; | ||||||||||
|
Comment on lines
+293
to
+294
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expressions
Suggested change
|
||||||||||
| return pb - pa; // 高优先级排前面 | ||||||||||
| }); | ||||||||||
| } | ||||||||||
| return copy; | ||||||||||
| }, [filtered, sortMode]); | ||||||||||
|
|
||||||||||
| const totalPages = Math.max(1, Math.ceil(sorted.length / pageSize)); | ||||||||||
| const currentPage = Math.min(page, totalPages); | ||||||||||
| const start = (currentPage - 1) * pageSize; | ||||||||||
| const pageItems = filtered.slice(start, start + pageSize); | ||||||||||
| const pageItems = sorted.slice(start, start + pageSize); | ||||||||||
| const selectablePageItems = useMemo( | ||||||||||
| () => pageItems.filter((file) => !isRuntimeOnlyAuthFile(file)), | ||||||||||
| [pageItems] | ||||||||||
|
|
@@ -559,6 +576,21 @@ export function AuthFilesPage() { | |||||||||
| }} | ||||||||||
| /> | ||||||||||
| </div> | ||||||||||
| <div className={styles.filterItem}> | ||||||||||
| <label>{t('auth_files.sort_label')}</label> | ||||||||||
| <select | ||||||||||
| className={styles.sortSelect} | ||||||||||
| value={sortMode} | ||||||||||
| onChange={(e) => { | ||||||||||
| setSortMode(e.target.value as 'default' | 'az' | 'priority'); | ||||||||||
| setPage(1); | ||||||||||
| }} | ||||||||||
| > | ||||||||||
| <option value="default">{t('auth_files.sort_default')}</option> | ||||||||||
| <option value="az">{t('auth_files.sort_az')}</option> | ||||||||||
| <option value="priority">{t('auth_files.sort_priority')}</option> | ||||||||||
| </select> | ||||||||||
| </div> | ||||||||||
| <div className={`${styles.filterItem} ${styles.filterToggleItem}`}> | ||||||||||
| <label>{t('auth_files.problem_filter_label')}</label> | ||||||||||
| <div className={styles.filterToggle}> | ||||||||||
|
|
@@ -615,7 +647,7 @@ export function AuthFilesPage() { | |||||||||
| </div> | ||||||||||
| )} | ||||||||||
|
|
||||||||||
| {!loading && filtered.length > pageSize && ( | ||||||||||
| {!loading && sorted.length > pageSize && ( | ||||||||||
| <div className={styles.pagination}> | ||||||||||
| <Button | ||||||||||
| variant="secondary" | ||||||||||
|
|
@@ -629,7 +661,7 @@ export function AuthFilesPage() { | |||||||||
| {t('auth_files.pagination_info', { | ||||||||||
| current: currentPage, | ||||||||||
| total: totalPages, | ||||||||||
| count: filtered.length, | ||||||||||
| count: sorted.length, | ||||||||||
| })} | ||||||||||
| </div> | ||||||||||
| <Button | ||||||||||
|
|
||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expression
file.priority ?? file['priority']is redundant. Accessing a property with dot notation (file.priority) is equivalent to using bracket notation (file['priority']) for a valid identifier. You can simplify this for better readability.