Skip to content

Commit

Permalink
fix: broken update button
Browse files Browse the repository at this point in the history
  • Loading branch information
jtary committed Sep 28, 2023
1 parent ded4890 commit e416afc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
7 changes: 5 additions & 2 deletions web/src/api/rpc/beta3/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export const fetchProviderAttributes = async (
}

return client
.ProviderAttributes(QueryProviderAttributesRequest.fromPartial(filter));
// .catch((err) => ({} as QueryProvidersResponse)); // if there is no value, return empty set
.ProviderAttributes(QueryProviderAttributesRequest.fromPartial(filter))
.catch((err) => {
console.warn('Error fetching provider attributes', err);
return {} as QueryProvidersResponse;
}); // if there is no value, return empty set
};

export const fetchAuditorAttributes = async (
Expand Down
9 changes: 6 additions & 3 deletions web/src/components/Deployment/DeploymentActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ type DeploymentActionButtonProps = {
children: React.ReactNode;
} & ButtonProps;

const ConditionalTooltip = ({ children, condition, ...rest }: any) => {
const ConditionalTooltip = ({ children, condition, title, to, sx }: any) => {
console.log('Condition', condition);

return condition
? <Link {...rest}>{children}</Link>
: <Tooltip {...rest} placement="top">{children}</Tooltip>;
? <Link href={to} className='w-full'>{children}</Link>
: <Tooltip title={title} placement="top" sx={sx}><div className='w-full'>{children}</div></Tooltip>;
};


Expand All @@ -37,6 +39,7 @@ const DeploymentActionButton: React.FC<DeploymentActionButtonProps> = (props) =>
fullWidth
variant="outlined"
color="secondary"
disabled={!condition}
sx={{
justifyContent: 'left'
}}
Expand Down
14 changes: 9 additions & 5 deletions web/src/components/Deployment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import { uniqueName } from '../../_helpers/unique-name';
import { Icon } from '../Icons';
import { useLeaseStatus } from '../../hooks/useLeaseStatus';
import InfoIcon from '@mui/icons-material/Info';
import { fetchDeployment as beta2FetchDeployment } from '../../api/rpc/beta2/deployments';
import { fetchDeployment as beta3FetchDeployment } from '../../api/rpc/beta3/deployments';
import { getRpcNode } from '../../hooks/useRpcNode';

import { QueryDeploymentResponse as Beta3Deployment } from '@akashnetwork/akashjs/build/protobuf/akash/deployment/v1beta3/query';
import { QueryDeploymentResponse as Beta2Deployment } from '@akashnetwork/akashjs/build/protobuf/akash/deployment/v1beta2/query';

import DeploymentActionButton from './DeploymentActionButton';

const Deployment: React.FC<any> = () => {
Expand Down Expand Up @@ -193,6 +192,8 @@ const Deployment: React.FC<any> = () => {
}
}
}

console.log('leaseStatus', leaseStatus);
}, [leaseStatus]);

React.useEffect(() => {
Expand All @@ -207,14 +208,16 @@ const Deployment: React.FC<any> = () => {
navigate(`/configure-deployment/${dseq}`);
};

const onUpdateDeployment = () => {
navigate(`/my-deployments/${dseq}/update-deployment`);
};

// In case that current SDL is deployed from another machine, only show Tooltip and not show re-deploy page
const ConditionalLinkReDeploy = application !== null ? Link : Tooltip;

// In case that current SDL is deployed from another machine or status closed, only show Tooltip and not show update page
const canUpdate = application !== null && deployment?.deployment?.state === 1;

console.log('Can Update', canUpdate);

return (
<Stack>
{certificate.$type === 'Invalid Certificate' && (
Expand Down Expand Up @@ -274,7 +277,7 @@ const Deployment: React.FC<any> = () => {
: 'This SDL is deployed with another tool and can\'t be updated from here'
}
tooltip={UpdateDeploymentTooltip}
linkTo={'update-deployment'}
linkTo={`/my-deployments/${dseq}/update-deployment`}
aria-label="update deployment"
aria-controls="menu-appbar"
aria-haspopup="true"
Expand All @@ -296,6 +299,7 @@ const Deployment: React.FC<any> = () => {
variant="outlined"
color="secondary"
aria-label="re-deploy"
disabled={!canUpdate}
sx={{
justifyContent: 'left'
}}
Expand Down
20 changes: 12 additions & 8 deletions web/src/hooks/useDeploymentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,18 @@ export default function useDeploymentData(owner: string) {
if (status === undefined || status === '') {
console.warn('Unable to resolve lease status for deployment:', dseq);
} else {
const leaseStatus = await status.json() as any;

if (leaseStatus && leaseStatus.services) {
url = Object.values(leaseStatus.services)
.map((service) => (service as any).uris)
.filter((uri) => uri && uri[0])
.map((uri) => uri[0])
.join(', ');
try {
const leaseStatus = await status.json() as any;

if (leaseStatus && leaseStatus.services) {
url = Object.values(leaseStatus.services)
.map((service) => (service as any).uris)
.filter((uri) => uri && uri[0])
.map((uri) => uri[0])
.join(', ');
}
} catch (e) {
console.warn('Unable to parse lease status', e);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/SelectProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useQuery } from 'react-query';
import { WordSwitch } from '../components/Switch/WordSwitch';
import { Timer } from '../components/Timer';
import { PlaceholderCard } from '../components/PlaceholderCard';
import { getRpcNode } from '../hooks/useRpcNode';

export interface SelectProviderProps {
deploymentId: { owner: string; dseq: string };
Expand Down

0 comments on commit e416afc

Please sign in to comment.