From 63768afb656b0c6c7f6f10f1169d67af130d0174 Mon Sep 17 00:00:00 2001 From: Jose Francisco Date: Mon, 18 Dec 2023 10:08:02 +0000 Subject: [PATCH] (chore) lint --- .../offline-ready-modal.component.tsx | 53 +++++++------------ .../apps/esm-offline-tools-app/src/index.ts | 12 ++--- .../offline-actions-mode-button.component.tsx | 37 +++++-------- .../translations/am.json | 2 +- .../translations/ar.json | 2 +- .../translations/en.json | 2 +- .../translations/es.json | 2 +- .../translations/fr.json | 2 +- .../translations/he.json | 2 +- .../translations/km.json | 2 +- packages/framework/esm-offline/src/mode.ts | 14 ++--- packages/framework/esm-offline/src/public.ts | 15 ++---- 12 files changed, 53 insertions(+), 92 deletions(-) diff --git a/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx b/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx index ada179593..46d323c23 100644 --- a/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx +++ b/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx @@ -1,36 +1,25 @@ -import React, { useCallback, useEffect, useState } from "react"; -import { - ModalBody, - ModalFooter, - ModalHeader, - Button, - InlineLoading, -} from "@carbon/react"; -import { useTranslation } from "react-i18next"; -import { getCurrentOfflineMode, showToast } from "@openmrs/esm-framework"; +import React, { useCallback, useEffect, useState } from 'react'; +import { ModalBody, ModalFooter, ModalHeader, Button, InlineLoading } from '@carbon/react'; +import { useTranslation } from 'react-i18next'; +import { getCurrentOfflineMode, showToast } from '@openmrs/esm-framework'; export interface OfflineActionsProgressModalProps { items?: Array; closeModal: (active: boolean) => void; } -const OfflineReadyModal: React.FC = ({ - closeModal, - items, -}) => { +const OfflineReadyModal: React.FC = ({ closeModal, items }) => { const { t } = useTranslation(); const [isRunning, setIsRunning] = useState(true); - const [abortController, setAbortController] = useState( - () => new AbortController() - ); + const [abortController, setAbortController] = useState(() => new AbortController()); async function dispatchOfflineEvent() { //TODO CHANGE MODE let mode = getCurrentOfflineMode().active; window.dispatchEvent( - new CustomEvent(`openmrs:offline-${mode ? "enabled" : "disabled"}`, { + new CustomEvent(`openmrs:offline-${mode ? 'enabled' : 'disabled'}`, { detail: getCurrentOfflineMode(), - }) + }), ); setIsRunning(false); @@ -46,20 +35,17 @@ const OfflineReadyModal: React.FC = ({ showToast({ critical: true, - kind: "warning", - description: t( - "unavailableOfflineFeatures", - "Some features may not be available offline." - ), - title: t("offlinePreparationCanceled", "Offline preparation canceled"), + kind: 'warning', + description: t('unavailableOfflineFeatures', 'Some features may not be available offline.'), + title: t('offlinePreparationCanceled', 'Offline preparation canceled'), }); closeModal(false); } else { showToast({ critical: true, - kind: "success", - description: t("offlineModeIsReady", "Offline mode is ready"), - title: t("offline", "Offline"), + kind: 'success', + description: t('offlineModeIsReady', 'Offline mode is ready'), + title: t('offline', 'Offline'), }); closeModal(true); } @@ -67,24 +53,21 @@ const OfflineReadyModal: React.FC = ({ return ( <> - + {isRunning && ( )} diff --git a/packages/apps/esm-offline-tools-app/src/index.ts b/packages/apps/esm-offline-tools-app/src/index.ts index 6e7507b1c..eb361ef61 100644 --- a/packages/apps/esm-offline-tools-app/src/index.ts +++ b/packages/apps/esm-offline-tools-app/src/index.ts @@ -8,7 +8,7 @@ import offlineToolsComponent from './root.component'; import offlineToolsLinkComponent from './offline-tools-app-menu-link.component'; import offlineToolsNavItemsComponent from './nav/offline-tools-nav-menu.component'; import offlineToolsConfirmationModalComponent from './components/confirmation-modal.component'; -import offlineToolsOfflineReadyModalComponent from "./components/offline-ready-modal.component"; +import offlineToolsOfflineReadyModalComponent from './components/offline-ready-modal.component'; import offlineToolsPatientsCardComponent from './offline-patients/patients-overview-card.component'; import offlineToolsActionsCardComponent from './offline-actions/offline-actions-overview-card.component'; import offlineToolsActionsComponent from './offline-actions/offline-actions.component'; @@ -37,15 +37,9 @@ export const offlineToolsNavItems = getSyncLifecycle(offlineToolsNavItemsCompone export const offlineToolsConfirmationModal = getSyncLifecycle(offlineToolsConfirmationModalComponent, options); -export const offlineToolsOfflineReadyModal = getSyncLifecycle( - offlineToolsOfflineReadyModalComponent, - options -); +export const offlineToolsOfflineReadyModal = getSyncLifecycle(offlineToolsOfflineReadyModalComponent, options); -export const offlineToolsPatientsCard = getSyncLifecycle( - offlineToolsPatientsCardComponent, - options -); +export const offlineToolsPatientsCard = getSyncLifecycle(offlineToolsPatientsCardComponent, options); export const offlineToolsActionsCard = getSyncLifecycle(offlineToolsActionsCardComponent, options); diff --git a/packages/apps/esm-offline-tools-app/src/offline-actions/offline-actions-mode-button.component.tsx b/packages/apps/esm-offline-tools-app/src/offline-actions/offline-actions-mode-button.component.tsx index c9a88aeea..f19758893 100644 --- a/packages/apps/esm-offline-tools-app/src/offline-actions/offline-actions-mode-button.component.tsx +++ b/packages/apps/esm-offline-tools-app/src/offline-actions/offline-actions-mode-button.component.tsx @@ -1,14 +1,14 @@ -import React, { useState, useCallback } from "react"; -import { useTranslation } from "react-i18next"; -import { Toggle, Button, DefinitionTooltip } from "@carbon/react"; -import { Network_3 } from "@carbon/react/icons"; +import React, { useState, useCallback } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Toggle, Button, DefinitionTooltip } from '@carbon/react'; +import { Network_3 } from '@carbon/react/icons'; import { getCurrentOfflineMode, setCurrentOfflineMode, showModal, useConnectivity, -} from "@openmrs/esm-framework/src/internal"; -import styles from "./offline-actions-mode-button.scss"; +} from '@openmrs/esm-framework/src/internal'; +import styles from './offline-actions-mode-button.scss'; function doNotCloseMenu(ev: React.SyntheticEvent) { ev.stopPropagation(); @@ -17,16 +17,14 @@ function doNotCloseMenu(ev: React.SyntheticEvent) { const OfflineActionsModeButton: React.FC = () => { const { t } = useTranslation(); const isOnline = useConnectivity(); - const [lastRun, setLastRun] = useState( - () => getCurrentOfflineMode().lastRun - ); + const [lastRun, setLastRun] = useState(() => getCurrentOfflineMode().lastRun); const [active, setActive] = useState(() => getCurrentOfflineMode().active); const toggle = useCallback(() => { - const dispose = showModal("offline-tools-offline-ready-modal", { + const dispose = showModal('offline-tools-offline-ready-modal', { closeModal: (result) => { setActive(result); - setCurrentOfflineMode(result ? "on" : "off"); + setCurrentOfflineMode(result ? 'on' : 'off'); dispose(); }, }); @@ -42,30 +40,21 @@ const OfflineActionsModeButton: React.FC = () => {
- {t("offlineReady", "Offline Ready")} + {t('offlineReady', 'Offline Ready')}
{active && ( )} - {!active && ( - - )} + {!active && } ) ); diff --git a/packages/apps/esm-offline-tools-app/translations/am.json b/packages/apps/esm-offline-tools-app/translations/am.json index bb4b55415..7d2508e0d 100644 --- a/packages/apps/esm-offline-tools-app/translations/am.json +++ b/packages/apps/esm-offline-tools-app/translations/am.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "Newly registered", "homeOverviewCardView": "View", "lastRun": "Last Run", + "loading": "Loading", "never": "Never", "offline": "Offline", "offlineActions": "Offline actions", @@ -62,7 +63,6 @@ "offlineReady": "Offline Ready", "offlineToolsAppMenuLink": "Offline tools", "preparingOfflineMode": "Preparing for offline mode", - "progressBarLabel": "{progress}% Complete", "refresh": "Refresh", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/ar.json b/packages/apps/esm-offline-tools-app/translations/ar.json index 871638e36..c14448bb3 100644 --- a/packages/apps/esm-offline-tools-app/translations/ar.json +++ b/packages/apps/esm-offline-tools-app/translations/ar.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "مُسجل حديثًا", "homeOverviewCardView": "عرض", "lastRun": "Last Run", + "loading": "Loading", "never": "Never", "offline": "Offline", "offlineActions": "الأنشطة بدون اتصال", @@ -66,7 +67,6 @@ "offlineReady": "جاهز للعمل بدون اتصال", "offlineToolsAppMenuLink": "أدوات العمل بدون اتصال", "preparingOfflineMode": "Preparing for offline mode", - "progressBarLabel": "{progress}% Complete", "refresh": "Refresh", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/en.json b/packages/apps/esm-offline-tools-app/translations/en.json index 81e7a723a..f57eaae45 100644 --- a/packages/apps/esm-offline-tools-app/translations/en.json +++ b/packages/apps/esm-offline-tools-app/translations/en.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "Newly registered", "homeOverviewCardView": "View", "lastRun": "Last Run", + "loading": "Loading", "never": "Never", "offline": "Offline", "offlineActions": "Offline Actions", @@ -62,7 +63,6 @@ "offlineReady": "Offline Ready", "offlineToolsAppMenuLink": "Offline tools", "preparingOfflineMode": "Preparing for offline mode", - "progressBarLabel": "{{progress}}% Complete", "refresh": "Refresh", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/es.json b/packages/apps/esm-offline-tools-app/translations/es.json index b2617d95b..bf49641b3 100644 --- a/packages/apps/esm-offline-tools-app/translations/es.json +++ b/packages/apps/esm-offline-tools-app/translations/es.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "Recién registrados", "homeOverviewCardView": "Ver", "lastRun": "Última carrera", + "loading": "Loading", "never": "Nunca", "offline": "Offline", "offlineActions": "Acciones offline", @@ -63,7 +64,6 @@ "offlineReady": "Listo offline", "offlineToolsAppMenuLink": "Herramientas offline", "preparingOfflineMode": "Preparando modo sin conexión", - "progressBarLabel": "{{progress}}% Completo", "refresh": "Actualizar", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/fr.json b/packages/apps/esm-offline-tools-app/translations/fr.json index ec2d4f6b3..28c09a014 100644 --- a/packages/apps/esm-offline-tools-app/translations/fr.json +++ b/packages/apps/esm-offline-tools-app/translations/fr.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "Nouvellement enregistré", "homeOverviewCardView": "Voir", "lastRun": "Dernière course", + "loading": "Loading", "never": "Jamais", "offline": "Offline", "offlineActions": "Actions hors ligne", @@ -63,7 +64,6 @@ "offlineReady": "Prêt pour être hors ligne", "offlineToolsAppMenuLink": "Outils hors ligne", "preparingOfflineMode": "Préparation du mode hors ligne", - "progressBarLabel": "{{progress}}% Complet", "refresh": "rafraîchir", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/he.json b/packages/apps/esm-offline-tools-app/translations/he.json index 3b5f1f2f2..3f21d8b38 100644 --- a/packages/apps/esm-offline-tools-app/translations/he.json +++ b/packages/apps/esm-offline-tools-app/translations/he.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "רשומים חדשים", "homeOverviewCardView": "צפה", "lastRun": "Last Run", + "loading": "Loading", "never": "Never", "offline": "Offline", "offlineActions": "פעולות לא מקוונות", @@ -64,7 +65,6 @@ "offlineReady": "מצב לא מקוון מוכן", "offlineToolsAppMenuLink": "כלי לא מקוונים", "preparingOfflineMode": "Preparing for offline mode", - "progressBarLabel": "{progress}% Complete", "refresh": "Refresh", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/apps/esm-offline-tools-app/translations/km.json b/packages/apps/esm-offline-tools-app/translations/km.json index 4b985163b..1254de9b8 100644 --- a/packages/apps/esm-offline-tools-app/translations/km.json +++ b/packages/apps/esm-offline-tools-app/translations/km.json @@ -12,6 +12,7 @@ "homeOverviewCardPatientsNewlyRegistered": "Newly registered", "homeOverviewCardView": "View", "lastRun": "Last Run", + "loading": "Loading", "never": "Never", "offline": "Offline", "offlineActions": "សកម្មភាពក្រៅបណ្តាញ", @@ -61,7 +62,6 @@ "offlineReady": "Offline Ready", "offlineToolsAppMenuLink": "Offline tools", "preparingOfflineMode": "Preparing for offline mode", - "progressBarLabel": "{progress}% Complete", "refresh": "Refresh", "unavailableOfflineFeatures": "Some features may not be available offline." } diff --git a/packages/framework/esm-offline/src/mode.ts b/packages/framework/esm-offline/src/mode.ts index ecbeb87a4..bccb1adb1 100644 --- a/packages/framework/esm-offline/src/mode.ts +++ b/packages/framework/esm-offline/src/mode.ts @@ -31,7 +31,7 @@ async function isPrivateBrowsing() { return (await isFirefoxPrivateBrowsing()) || (await isEdgePrivateBrowsing()) || (await isSafariPrivateBrowsing()); } -export type OfflineMode = "on" | "off" | "unavailable"; +export type OfflineMode = 'on' | 'off' | 'unavailable'; export type OfflineHandler = () => void | Promise; export interface OfflineModeResult { @@ -41,15 +41,15 @@ export interface OfflineModeResult { lastRun: string; } -const offlineModeStorageKey = "openmrs:offline-mode"; -let offlineMode: OfflineMode = "unavailable"; -let lastRun: string = ""; +const offlineModeStorageKey = 'openmrs:offline-mode'; +let offlineMode: OfflineMode = 'unavailable'; +let lastRun: string = ''; export function getCurrentOfflineMode(): OfflineModeResult { return { current: offlineMode, - notAvailable: offlineMode === "unavailable", - active: offlineMode === "on", + notAvailable: offlineMode === 'unavailable', + active: offlineMode === 'on', lastRun: lastRun, }; } @@ -62,7 +62,7 @@ export function setCurrentOfflineMode(mode: OfflineMode) { } export function registerOfflineHandler(setupOffline: OfflineHandler) { - window.addEventListener("openmrs:offline-enabled", setupOffline); + window.addEventListener('openmrs:offline-enabled', setupOffline); const offlineMode = getCurrentOfflineMode(); if (offlineMode.active) { setupOffline(); diff --git a/packages/framework/esm-offline/src/public.ts b/packages/framework/esm-offline/src/public.ts index 2e0bee08f..7a16dcf7a 100644 --- a/packages/framework/esm-offline/src/public.ts +++ b/packages/framework/esm-offline/src/public.ts @@ -1,13 +1,8 @@ -export { - type OfflineMode, - type OfflineModeResult, - getCurrentOfflineMode, - registerOfflineHandler, -} from "./mode"; -export * from "./offline-patient-data"; -export * from "./service-worker-messaging"; -export * from "./service-worker-http-headers"; -export * from "./uuid"; +export { type OfflineMode, type OfflineModeResult, getCurrentOfflineMode, registerOfflineHandler } from './mode'; +export * from './offline-patient-data'; +export * from './service-worker-messaging'; +export * from './service-worker-http-headers'; +export * from './uuid'; export { type QueueItemDescriptor, type SyncItem,