Skip to content
Merged

Stage #327

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
213d160
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 11, 2023
14532ed
Bump stylelint from 15.8.0 to 15.10.1
dependabot[bot] Jul 7, 2023
323a44b
use cached sytem info values for disk and network when polling
Sep 5, 2023
e6a0861
extract fetchSystemInfo into separate function so it can be called in…
Sep 5, 2023
8566c22
only include __updatedtime__ and __createdtime__ headers in browse da…
Aug 9, 2023
c3620b7
clarifying comment.
Aug 9, 2023
836a7ac
extract fetchSystemInfo into separate function so it can be called in…
Sep 5, 2023
a48aba4
make argument to fetchSystemInfo a bit clearer.
Sep 5, 2023
59a0803
update on level of support for system attribute skip list.
Sep 5, 2023
a072bdb
bugfix: dont use cache when manually refreshing system info.
Sep 5, 2023
b2e7d6b
support caching all system info attributes, not just network and disk.
Sep 5, 2023
fe6ccc3
make cpuLoad nullable in system info component.
Sep 5, 2023
3a44e26
bugfix: just skip network and disk.
Sep 5, 2023
ae0da95
cache system attribute results as well as disk and network.
Sep 5, 2023
0277bff
version bump.
Sep 5, 2023
b32f04f
add safer length check on skip array.
Sep 5, 2023
f3b56c8
extract fetchSystemInfo into separate function so it can be called in…
Sep 5, 2023
1d03243
Some UI tweaks for rounded corners, drop shadows, and better typography
kriszyp Aug 29, 2023
23f23dd
Remove the dots
kriszyp Aug 29, 2023
dda176d
add 'px' to border radius value.
Sep 11, 2023
6cdd34a
versio bump
Sep 11, 2023
2d62c39
add unlimited_local_install customer flag to bypass logic when determ…
Oct 9, 2023
e00d3b8
name useEffect functions.
Aug 1, 2023
8d7f915
remove eslint ignore rule for an old dep.
Oct 2, 2023
5807b28
resolve stage conflicts w/ master.
Oct 9, 2023
9fba28e
v4.2.11
Oct 9, 2023
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: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
src/components/shared/react-json-editor-ajrm
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harperdb-studio",
"version": "4.2.10",
"version": "4.2.11",
"description": "A UI for HarperDB",
"deploymentUrl": "studio.harperdb.io",
"private": true,
Expand Down
32 changes: 24 additions & 8 deletions src/components/instance/functions/manage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,43 @@ function ManageIndex({ refreshCustomFunctions, loading }) {
const [majorVersion, minorVersion] = (registration?.version || '').split('.');
const supportsStaticRoutes = parseFloat(`${majorVersion}.${minorVersion}`) < 4.1;
const restarting = useStoreState(instanceState, (s) => s.restarting_service === 'custom_functions');
// NOTE: use the operationsApi server for cf_server_url in the future.
const cf_server_url = useStoreState(instanceState, (s) => s.custom_functions_url || `${s.url.split(':').slice(0, -1).join(':')}:${s.custom_functions?.port}`);
const baseUrl = `/o/${customer_id}/i/${compute_stack_id}/functions/${action}`;

useEffect(() => {
const routeToDefaultProject = () => {

const hasProjects = custom_functions?.endpoints && Object.keys(custom_functions?.endpoints).length;
const projectIsInEndpoints = custom_functions?.endpoints && Object.keys(custom_functions?.endpoints).includes(project);

let targetUrl;

if (hasProjects && project && !projectIsInEndpoints) {

const firstProject = project && Object.keys(custom_functions?.endpoints)[0];
navigate(`${baseUrl}/${firstProject}`);
targetUrl = `${baseUrl}/${firstProject}`;

} else if (hasProjects && project && !file) {

const firstRouteFile = project && custom_functions?.endpoints[project]?.routes[0];
const firstHelperFile = project && custom_functions?.endpoints[project]?.helpers[0];
const defaultType = firstRouteFile ? 'routes' : 'helpers';
navigate(`${baseUrl}/${project}/${defaultType}/${firstRouteFile || firstHelperFile}`);
targetUrl = `${baseUrl}/${project}/${defaultType}/${firstRouteFile || firstHelperFile}`;

} else if (hasProjects && !project) {

const firstProject = Object.keys(custom_functions?.endpoints)[0];
navigate(`${baseUrl}/${firstProject}`);
targetUrl = `${baseUrl}/${firstProject}`;

} else if (!hasProjects) {
navigate(baseUrl);

targetUrl = baseUrl;
}
}, [custom_functions?.endpoints, customer_id, compute_stack_id, navigate, action, project, file, baseUrl]);

useInterval(async () => {
navigate(targetUrl);
}

const waitForRestartToComplete = async () => {
if (cf_server_url && restarting) {
try {
await fetch(cf_server_url);
Expand All @@ -60,7 +73,10 @@ function ManageIndex({ refreshCustomFunctions, loading }) {
console.log(e);
}
}
}, 1000);
}

useEffect(routeToDefaultProject, [custom_functions?.endpoints, customer_id, compute_stack_id, navigate, action, project, file, baseUrl]);
useInterval(waitForRestartToComplete, 1000);

return (
<Row id="functions">
Expand Down
25 changes: 2 additions & 23 deletions src/components/instance/status/SystemInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,11 @@ function SystemInfo() {
const [lastUpdate, setLastUpdate] = useState(null);

async function fetchSystemInfo(useCache=false) {

if (useCache) {

await updateSystemInfo({
auth,
url,
is_local,
signal: controller.signal,
refresh: !!systemInfo,
cachedSystemInfo: systemInfo,
skip: ['disk', 'network', 'system']
});

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,
cachedSystemInfo: systemInfo
});

await updateSystemInfo({ auth, url, is_local, signal: controller.signal, refresh: !!systemInfo, previousSystemInfo: systemInfo });
}

}

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/instances/new/DetailsLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function DetailsLocal() {
const navigate = useNavigate();
const { customer_id } = useParams();
const is_unpaid = useStoreState(appState, (s) => s.customer.is_unpaid);
const unlimited_local_install = useStoreState(appState, (s) => s.customer.unlimited_local_install);
const [newInstance, setNewInstance] = useNewInstance({});
const unusedCompute = useStoreState(
appState,
Expand All @@ -26,7 +27,7 @@ function DetailsLocal() {
const [formState, setFormState] = useState({});
const [formData, setFormData] = useState({ ...products[0]?.value, ...newInstance });
const isFree = !formData.compute_price || !!formData.compute_subscription_id;
const needsCard = products && !hasCard && !isFree && !is_unpaid;
const needsCard = products && !hasCard && !isFree && !is_unpaid && !unlimited_local_install;

useAsyncEffect(() => {
const { submitted } = formState;
Expand Down
4 changes: 1 addition & 3 deletions src/functions/api/instance/updateSystemInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export default async ({ auth, url, signal, refresh, is_local, cachedSystemInfo,
result.network.latency.ms;
const networkLatencyStatus = skip.includes('network') ?
parseFloat(cachedSystemInfo.networkLatencyStatus) :
networkLatency > 1000 ?
'danger' : networkLatency > 500 ?
'warning' : 'success';
networkLatency > 1000 ? 'danger' : networkLatency > 500 ? 'warning' : 'success';

const systemInfo = {
totalMemory: totalMemory?.toFixed(2),
Expand Down
Loading