Skip to content

Commit

Permalink
[menu-bar] Fix undismissable Alerts (#112)
Browse files Browse the repository at this point in the history
* [menu-bar] Fix undismissable Alerts

* Add changelog entry
  • Loading branch information
gabrieldonadel authored Nov 30, 2023
1 parent 078917d commit b1e2e87
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

- Fix installing EAS builds from cold start. ([#108](https://github.com/expo/orbit/pull/108) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Fix onboarding command check loading status. ([#110](https://github.com/expo/orbit/pull/110) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Fix undismissable Alerts. ([#112](https://github.com/expo/orbit/pull/112) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 💡 Others

Expand Down
2 changes: 1 addition & 1 deletion apps/menu-bar/src/components/CommandCheckItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Clipboard from '@react-native-clipboard/clipboard';
import { CliCommands } from 'common-types';
import {
ActivityIndicator,
Alert,
AlertButton,
Image,
ImageSourcePropType,
Expand All @@ -15,6 +14,7 @@ import { Text } from './Text';
import { View } from './View';
import AlertIcon from '../assets/icons/AlertTriangle';
import CheckIcon from '../assets/icons/check-circle.svg';
import Alert from '../modules/Alert';

type Props = {
title: string;
Expand Down
25 changes: 25 additions & 0 deletions apps/menu-bar/src/modules/Alert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Alert as RNAlert, AlertOptions, AlertButton } from 'react-native';

type MacOSAlertOptions = AlertOptions & {
modal?: boolean;
critical?: boolean;
};

/**
* A wrapper around RNAlert to override the
* default alert and set modal true, that way
* users can dismiss it even without an active window
**/
const Alert = {
...RNAlert,
alert(
title: string,
message?: string,
buttons?: AlertButton[],
options: MacOSAlertOptions = {}
): void {
RNAlert.alert(title, message, buttons, { modal: true, ...options });
},
};

export default Alert;
3 changes: 2 additions & 1 deletion apps/menu-bar/src/popover/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InternalError } from 'common-types';
import { MultipleAppsInTarballErrorDetails } from 'common-types/build/InternalError';
import { Device } from 'common-types/build/devices';
import React, { memo, useCallback, useState } from 'react';
import { Alert, SectionList } from 'react-native';
import { SectionList } from 'react-native';

import BuildsSection, { BUILDS_SECTION_HEIGHT } from './BuildsSection';
import DeviceListSectionHeader from './DeviceListSectionHeader';
Expand All @@ -21,6 +21,7 @@ import { useDeviceAudioPreferences } from '../hooks/useDeviceAudioPreferences';
import { useGetPinnedApps } from '../hooks/useGetPinnedApps';
import { usePopoverFocusEffect } from '../hooks/usePopoverFocus';
import { useSafeDisplayDimensions } from '../hooks/useSafeDisplayDimensions';
import Alert from '../modules/Alert';
import { useFileHandler } from '../modules/FileHandlerModule';
import MenuBarModule from '../modules/MenuBarModule';
import {
Expand Down
3 changes: 2 additions & 1 deletion apps/menu-bar/src/popover/DeviceListSectionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Alert, PlatformColor, TouchableOpacity } from 'react-native';
import { PlatformColor, TouchableOpacity } from 'react-native';

import SectionHeader from './SectionHeader';
import AlertIcon from '../assets/icons/AlertTriangle';
import { View } from '../components/View';
import Alert from '../modules/Alert';
import { useCurrentTheme } from '../utils/useExpoTheme';

type Props = {
Expand Down
3 changes: 2 additions & 1 deletion apps/menu-bar/src/windows/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { darkTheme, lightTheme } from '@expo/styleguide-native';
import React, { Fragment, useEffect, useState } from 'react';
import { Alert, StyleSheet, TouchableOpacity, Switch } from 'react-native';
import { StyleSheet, TouchableOpacity, Switch } from 'react-native';

import { WindowsNavigator } from './index';
import { withApolloProvider } from '../api/ApolloClient';
Expand All @@ -11,6 +11,7 @@ import Button, { getStylesForColor } from '../components/Button';
import PathInput from '../components/PathInput';
import SystemIconView from '../components/SystemIconView';
import { useGetCurrentUserQuery } from '../generated/graphql';
import Alert from '../modules/Alert';
import MenuBarModule from '../modules/MenuBarModule';
import SparkleModule from '../modules/SparkleModule';
import {
Expand Down

0 comments on commit b1e2e87

Please sign in to comment.