Skip to content

Commit

Permalink
Merge pull request #403 from HarperDB/stage
Browse files Browse the repository at this point in the history
v4.6.2
  • Loading branch information
BboyAkers authored Nov 1, 2024
2 parents cbdaba3 + 580f574 commit 2c20b30
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 239 deletions.
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.6.1",
"version": "4.6.2",
"description": "A UI for HarperDB",
"deploymentUrl": "studio.harperdb.io",
"private": true,
Expand Down
16 changes: 10 additions & 6 deletions src/components/instances/list/CardFront.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import CardFrontStatusRow from '../../shared/CardFrontStatusRow';
import ErrorFallback from '../../shared/ErrorFallback';

const modifyingStatus = ['CREATING INSTANCE', 'DELETING INSTANCE', 'UPDATING INSTANCE', 'LOADING', 'CONFIGURING NETWORK', 'APPLYING LICENSE'];
const clickableStatus = ['OK', 'PLEASE LOG IN', 'LOGIN FAILED'];
const clickableStatus = ['OK', 'PLEASE LOG IN', 'LOGIN FAILED', 'LICENSE UPDATED - PLEASE RESTART'];

function CardFront({ compute_stack_id, instance_id, url, status, instance_name, is_local, is_ssl, cloud_provider, setFlipState, flipState, compute, storage, wavelength_zone_id }) {
const { customer_id } = useParams();
const navigate = useNavigate();
const auth = useStoreState(appState, (s) => s.auth);
const isOrgOwner = auth?.orgs?.find((o) => o.customer_id?.toString() === customer_id)?.status === 'owner';
const [instanceAuths, setInstanceAuths] = useInstanceAuth({});
const instanceAuth = useMemo(() => instanceAuths && instanceAuths[compute_stack_id], [instanceAuths, compute_stack_id]);
const instanceAuth = useMemo(() => instanceAuths?.[compute_stack_id], [instanceAuths, compute_stack_id]);
const [instanceData, setInstanceData] = useState({ status: 'LOADING', clustering: '', version: '' });
const [lastUpdate, setLastUpdate] = useState(false);
const [processing, setProcessing] = useState(false);
Expand All @@ -40,17 +40,17 @@ function CardFront({ compute_stack_id, instance_id, url, status, instance_name,
const statusClass = `text-bold text-${instanceData.error ? 'danger' : 'success'}`;
const ramString = `${compute?.compute_ram_string || '...'}`;
const typeString = generateTypeString({ wavelength_zone_id, is_local, cloud_provider });
const alarms = useStoreState(appState, (s) => s.alarms && s.alarms[compute_stack_id]?.alarmCounts, [compute_stack_id]);
const diskClass = alarms && alarms.Storage ? 'text-danger' : '';
const diskString = `${storage?.data_volume_size_string || 'DEVICE DISK'} ${alarms && alarms.Storage ? `/ ${alarms.Storage} ALARM${alarms.Storage > 1 ? 'S' : ''}` : ''}`;
const alarms = useStoreState(appState, (s) => s.alarms?.[compute_stack_id]?.alarmCounts, [compute_stack_id]);
const diskClass = alarms?.Storage ? 'text-danger' : '';
const diskString = `${storage?.data_volume_size_string || 'DEVICE DISK'} ${alarms?.Storage ? `/ ${alarms.Storage} ALARM${alarms.Storage > 1 ? 'S' : ''}` : ''}`;

const handleCardClick = useCallback(
async (e) => {
if (['CREATE FAILED', 'DELETE FAILED'].includes(instanceData.status)) {
e.stopPropagation();
} else if (!instanceAuth) {
setFlipState('login');
} else if (instanceData.status === 'OK') {
} else if (instanceData.status === 'OK' || instanceData.status === 'LICENSE UPDATED - PLEASE RESTART') {
const result = await userInfo({ auth: instanceAuth, url });
if (result.error) {
setInstanceData({ ...instanceData, status: 'UNABLE TO CONNECT', error: true, retry: true });
Expand Down Expand Up @@ -104,13 +104,17 @@ function CardFront({ compute_stack_id, instance_id, url, status, instance_name,
setProcessing(true);

const registrationResult = await handleInstanceRegistration({
auth,
customer_id,
instanceAuth,
url,
is_local,
is_ssl,
cloud_provider,
instance_id,
instance_name,
compute_stack_id,
compute,
status: instanceData.status,
});

Expand Down
17 changes: 0 additions & 17 deletions src/config/index.base.js

This file was deleted.

14 changes: 13 additions & 1 deletion src/config/index.example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
export default {
studio_version: 'x.x.xx',
env: 'dev',
stripe_public_key: 'pk_test_XXXXXXXXXXXXXXXXXXXXXX',
lms_api_url: 'XXXXXXXXXXXXXXXXXXXXXXXX',
lms_api_url: 'https://dev.harperdbcloudservices.com/',
google_analytics_code: 'UA-XXXXXXXXXXXXX-3',
tc_version: '2020-01-01',
check_version_interval: 300000,
check_user_interval: 900000,
refresh_content_interval: 10000,
free_cloud_instance_limit: 1,
max_file_upload_size: 10380902,
alarm_badge_threshold: 86400,
maintenance: 0,
is_local_studio: process.env.REACT_APP_LOCALSTUDIO, // this is injected at build-time and loads LocalApp.js instead of App.js
local_studio_dev_url: 'http://localhost:9925', // this lets you dev the UI on port 3000 and talk to your local instance on 9925
};
2 changes: 1 addition & 1 deletion src/functions/api/queryInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async ({ operation, auth, url, timeout = 0, authType = undefined,
method: 'POST',
body: JSON.stringify(operation),
headers,
credentials: 'include',
credentials: headers.Authorization ? 'omit' : 'include',
});

clearTimeout(id);
Expand Down
39 changes: 33 additions & 6 deletions src/functions/instances/handleInstanceRegistration.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import registrationInfo from '../api/instance/registrationInfo';
import handleCloudInstanceUsernameChange from './handleCloudInstanceUsernameChange';
import getFingerprint from '../api/instance/getFingerprint';
import setLicense from '../api/instance/setLicense';
import createLicense from '../api/lms/createLicense';

export default async ({ instanceAuth, url, is_local, is_ssl, cloud_provider, instance_id, status }) => {
export default async ({ auth, customer_id, instanceAuth, url, is_local, is_ssl, cloud_provider, instance_id, compute_stack_id, compute, status }) => {
try {
let registration = await registrationInfo({ auth: instanceAuth, url });

Expand All @@ -27,7 +30,7 @@ export default async ({ instanceAuth, url, is_local, is_ssl, cloud_provider, ins
}
}

if ((registration.status === 401) || registration.error === 'Login failed') {
if (registration.status === 401 || registration.error === 'Login failed') {
return {
status: 'LOGIN FAILED',
error: true,
Expand All @@ -53,22 +56,46 @@ export default async ({ instanceAuth, url, is_local, is_ssl, cloud_provider, ins

if (registration.error) {
return {
status: 'UNABLE TO CONNECT',
status: 'UNABLE TO CONNECT1',
error: true,
retry: true,
};
}
const registration_matches_stripe_plan = !compute || (registration.registered && registration.ram_allocation === compute.compute_ram);

if (registration_matches_stripe_plan) {
return {
status: 'OK',
error: false,
version: registration.version,
retry: false,
};
}

const fingerprint = await getFingerprint({ auth: instanceAuth, url });
const license = await createLicense({ auth, compute_stack_id, customer_id, fingerprint });
const apply = await setLicense({ auth: instanceAuth, key: license.key, company: license.company.toString(), url });

if (apply.error) {
return {
status: 'APPLYING LICENSE',
error: false,
version: registration.version,
retry: true,
};
}

return {
status: 'OK',
status: 'LICENSE UPDATED - PLEASE RESTART',
error: false,
version: registration.version,
retry: false,
retry: true,
};
// eslint-disable-next-line
} catch (e) {
console.log(e);

Check warning on line 96 in src/functions/instances/handleInstanceRegistration.js

View workflow job for this annotation

GitHub Actions / publishProductionStudio

Unexpected console statement
return {
status: 'UNABLE TO CONNECT',
status: 'UNABLE TO CONNECT2',
error: true,
retry: true,
};
Expand Down
Loading

0 comments on commit 2c20b30

Please sign in to comment.