Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update app name on topbar based on version #159

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
env:
NODE_ENV: production
DEV_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/
IS_STAGING: ${{ secrets.IS_STAGING || 'false' }}
FORK_URL: https://rpc-gate.autonolas.tech/gnosis-rpc/
- run: rm -rf /dist
- name: "Build, notarize, publish"
Expand Down
3 changes: 1 addition & 2 deletions electron/constants/publishOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const publishOptions = {
token: process.env.GH_TOKEN,
private: false,
publishAutoUpdate: true,
releaseType: process.env.IS_STAGING === 'true' ? 'prerelease' : 'release',
channel: process.env.IS_STAGING === 'true' ? 'alpha' : 'latest',
releaseType: process.env.IS_STAGING === 'true' ? 'draft' : 'release',
mohandast52 marked this conversation as resolved.
Show resolved Hide resolved
};

module.exports = { publishOptions };
7 changes: 6 additions & 1 deletion electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const process = require('process');
const { spawnSync } = require('child_process');
const Docker = require('dockerode');

/**
* current version of the pearl release
* - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26"
* - use "alpha" for alpha release, for example "0.1.0rc26-alpha"
*/
const Version = '0.1.0rc26';
mohandast52 marked this conversation as resolved.
Show resolved Hide resolved
const OperateDirectory = `${os.homedir()}/.operate`;
const VenvDir = `${OperateDirectory}/venv`;
Expand Down Expand Up @@ -46,7 +51,7 @@ function appendLog(log) {
function runCmdUnix(command, options) {
fs.appendFileSync(
OperateInstallationLog,
`Runninng ${command} with options ${JSON.stringify(options)}`,
`Running ${command} with options ${JSON.stringify(options)}`,
{ encoding: 'utf-8' },
);
let bin = getBinPath(command);
Expand Down
6 changes: 5 additions & 1 deletion electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ const createMainWindow = () => {
mainWindow.hide();
});

setupStoreIpc(ipcMain, mainWindow);
const storeInitialValues = {
appVersion: app.getVersion(),
releaseType: process.env.IS_STAGING ? 'draft' : 'release',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
releaseType: process.env.IS_STAGING ? 'draft' : 'release',
releaseType: 'draft',

};
setupStoreIpc(ipcMain, mainWindow, storeInitialValues);

if (isDev) {
mainWindow.webContents.openDevTools();
Expand Down
33 changes: 16 additions & 17 deletions electron/store.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
// set schema to validate store data
const schema = {
isInitialFunded: {
type: 'boolean',
default: false,
},
firstStakingRewardAchieved: {
type: 'boolean',
default: false,
},
firstRewardNotificationShown: {
type: 'boolean',
default: false,
},
const defaultSchema = {
appVersion: { type: 'string', default: '' },
releaseType: { type: 'string', default: '' },
isInitialFunded: { type: 'boolean', default: false },
firstStakingRewardAchieved: { type: 'boolean', default: false },
firstRewardNotificationShown: { type: 'boolean', default: false },
};

const setupStoreIpc = async (ipcChannel, mainWindow) => {
const setupStoreIpc = async (ipcChannel, mainWindow, storeInitialValues) => {
const Store = (await import('electron-store')).default;

/** @type import Store from 'electron-store' */
const store = new Store({
schema,
// set default values for store
const schema = Object.assign({}, defaultSchema);
Object.keys(schema).forEach((key) => {
if (storeInitialValues[key] !== undefined) {
schema[key].default = storeInitialValues[key];
}
});

/** @type import Store from 'electron-store' */
const store = new Store({ schema });

store.onDidAnyChange((data) => {
if (mainWindow?.webContents)
mainWindow.webContents.send('store-changed', data);
Expand Down
5 changes: 4 additions & 1 deletion electron/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const { publishOptions } = require('./constants/publishOptions');
const electronUpdater = require('electron-updater');
const electronLogger = require('electron-log');

const macUpdater = new electronUpdater.MacUpdater({ ...publishOptions });
const macUpdater = new electronUpdater.MacUpdater({
...publishOptions,
channels: ['latest', 'beta', 'alpha'], // automatically update to all channels
});

macUpdater.logger = electronLogger;

Expand Down
17 changes: 16 additions & 1 deletion frontend/components/Layout/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Typography } from 'antd';
import { useMemo } from 'react';
import styled from 'styled-components';

import { COLOR } from '@/constants';
import { useElectronApi } from '@/hooks/useElectronApi';
import { useStore } from '@/hooks/useStore';

const { Text } = Typography;

Expand Down Expand Up @@ -48,6 +50,19 @@ const TopBarContainer = styled.div`

export const TopBar = () => {
const electronApi = useElectronApi();
const store = useStore();

const versionName = useMemo(() => {
const releaseType = store?.storeState?.releaseType;
if (releaseType === 'draft') return ' (staging)';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tanya-atatakai, we can't use .env files because they aren't exposed here, so we used this technique instead.
@truemiller, do you think the appVersion is unnecessary and won't need renaming?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not sure we need appVersion is store..
can probably just a expose constant through electron api


const appVersion = store?.storeState?.appVersion;
if (!appVersion) return '';
if (appVersion.includes('alpha')) return ''; // TODO
if (appVersion.includes('beta')) return ''; // TODO
return '';
}, [store?.storeState?.appVersion, store?.storeState?.releaseType]);

return (
<TopBarContainer>
<TrafficLights>
Expand All @@ -56,7 +71,7 @@ export const TopBar = () => {
<DisabledLight />
</TrafficLights>

<Text>Pearl (alpha)</Text>
<Text>{`Pearl (alpha) ${versionName}`.trim()}</Text>
</TopBarContainer>
);
};
2 changes: 2 additions & 0 deletions frontend/types/ElectronApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type ElectronStore = {
appVersion?: string;
releaseType?: string;
isInitialFunded?: boolean;
firstStakingRewardAchieved?: boolean;
firstRewardNotificationShown?: boolean;
Expand Down
Loading