add license dialog

This commit is contained in:
David Lechner
2021-01-17 10:39:38 -06:00
parent 4b63a80f80
commit 1626533cca
21 changed files with 454 additions and 12 deletions
+23 -1
View File
@@ -17,6 +17,10 @@ export enum AppActionType {
OpenAboutDialog = 'app.action.openAboutDialog',
/** Close about dialog. */
CloseAboutDialog = 'app.action.closeAboutDialog',
/** Open license dialog. */
OpenLicenseDialog = 'app.action.openLicenseDialog',
/** Close license dialog. */
CloseLicenseDialog = 'app.action.closeLicenseDialog',
}
/** Action that indicates the app has just started. */
@@ -59,10 +63,28 @@ export function closeAboutDialog(): AppCloseAboutDialogAction {
return { type: AppActionType.CloseAboutDialog };
}
/** Action to open the license dialog. */
export type AppOpenLicenseDialogAction = Action<AppActionType.OpenLicenseDialog>;
/** Creates an action to open the license dialog. */
export function openLicenseDialog(): AppOpenLicenseDialogAction {
return { type: AppActionType.OpenLicenseDialog };
}
/** Action to close the license dialog. */
export type AppCloseLicenseDialogAction = Action<AppActionType.CloseLicenseDialog>;
/** Creates an action to close the license dialog. */
export function closeLicenseDialog(): AppCloseLicenseDialogAction {
return { type: AppActionType.CloseLicenseDialog };
}
/** common type for all app actions. */
export type AppAction =
| AppStartupAction
| AppOpenSettingsAction
| AppCloseSettingsAction
| AppOpenAboutDialogAction
| AppCloseAboutDialogAction;
| AppCloseAboutDialogAction
| AppOpenLicenseDialogAction
| AppCloseLicenseDialogAction;
+2
View File
@@ -8,6 +8,7 @@ import { BleUartAction } from './ble-uart';
import { EditorAction } from './editor';
import { FlashFirmwareAction } from './flash-firmware';
import { HubAction, HubMessageAction } from './hub';
import { LicenseAction } from './license';
import {
BootloaderConnectionAction,
BootloaderDidRequestAction,
@@ -36,6 +37,7 @@ export type Action =
| FlashFirmwareAction
| HubAction
| HubMessageAction
| LicenseAction
| MpyAction
| NotificationAction
| ServiceWorkerAction
+28
View File
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 The Pybricks Authors
import { Action } from 'redux';
import { LicenseInfo, LicenseList } from '../reducers/license';
export enum LicenseActionType {
DidFetchList = 'license.action.didFetchList',
Select = 'license.action.select',
}
export type LicenseDidFetchListAction = Action<LicenseActionType.DidFetchList> & {
list: LicenseList;
};
export function didFetchList(list: LicenseList): LicenseDidFetchListAction {
return { type: LicenseActionType.DidFetchList, list };
}
export type LicenseSelectAction = Action<LicenseActionType.Select> & {
info: LicenseInfo;
};
export function select(info: LicenseInfo): LicenseSelectAction {
return { type: LicenseActionType.Select, info };
}
export type LicenseAction = LicenseDidFetchListAction | LicenseSelectAction;