refactor(renderer): organize utils by setchy · Pull Request #2683 · gitify-app/gitify

9 changes: 9 additions & 0 deletions sonar-project.properties

Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ sonar.links.homepage=https://gitify.io
sonar.links.ci=https://github.com/gitify-app/gitify/actions
sonar.links.scm=https://github.com/gitify-app/gitify
sonar.links.issue=https://github.com/gitify-app/gitify/issues


# =====================================================
# Default Rule Ignores
# =====================================================
# Prefer `globalThis` over `window`.
sonar.issue.ignore.multicriteria=globalThisOverWindow
sonar.issue.ignore.multicriteria.globalThisOverWindow.ruleKey=typescript:S7764
sonar.issue.ignore.multicriteria.globalThisOverWindow.resourceKey=**/*

4 changes: 2 additions & 2 deletions src/renderer/components/GlobalShortcuts.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import userEvent from '@testing-library/user-event';

import { navigateMock, renderWithAppContext } from '../__helpers__/test-utils';

import * as comms from '../utils/comms';
import * as links from '../utils/links';
import * as comms from '../utils/system/comms';
import * as links from '../utils/system/links';
import { GlobalShortcuts } from './GlobalShortcuts';

describe('components/GlobalShortcuts.tsx', () => {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/Oops.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EmojiSplash } from './layout/EmojiSplash';

import type { GitifyError } from '../types';

import { Errors } from '../utils/errors';
import { Errors } from '../utils/core/errors';

interface OopsProps {
error: GitifyError;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/Sidebar.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mockMultipleAccountNotifications } from '../__mocks__/notifications-moc
import { mockSettings } from '../__mocks__/state-mocks';

import { useFiltersStore } from '../stores';
import * as comms from '../utils/comms';
import * as comms from '../utils/system/comms';
import { Sidebar } from './Sidebar';

describe('renderer/components/Sidebar.tsx', () => {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/avatars/AvatarWithFallback.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Avatar, Stack, Truncate } from '@primer/react';

import { type Link, Size, type UserType } from '../../types';

import { getDefaultUserIcon } from '../../utils/icons';
import { isNonHumanUser } from '../../utils/notifications/filters/userType';
import { getDefaultUserIcon } from '../../utils/ui/icons';

export interface AvatarWithFallbackProps {
src?: Link;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/fields/Checkbox.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Stack } from '@primer/react';

import { CustomCounter } from '../primitives/CustomCounter';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';
import { Tooltip } from './Tooltip';

export interface CheckboxProps {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/fields/Tooltip.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type FC, type ReactNode, useEffect, useRef, useState } from 'react';
import { QuestionIcon } from '@primer/octicons-react';
import { AnchoredOverlay } from '@primer/react';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';

export interface TooltipProps {
name: string;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/filters/SearchFilter.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { Title } from '../primitives/Title';
import { IconColor, type SearchToken, Size } from '../../types';

import { useFiltersStore } from '../../stores';
import { cn } from '../../utils/cn';
import {
hasExcludeSearchFilters,
hasIncludeSearchFilters,
} from '../../utils/notifications/filters/search';
import { cn } from '../../utils/ui/cn';
import { RequiresDetailedNotificationWarning } from './RequiresDetailedNotificationsWarning';
import { TokenSearchInput } from './TokenSearchInput';

Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/filters/SearchFilterSuggestions.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { useAppContext } from '../../hooks/useAppContext';

import { Opacity } from '../../types';

import { cn } from '../../utils/cn';
import {
ALL_SEARCH_QUALIFIERS,
BASE_SEARCH_QUALIFIERS,
SEARCH_DELIMITER,
} from '../../utils/notifications/filters/search';
import { cn } from '../../utils/ui/cn';

interface SearchFilterSuggestionsProps {
open: boolean;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/icons/LogoIcon.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { APPLICATION } from '../../../shared/constants';

import { Size } from '../../types';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';

interface LogoIconProps {
isDark?: boolean;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/layout/Contents.tsx

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC, ReactNode } from 'react';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';

interface IContents {
children: ReactNode;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/metrics/ReviewsPill.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from 'react';

import type { GitifyPullRequestReview } from '../../types';

import { getPullRequestReviewIcon } from '../../utils/icons';
import { getPullRequestReviewIcon } from '../../utils/ui/icons';
import { MetricPill } from './MetricPill';

export interface ReviewsPillProps {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/notifications/AccountNotifications.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mockSettings } from '../../__mocks__/state-mocks';

import { GroupBy } from '../../types';

import * as links from '../../utils/links';
import * as links from '../../utils/system/links';
import {
AccountNotifications,
type AccountNotificationsProps,
Expand Down

14 changes: 7 additions & 7 deletions src/renderer/components/notifications/AccountNotifications.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import {
} from '../../types';

import { hasMultipleAccounts } from '../../utils/auth/utils';
import { cn } from '../../utils/cn';
import { getChevronDetails } from '../../utils/helpers';
import {
openAccountProfile,
openGitHubIssues,
openGitHubPulls,
} from '../../utils/links';
import {
groupNotificationsByRepository,
isGroupByRepository,
} from '../../utils/notifications/group';
import {
openAccountProfile,
openGitHubIssues,
openGitHubPulls,
} from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { getChevronDetails } from '../../utils/ui/display';
import { AllRead } from '../AllRead';
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
import { Oops } from '../Oops';
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/notifications/NotificationFooter.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mockGitifyNotification } from '../../__mocks__/notifications-mocks';

import type { GitifyNotificationUser, Link } from '../../types';

import * as comms from '../../utils/comms';
import * as comms from '../../utils/system/comms';
import {
NotificationFooter,
type NotificationFooterProps,
Expand Down

4 changes: 2 additions & 2 deletions src/renderer/components/notifications/NotificationFooter.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { RelativeTime, Stack, Text } from '@primer/react';

import { type GitifyNotification, Opacity, Size } from '../../types';

import { cn } from '../../utils/cn';
import { openUserProfile } from '../../utils/links';
import { openUserProfile } from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
import { MetricGroup } from '../metrics/MetricGroup';

Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/notifications/NotificationHeader.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { mockSettings } from '../../__mocks__/state-mocks';

import { GroupBy } from '../../types';

import * as comms from '../../utils/comms';
import * as comms from '../../utils/system/comms';
import {
NotificationHeader,
type NotificationHeaderProps,
Expand Down

4 changes: 2 additions & 2 deletions src/renderer/components/notifications/NotificationHeader.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { useAppContext } from '../../hooks/useAppContext';

import { type GitifyNotification, Opacity, Size } from '../../types';

import { cn } from '../../utils/cn';
import { openRepository } from '../../utils/links';
import { isGroupByDate } from '../../utils/notifications/group';
import { openRepository } from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';

export interface NotificationHeaderProps {
Expand Down

4 changes: 2 additions & 2 deletions src/renderer/components/notifications/NotificationRow.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { mockSettings } from '../../__mocks__/state-mocks';

import { GroupBy } from '../../types';

import * as comms from '../../utils/comms';
import * as links from '../../utils/links';
import * as comms from '../../utils/system/comms';
import * as links from '../../utils/system/links';
import { NotificationRow, type NotificationRowProps } from './NotificationRow';

describe('renderer/components/notifications/NotificationRow.tsx', () => {
Expand Down

6 changes: 3 additions & 3 deletions src/renderer/components/notifications/NotificationRow.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { HoverGroup } from '../primitives/HoverGroup';

import { type GitifyNotification, Opacity, Size } from '../../types';

import { cn } from '../../utils/cn';
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
import { openNotification } from '../../utils/links';
import { isMarkAsDoneFeatureSupported } from '../../utils/api/features';
import { isGroupByDate } from '../../utils/notifications/group';
import { shouldRemoveNotificationsFromState } from '../../utils/notifications/remove';
import { openNotification } from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { NotificationFooter } from './NotificationFooter';
import { NotificationHeader } from './NotificationHeader';
import { NotificationTitle } from './NotificationTitle';
Expand Down

4 changes: 2 additions & 2 deletions src/renderer/components/notifications/NotificationTitle.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Text } from '@primer/react';

import { useAppContext } from '../../hooks/useAppContext';

import { cn } from '../../utils/cn';
import { parseInlineCode } from '../../utils/helpers';
import { cn } from '../../utils/ui/cn';
import { parseInlineCode } from '../../utils/ui/display';

interface NotificationTitleProps {
title: string;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/notifications/RepositoryNotifications.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { mockSettings } from '../../__mocks__/state-mocks';

import type { Link } from '../../types';

import * as comms from '../../utils/comms';
import * as comms from '../../utils/system/comms';
import {
RepositoryNotifications,
type RepositoryNotificationsProps,
Expand Down

8 changes: 4 additions & 4 deletions src/renderer/components/notifications/RepositoryNotifications.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { HoverGroup } from '../primitives/HoverGroup';

import { type GitifyNotification, Opacity, Size } from '../../types';

import { cn } from '../../utils/cn';
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
import { getChevronDetails } from '../../utils/helpers';
import { openRepository } from '../../utils/links';
import { isMarkAsDoneFeatureSupported } from '../../utils/api/features';
import { shouldRemoveNotificationsFromState } from '../../utils/notifications/remove';
import { openRepository } from '../../utils/system/links';
import { cn } from '../../utils/ui/cn';
import { getChevronDetails } from '../../utils/ui/display';
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
import { NotificationRow } from './NotificationRow';

Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/primitives/CustomCounter.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from 'react';

import { Text } from '@primer/react';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';

type CounterScheme = 'primary' | 'secondary' | 'empty';

Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/primitives/EmojiText.tsx

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC, useEffect, useRef } from 'react';

import { convertTextToEmojiImgHtml } from '../../utils/emojis';
import { convertTextToEmojiImgHtml } from '../../utils/ui/emojis';

export interface IEmojiText {
text: string;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/primitives/HoverGroup.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC, ReactNode } from 'react';

import { Stack } from '@primer/react';

import { cn } from '../../utils/cn';
import { cn } from '../../utils/ui/cn';

interface HoverGroupProps {
children: ReactNode;
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/AppearanceSettings.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
import { renderWithAppContext } from '../../__helpers__/test-utils';
import { mockGitHubAppAccount } from '../../__mocks__/account-mocks';

import * as zoom from '../../utils/zoom';
import * as zoom from '../../utils/ui/zoom';
import { AppearanceSettings } from './AppearanceSettings';

describe('renderer/components/settings/AppearanceSettings.tsx', () => {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/AppearanceSettings.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
increaseZoom,
resetZoomLevel,
zoomLevelToPercentage,
} from '../../utils/zoom';
} from '../../utils/ui/zoom';

export const AppearanceSettings: FC = () => {
const { auth, settings, updateSetting } = useAppContext();
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/NotificationSettings.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mockSettings } from '../../__mocks__/state-mocks';

import { Constants } from '../../constants';

import * as comms from '../../utils/comms';
import * as comms from '../../utils/system/comms';
import { NotificationSettings } from './NotificationSettings';

describe('renderer/components/settings/NotificationSettings.tsx', () => {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/NotificationSettings.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
hasAlternateScopes,
hasRecommendedScopes,
} from '../../utils/auth/utils';
import { openGitHubParticipatingDocs } from '../../utils/links';
import { openGitHubParticipatingDocs } from '../../utils/system/links';

export const NotificationSettings: FC = () => {
const navigate = useNavigate();
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/SettingsFooter.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
renderWithAppContext,
} from '../../__helpers__/test-utils';

import * as comms from '../../utils/comms';
import * as comms from '../../utils/system/comms';
import { SettingsFooter } from './SettingsFooter';

describe('renderer/components/settings/SettingsFooter.tsx', () => {
Expand Down

4 changes: 2 additions & 2 deletions src/renderer/components/settings/SettingsFooter.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useShortcutActions } from '../../hooks/useShortcutActions';

import { Footer } from '../primitives/Footer';

import { getAppVersion } from '../../utils/comms';
import { openGitifyReleaseNotes } from '../../utils/links';
import { getAppVersion } from '../../utils/system/comms';
import { openGitifyReleaseNotes } from '../../utils/system/links';

export const SettingsFooter: FC = () => {
const [appVersion, setAppVersion] = useState<string | null>(null);
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/SettingsReset.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event';

import { renderWithAppContext } from '../../__helpers__/test-utils';

import * as logger from '../../utils/logger';
import * as logger from '../../utils/core/logger';
import { SettingsReset } from './SettingsReset';

describe('renderer/components/settings/SettingsReset.tsx', () => {
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/SettingsReset.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, Stack, useConfirm } from '@primer/react';

import { useAppContext } from '../../hooks/useAppContext';

import { rendererLogInfo } from '../../utils/logger';
import { rendererLogInfo } from '../../utils/core/logger';

export const SettingsReset: FC = () => {
const { resetSettings } = useAppContext();
Expand Down

2 changes: 1 addition & 1 deletion src/renderer/components/settings/SystemSettings.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
canIncreaseVolume,
decreaseVolume,
increaseVolume,
} from '../../utils/notifications/sound';
} from '../../utils/system/audio';
import { VolumeDownIcon } from '../icons/VolumeDownIcon';
import { VolumeUpIcon } from '../icons/VolumeUpIcon';

Expand Down

4 changes: 2 additions & 2 deletions src/renderer/context/App.test.tsx

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import type {
import type { DeviceFlowSession } from '../utils/auth/types';

import * as authUtils from '../utils/auth/utils';
import * as storage from '../utils/core/storage';
import * as notifications from '../utils/notifications/notifications';
import * as storage from '../utils/storage';
import * as tray from '../utils/tray';
import * as tray from '../utils/system/tray';
import { type AppContextState, AppProvider } from './App';
import { defaultSettings } from './defaults';

Expand Down