From ef4e31355d1faef0e829eea3a91c5f11c274509a Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Sat, 14 Sep 2024 16:32:13 -0600 Subject: [PATCH 1/3] Don't update onFileChange when there is no selectedFile --- .../instance/functions/manage/applicationsEditor/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/instance/functions/manage/applicationsEditor/index.js b/src/components/instance/functions/manage/applicationsEditor/index.js index 0a1daa916..72abb4219 100644 --- a/src/components/instance/functions/manage/applicationsEditor/index.js +++ b/src/components/instance/functions/manage/applicationsEditor/index.js @@ -308,6 +308,7 @@ function WebIDE({ active={activeEditorWindow === EDITOR_WINDOWS.CODE_EDITOR_WINDOW} file={selectedFile} onFileChange={async (fileContent) => { + if (!selectedFile) return; updateFileInMemory(fileContent); await onFileChange({ path: selectedFile?.path, content: fileContent }); setSelectedFile({ ...selectedFile, content: fileContent, cached: true }); From 70eea099948b40dac1768210de80089d39978590 Mon Sep 17 00:00:00 2001 From: deliciousmonster Date: Tue, 17 Sep 2024 11:34:41 -0600 Subject: [PATCH 2/3] eliminate excessive loading and license restarts --- .github/workflows/publish-development.yaml | 87 --------- package.json | 1 - src/components/instance/status/SystemInfo.js | 51 ++---- src/components/instances/index.js | 55 ++---- src/components/instances/list/CardFront.js | 9 +- .../instances/handleInstanceRegistration.js | 35 +--- yarn.lock | 173 ++++++++---------- 7 files changed, 114 insertions(+), 297 deletions(-) delete mode 100644 .github/workflows/publish-development.yaml diff --git a/.github/workflows/publish-development.yaml b/.github/workflows/publish-development.yaml deleted file mode 100644 index da33abf6a..000000000 --- a/.github/workflows/publish-development.yaml +++ /dev/null @@ -1,87 +0,0 @@ -on: - push: - branches: - - "development" - workflow_dispatch: -name: Publish Development -jobs: - publishDevStudio: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Write config file - run: | - #!/bin/bash - - PACKAGE_VERSION=$(sed -nr 's/^\s*\"version": "([0-9]{1,}\.[0-9]{1,}.*)",$/\1/p' package.json) - cat < ./src/config/index.js - export default { - env: 'stage', - stripe_public_key: '${{secrets.STRIPE_PUBLIC_KEY}}', - lms_api_url: 'https://dev.harperdbcloudservices.com/', - google_analytics_code: '${{secrets.GOOGLE_ANALYTICS_CODE}}', - tc_version: '2020-01-01', - check_version_interval: 300000, - check_user_interval: 900000, - refresh_content_interval: 15000, - free_cloud_instance_limit: 1, - max_file_upload_size: 10380902, - studio_version:'$PACKAGE_VERSION', - alarm_badge_threshold: 86400, - maintenance: 0, - errortest: 0, - is_local_studio: false, - }; - EOF - - name: Write manifest file - run: | - #!/bin/bash - - cat < ./public/manifest.json - { - "short_name": "HarperDB Studio", - "name": "HarperDB Studio", - "icons": [ - { - "src": "favicon.ico", - "sizes": "16x16", - "type": "image/x-icon" - }, - { - "src": "images/logo_vertical_white.png", - "type": "image/png", - "sizes": "536x672" - } - ], - "start_url": "https://dev.studio.harperdb.io", - "display": "standalone", - "theme_color": "#480b8a", - "background_color": "#ffffff" - } - EOF - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 20.9.0 - - name: Build - run: | - #!/bin/bash - - yarn - yarn lint - yarn build:dev - - name: Clean Remote Directory - env: - CI_PRIVATE_KEY: ${{ secrets.CI_PRIVATE_KEY }} - run: | - #!/bin/bash - echo "$CI_PRIVATE_KEY" > private_key && chmod 600 private_key - ssh -i private_key -o ConnectTimeout=10 -o ConnectionAttempts=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR ubuntu@dev.studio.harperdb.io \ - "rm -rf /home/ubuntu/sites/studio-dev/*" - - name: Copy built files - env: - CI_PRIVATE_KEY: ${{ secrets.CI_PRIVATE_KEY }} - run: | - #!/bin/bash - scp -r -i private_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR \ - build/* "ubuntu@dev.studio.harperdb.io:/home/ubuntu/sites/studio-dev/" diff --git a/package.json b/package.json index e2310ecde..c58c9708f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "start": "HTTPS=true SSL_CRT_FILE=./.cert/cert.pem SSL_KEY_FILE=./.cert/key.pem react-scripts start", "start:local": "REACT_APP_LOCALSTUDIO=true HTTPS=true SSL_CRT_FILE=./.cert/cert.pem SSL_KEY_FILE=./.cert/key.pem react-scripts start", "docker": "HTTPS=false react-scripts start", - "build:dev": "PUBLIC_URL=https://d2uv4fa0aeja0t.cloudfront.net react-scripts build", "build:stage": "GENERATE_SOURCEMAP=false PUBLIC_URL=https://dbjxbnqel2bw9.cloudfront.net react-scripts build", "build:prod": "GENERATE_SOURCEMAP=false PUBLIC_URL=https://ds5zz9rfvzuta.cloudfront.net react-scripts build", "build:local": "BUILD_PATH=./build-local GENERATE_SOURCEMAP=false REACT_APP_LOCALSTUDIO=true react-scripts build", diff --git a/src/components/instance/status/SystemInfo.js b/src/components/instance/status/SystemInfo.js index 7618b52f2..382deffa6 100644 --- a/src/components/instance/status/SystemInfo.js +++ b/src/components/instance/status/SystemInfo.js @@ -1,12 +1,10 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { useStoreState } from 'pullstate'; import { Card, CardBody, Row, Col, Button } from 'reactstrap'; -import useInterval from 'use-interval'; import { ErrorBoundary } from 'react-error-boundary'; import appState from '../../../functions/state/appState'; import instanceState from '../../../functions/state/instanceState'; -import config from '../../../config'; import updateSystemInfo from '../../../functions/api/instance/updateSystemInfo'; import ContentContainer from '../../shared/ContentContainer'; @@ -24,57 +22,30 @@ function SystemInfo() { const storage = useStoreState(instanceState, (s) => s.storage); const iopsAlarms = useStoreState(appState, (s) => s.alarms && s.alarms[compute_stack_id]?.alarmCounts['Disk I/O'], [compute_stack_id]); const [autoRefresh, setAutoRefresh] = useState(false); - const [loading, setLoading] = useState(true); - const [lastUpdate, setLastUpdate] = useState(null); + const [loading, setLoading] = useState(!systemInfo?.totalMemory); - async function fetchSystemInfo(useCache = false) { - if (useCache) { - await updateSystemInfo({ auth, url, is_local, signal: controller.signal, refresh: !!systemInfo, previousSystemInfo: systemInfo, skip: ['disk', 'network'] }); - } else { - await updateSystemInfo({ auth, url, is_local, signal: controller.signal, refresh: !!systemInfo, previousSystemInfo: systemInfo }); - } - } + const fetchData = async () => { + setLoading(true); + controller = new AbortController(); + await updateSystemInfo({ auth, url, is_local, signal: controller.signal, refresh: !!systemInfo, previousSystemInfo: systemInfo }); + setLoading(false); + }; useEffect(() => { - let isMounted = true; - - const fetchData = async () => { - setLoading(true); - controller = new AbortController(); - await fetchSystemInfo(!!lastUpdate); - if (isMounted) setLoading(false); - }; - - if (auth) fetchData(); + if (auth && !systemInfo?.totalMemory) fetchData(); return () => { controller?.abort(); - isMounted = false; }; // eslint-disable-next-line - }, [auth, lastUpdate]); - - useInterval(() => { - if (auth && autoRefresh) { - setLastUpdate(Date.now()); - } - }, config.refresh_content_interval); + }, [auth]); return ( addError({ error: { message: error.message, componentStack } })} FallbackComponent={ErrorFallback}> host system -