Hi All
I am developing a Local Add-on and don’t understand how to display the Local UI Component Alert above the SiteInfoHeader upon user-based action in siteInfoToolsItem. See code below for example. Thanks in advance for any assistance!
main.ts
import * as LocalMain from '@getflywheel/local/main';
export default function(context: LocalMain.AddonMainContext): void {
const { electron } = context;
const { ipcMain } = electron;
ipcMain.on('test-alert', (event, siteId) => {
const messageData = {
title: 'Test Alert',
body: 'This is a test alert',
};
// display an Alert ???
});
}
renderer.tsx
import React from 'react';
import fs from 'fs-extra';
import path from 'path';
import Boilerplate from './components/Boilerplate';
export default function (context): void {
const { hooks } = context;
const packageJSON = fs.readJsonSync(path.join(__dirname, '../package.json'));
const addonID = packageJSON.slug;
hooks.addFilter('siteInfoToolsItem', (menu) => [
...menu,
{
menuItem: 'Test Alert',
path: `/${addonID}`,
render: (props) => <Boilerplate {...props} />,
},
]);
}
components/Boilerplate.tsx
import React, { useState } from "react";
import { ipcRenderer } from "electron";
import { TextButton } from '@getflywheel/local-components';
const Boilerplate = (props) => {
const [siteId] = useState(props.site?.id);
return (
<TextButton
style={{paddingLeft: 0}}
onClick={(event) => {
console.log('test alert enter');
ipcRenderer.send('test-alert', siteId);
}}
>
Click to Test Alert
</TextButton>
);
};
export default Boilerplate;