Skip to content

Commit cae55f7

Browse files
committed
Added reboot dialog after installation and logs
1 parent db497fc commit cae55f7

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

apps/box/src/screens/Plugin.screen.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import React, { useState, useEffect } from 'react';
2-
import { ScrollView, StyleSheet, TextInput, Linking } from 'react-native';
2+
import {
3+
ScrollView,
4+
StyleSheet,
5+
TextInput,
6+
Linking,
7+
Alert,
8+
} from 'react-native';
39
import {
410
FxBox,
511
FxCard,
@@ -66,6 +72,42 @@ export const PluginScreen = () => {
6672
const isInstalled = activePlugins.includes(name);
6773
const { queueToast } = useToast();
6874

75+
const handleReboot = async () => {
76+
try {
77+
// Call the reboot method here
78+
// For example: await fxblox.reboot();
79+
queueToast({
80+
type: 'success',
81+
title: 'Reboot Initiated',
82+
message: 'Your Blox is rebooting. Please wait...',
83+
});
84+
} catch (error) {
85+
queueToast({
86+
type: 'error',
87+
title: 'Reboot Failed',
88+
message: error.message || 'Failed to reboot Blox.',
89+
});
90+
}
91+
};
92+
93+
const showRebootDialog = () => {
94+
Alert.alert(
95+
'Reboot Required',
96+
'To complete the installation, your Blox needs to be rebooted. Would you like to reboot now?',
97+
[
98+
{
99+
text: 'Reboot Now',
100+
onPress: handleReboot,
101+
style: 'destructive',
102+
},
103+
{
104+
text: 'Reboot Later',
105+
style: 'cancel',
106+
},
107+
]
108+
);
109+
};
110+
69111
useEffect(() => {
70112
const fetchPluginInfo = async () => {
71113
if (!name) {
@@ -143,6 +185,7 @@ export const PluginScreen = () => {
143185
title: 'Success',
144186
message: 'Plugin installed successfully',
145187
});
188+
showRebootDialog();
146189
} else {
147190
queueToast({
148191
type: 'error',

apps/box/src/screens/Settings/BloxLogs.screen.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,37 @@ import { fxblox } from '@functionland/react-native-fula';
1818
import { useLogger } from '../../hooks';
1919
import { ActivityIndicator } from 'react-native';
2020
import { copyToClipboard } from '../../utils/clipboard';
21+
import { usePluginsStore } from '../../stores/usePluginsStore';
2122

2223
export const BloxLogsScreen = () => {
2324
const logger = useLogger();
2425
const [selectedValue, setSelectedValue] = React.useState<string>('');
2526
const [log, setLog] = React.useState<string>('');
26-
const [tailCount, setTailCount] = React.useState<string>('30');
27+
const [tailCount, setTailCount] = React.useState<string>('50');
2728
const [loadingLogs, setLoadingLogs] = React.useState<boolean>(false);
2829
const [fulaIsReady] = useUserProfileStore((state) => [state.fulaIsReady]);
2930
const [showOtherInput, setShowOtherInput] = React.useState<boolean>(false);
3031
const { queueToast } = useToast();
3132
const { colors } = useFxTheme();
33+
const [activePlugins, setActivePlugins] = React.useState<string[]>([]);
34+
const { listActivePlugins } = usePluginsStore();
35+
const fetchActivePlugins = React.useCallback(async () => {
36+
try {
37+
const result = await listActivePlugins();
38+
if (result.success) {
39+
setActivePlugins(result.msg);
40+
} else {
41+
console.error('Failed to fetch active plugins:', result.message);
42+
}
43+
} catch (error) {
44+
console.error('Error fetching active plugins:', error);
45+
}
46+
}, [listActivePlugins]);
47+
48+
React.useEffect(() => {
49+
fetchActivePlugins();
50+
}, [fetchActivePlugins]);
51+
3252
const sanitizeLogData = (logString: string) => {
3353
// Regular expression to match non-printable characters except newlines
3454
// This regex matches characters in the control characters range (0x00-0x1F and 0x7F-0x9F) except for newline (0x0A)
@@ -114,8 +134,14 @@ export const BloxLogsScreen = () => {
114134
{ label: 'Select container name', value: '' },
115135
{ label: 'Go-Fula', value: 'fula_go' },
116136
{ label: 'Node', value: 'fula_node' },
137+
{ label: 'IPFS', value: 'ipfs_host' },
138+
{ label: 'IPFS Cluster', value: 'ipfs_cluster' },
117139
{ label: 'Fx', value: 'fula_fxsupport' },
118140
{ label: 'Service Logs', value: 'MainService' },
141+
...activePlugins.map((plugin) => ({
142+
label: plugin,
143+
value: plugin,
144+
})),
119145
{ label: 'Other', value: 'Other' },
120146
]}
121147
title="Container Name"

0 commit comments

Comments
 (0)