Skip to content

Commit

Permalink
Rename "foundPlatform" -> "platform"
Browse files Browse the repository at this point in the history
Summary: The variable for the platform used in platform.ts was `foundPlatform`, because it checks for `window.islPlatform`. That's fine, but autocomplete ends up naming the default export as `foundPlatform` everywhere this gets used. Let's simplify and rename to just `platform`, for consistency.

Reviewed By: zzl0

Differential Revision: D64487453

fbshipit-source-id: e0bb544719cba82f2c60543c79ea98d5bdd3b215
  • Loading branch information
evangrayk authored and facebook-github-bot committed Oct 17, 2024
1 parent 2e8cca6 commit afcd85b
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions addons/isl/src/BrowseRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {Comparison} from 'shared/Comparison';

import serverAPI from './ClientToServerAPI';
import {configBackedAtom} from './jotaiUtils';
import foundPlatform from './platform';
import platform from './platform';
import {copyAndShowToast, showToast} from './toast';
import {revsetForComparison} from 'shared/Comparison';

Expand All @@ -32,7 +32,7 @@ export async function openBrowseUrlForHash(hash: Hash) {
} else if (url.value == null) {
return;
}
foundPlatform.openExternalLink(url.value);
platform.openExternalLink(url.value);
}

export async function copyUrlForFile(path: RepoRelativePath, comparison: Comparison) {
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/CommitInfoView/FillCommitMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {Internal} from '../Internal';
import {tracker} from '../analytics';
import {T, t} from '../i18n';
import {readAtom, writeAtom} from '../jotaiUtils';
import foundPlatform from '../platform';
import platform from '../platform';
import {dagWithPreviews} from '../previews';
import {layout} from '../stylexUtils';
import {useModal} from '../useModal';
Expand Down Expand Up @@ -107,7 +107,7 @@ export function FillCommitMessage({commit, mode}: {commit: CommitInfo; mode: Com
{
label: t('Clear commit message'),
onClick: async () => {
const confirmed = await foundPlatform.confirm(
const confirmed = await platform.confirm(
t('Are you sure you want to clear the currently edited commit message?'),
);
if (confirmed) {
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/ComparisonView/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type {Comparison} from 'shared/Comparison';

import {writeAtom} from '../jotaiUtils';
import foundPlatform from '../platform';
import platform from '../platform';
import {atom} from 'jotai';
import {ComparisonType} from 'shared/Comparison';

Expand All @@ -27,7 +27,7 @@ export const currentComparisonMode = atom<ComparisonMode>(

/** Open Comparison View for a given comparison type */
export async function showComparison(comparison: Comparison) {
if (await foundPlatform.openDedicatedComparison?.(comparison)) {
if (await platform.openDedicatedComparison?.(comparison)) {
return;
}
writeAtom(currentComparisonMode, {comparison, visible: true});
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/CwdSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {useCommandEvent} from './ISLShortcuts';
import {codeReviewProvider} from './codeReview/CodeReviewInfo';
import {T, t} from './i18n';
import {writeAtom} from './jotaiUtils';
import foundPlatform from './platform';
import platform from './platform';
import {serverCwd} from './repositoryData';
import {repositoryInfo} from './serverAPIState';
import {registerCleanup, registerDisposable} from './utils';
Expand Down Expand Up @@ -140,7 +140,7 @@ function CwdDetails({dismiss}: {dismiss: () => unknown}) {
const repoRoot = info?.type === 'success' ? info.repoRoot : null;
const provider = useAtomValue(codeReviewProvider);
const cwd = useAtomValue(serverCwd);
const AddMoreCwdsHint = foundPlatform.AddMoreCwdsHint;
const AddMoreCwdsHint = platform.AddMoreCwdsHint;
return (
<DropdownFields title={<T>Repository info</T>} icon="folder" data-testid="cwd-details-dropdown">
<CwdSelections dismiss={dismiss} divider />
Expand Down
6 changes: 3 additions & 3 deletions addons/isl/src/Diagnostics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {tracker} from './analytics';
import {getFeatureFlag} from './featureFlags';
import {T, t} from './i18n';
import {localStorageBackedAtom, readAtom} from './jotaiUtils';
import foundPlatform from './platform';
import platform from './platform';
import {uncommittedChangesWithPreviews} from './previews';
import {showModal} from './useModal';
import * as stylex from '@stylexjs/stylex';
Expand Down Expand Up @@ -114,7 +114,7 @@ export async function confirmNoBlockingDiagnostics(
if (!readAtom(shouldWarnAboutDiagnosticsAtom)) {
return true;
}
if (foundPlatform.platformName === 'vscode') {
if (platform.platformName === 'vscode') {
const allFiles = new Set<string>();
for (const file of readAtom(uncommittedChangesWithPreviews)) {
if (selection.isFullyOrPartiallySelected(file.path)) {
Expand Down Expand Up @@ -249,7 +249,7 @@ function DiagnosticsList({
key={i}
xstyle={styles.diagnosticRow}
onClick={() => {
foundPlatform.openFile(filepath, {line: d.range.startLine + 1});
platform.openFile(filepath, {line: d.range.startLine + 1});
tracker.track('DiagnosticsConfirmationAction', {
extras: {action: 'openFile'},
});
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/UncommitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {codeReviewProvider, diffSummary} from './codeReview/CodeReviewInfo';
import {t, T} from './i18n';
import {UncommitOperation} from './operations/Uncommit';
import {useRunOperation} from './operationsState';
import foundPlatform from './platform';
import platform from './platform';
import {dagWithPreviews} from './previews';
import {Button} from 'isl-components/Button';
import {Icon} from 'isl-components/Icon';
Expand Down Expand Up @@ -51,7 +51,7 @@ export function UncommitButton() {
onClick={async e => {
e.stopPropagation();
const [confirmed, changedFilesResult] = await Promise.all([
foundPlatform.confirm(
platform.confirm(
t('Are you sure you want to Uncommit?'),
hasChildren
? t(
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/UnsavedFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {Column, Row} from './ComponentUtils';
import {availableCwds} from './CwdSelector';
import {T, t} from './i18n';
import {readAtom, writeAtom} from './jotaiUtils';
import foundPlatform from './platform';
import platform from './platform';
import {showModal} from './useModal';
import {registerCleanup, registerDisposable} from './utils';
import {Button} from 'isl-components/Button';
Expand Down Expand Up @@ -54,7 +54,7 @@ export function UnsavedFilesCount() {
const options: Array<ContextMenuItem> = disambiguated.map((name, i) => ({
label: t('Open $name', {replace: {$name: name}}),
onClick: () => {
foundPlatform.openFile(fullPaths[i]);
platform.openFile(fullPaths[i]);
},
}));
options.push({type: 'divider'});
Expand Down
8 changes: 4 additions & 4 deletions addons/isl/src/__tests__/BrowseRepoUrl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import App from '../App';
import foundPlatform from '../platform';
import platform from '../platform';
import {ignoreRTL} from '../testQueries';
import {
closeCommitInfoSidebar,
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Browse repo url', () => {
setCodeBrowserConfig('https://www.example.com/repo/browse/%s');
clickBrowseRepo();

const openLinkSpy = jest.spyOn(foundPlatform, 'openExternalLink').mockImplementation(() => {});
const openLinkSpy = jest.spyOn(platform, 'openExternalLink').mockImplementation(() => {});
expectMessageSentToServer({
type: 'getRepoUrlAtHash',
revset: '1',
Expand All @@ -93,7 +93,7 @@ describe('Browse repo url', () => {
setCodeBrowserConfig('https://www.example.com/repo/browse/%s');
clickBrowseRepo();

const openLinkSpy = jest.spyOn(foundPlatform, 'openExternalLink').mockImplementation(() => {});
const openLinkSpy = jest.spyOn(platform, 'openExternalLink').mockImplementation(() => {});
expectMessageSentToServer({
type: 'getRepoUrlAtHash',
revset: '1',
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('Browse repo url', () => {
});

await waitFor(() => {
const copySpy = jest.spyOn(foundPlatform, 'clipboardCopy').mockImplementation(() => {});
const copySpy = jest.spyOn(platform, 'clipboardCopy').mockImplementation(() => {});
expect(copySpy).toHaveBeenCalledWith(
'https://www.example.com/repo/browse/a/file1.txt',
undefined,
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/__tests__/FillCommitMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import App from '../App';
import foundPlatform from '../platform';
import platform from '../platform';
import {CommitInfoTestUtils} from '../testQueries';
import {
expectMessageSentToServer,
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('FillCommitMessage', () => {
expect(getDescriptionEditor()).toHaveValue('');

const confirmSpy = jest
.spyOn(foundPlatform, 'confirm')
.spyOn(platform, 'confirm')
.mockImplementation(() => Promise.resolve(true));

fireEvent.click(screen.getByTestId('fill-commit-message-more-options'));
Expand Down
8 changes: 4 additions & 4 deletions addons/isl/src/__tests__/GeneratedFiles.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import App from '../App';
import {genereatedFileCache} from '../GeneratedFile';
import {__TEST__} from '../UncommittedChanges';
import {readAtom, writeAtom} from '../jotaiUtils';
import foundPlatform from '../platform';
import platform from '../platform';
import {ignoreRTL} from '../testQueries';
import {
expectMessageSentToServer,
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Generated Files', () => {
}

it('No generated files, opens all files', async () => {
const openSpy = jest.spyOn(foundPlatform, 'openFiles').mockImplementation(() => {});
const openSpy = jest.spyOn(platform, 'openFiles').mockImplementation(() => {});
await simulateCommitWithFiles({
'file_partial.txt': GeneratedStatus.PartiallyGenerated,
'file_manual.txt': GeneratedStatus.Manual,
Expand All @@ -268,7 +268,7 @@ describe('Generated Files', () => {
});

it('Some generated files, opens all non-generated files', async () => {
const openSpy = jest.spyOn(foundPlatform, 'openFiles').mockImplementation(() => {});
const openSpy = jest.spyOn(platform, 'openFiles').mockImplementation(() => {});
await simulateCommitWithFiles({
'file_gen.txt': GeneratedStatus.Generated,
'file_partial.txt': GeneratedStatus.PartiallyGenerated,
Expand All @@ -281,7 +281,7 @@ describe('Generated Files', () => {
});

it('All generated files, opens all files', async () => {
const openSpy = jest.spyOn(foundPlatform, 'openFiles').mockImplementation(() => {});
const openSpy = jest.spyOn(platform, 'openFiles').mockImplementation(() => {});
await simulateCommitWithFiles({
'file_gen1.txt': GeneratedStatus.Generated,
'file_gen2.txt': GeneratedStatus.Generated,
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/__tests__/toasts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import App from '../App';
import foundPlatform from '../platform';
import platform from '../platform';
import {
TEST_COMMIT_HISTORY,
expectMessageSentToServer,
Expand All @@ -32,7 +32,7 @@ describe('toasts', () => {
});

it('shows toast when copying commit hash', () => {
const copySpy = jest.spyOn(foundPlatform, 'clipboardCopy').mockImplementation(() => {});
const copySpy = jest.spyOn(platform, 'clipboardCopy').mockImplementation(() => {});
fireEvent.contextMenu(screen.getByTestId('commit-e'));
fireEvent.click(screen.getByText('Copy Commit Hash "e"'));
expect(screen.getByText('Copied e')).toBeInTheDocument();
Expand Down
4 changes: 2 additions & 2 deletions addons/isl/src/codeReview/DiffComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Column, Row} from '../ComponentUtils';
import {Link} from '../Link';
import {T, t} from '../i18n';
import {atomFamilyWeak, atomLoadableWithRefresh} from '../jotaiUtils';
import foundPlatform from '../platform';
import platform from '../platform';
import {RelativeDate} from '../relativeDate';
import {layout} from '../stylexUtils';
import {themeState} from '../theme';
Expand Down Expand Up @@ -109,7 +109,7 @@ function Comment({comment, isTopLevel}: {comment: DiffComment; isTopLevel?: bool
<Link
xstyle={styles.inlineCommentFilename}
onClick={() =>
comment.filename && foundPlatform.openFile(comment.filename, {line: comment.line})
comment.filename && platform.openFile(comment.filename, {line: comment.line})
}>
{comment.filename}
{comment.line == null ? '' : ':' + comment.line}
Expand Down
6 changes: 3 additions & 3 deletions addons/isl/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ declare global {
// before the main ISL script loads.

/** The ISL client Platform. This may be BrowserPlatform, VSCodeWebviewPlatform, or another platforms, determined at runtime. */
const foundPlatform = window.islPlatform ?? browserPlatform;
window.islPlatform = foundPlatform;
const platform = window.islPlatform ?? browserPlatform;
window.islPlatform = platform;

export default foundPlatform;
export default platform;
4 changes: 2 additions & 2 deletions addons/isl/src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {BulkRebaseOperation} from './operations/BulkRebaseOperation';
import {HideOperation} from './operations/HideOperation';
import {RebaseOperation} from './operations/RebaseOperation';
import {operationBeingPreviewed, useRunOperation} from './operationsState';
import foundPlatform from './platform';
import platform from './platform';
import {dagWithPreviews} from './previews';
import {latestDag} from './serverAPIState';
import {latestSuccessorUnlessExplicitlyObsolete} from './successionUtils';
Expand Down Expand Up @@ -369,7 +369,7 @@ export function useShortcutToRebaseSelected(): void {
);
} else {
if (
await foundPlatform.confirm(
await platform.confirm(
t('Are you sure you want to rebase $count commits?', {count: selectedRevsets.length}),
)
) {
Expand Down

0 comments on commit afcd85b

Please sign in to comment.