Skip to content

Commit

Permalink
feat: edit deloyment (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuberTRoy authored Jan 25, 2024
1 parent 736c492 commit ea0d9bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/components/Expand/Expand.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0

import React, { FC, useCallback, useMemo, useRef, useState } from 'react';
import React, { FC, useCallback, useEffect, useRef, useState } from 'react';
import { Typography } from '@subql/components';
import { useUpdate } from 'ahooks';

Expand All @@ -16,15 +16,21 @@ const Expand: FC<IProps> = (props) => {

const [expanded, setExpanded] = useState(false);
const childrenRef = useRef<HTMLDivElement | null>(null);
const [showExpandIcon, setShowExpandIcon] = useState(false);

const setCallback = useCallback((ref: HTMLDivElement) => {
childrenRef.current = ref;
update();
}, []);

const showExpandIcon = useMemo(() => {
const rect = childrenRef.current?.getBoundingClientRect();
return !!(rect?.height && rect.height > 400);
useEffect(() => {
// note this render,
// when children changed, the render in the micro tasks queue last,
// we need use a macro task to get the rendered height.
setTimeout(() => {
const rect = childrenRef.current?.getBoundingClientRect();
setShowExpandIcon(!!(rect?.height && rect.height > 400));
});
}, [childrenRef.current, props.children]);

return (
Expand Down
10 changes: 7 additions & 3 deletions src/components/ProjectDeployments/ProjectDeployments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const ProjectDeployments: React.FC<Props> = ({ deployments, projectId, currentDe
const [deploymentModal, setDeploymentModal] = React.useState<boolean>(false);
const [form] = useForm();
const [currentDeployment, setCurrentDeployment] = React.useState<Deployment>();

const handleSubmitUpdate = async () => {
try {
await form.validateFields();
Expand Down Expand Up @@ -65,7 +64,13 @@ const ProjectDeployments: React.FC<Props> = ({ deployments, projectId, currentDe
onSubmit={handleSubmitUpdate}
>
<div>
<Form form={form} layout="vertical">
<Form
form={form}
layout="vertical"
initialValues={{
description: currentDeployment?.description || '',
}}
>
<Form.Item label="Deployment Description" name="description" rules={[{ required: true }]}>
<div className={styles.markdownWrapper}>
<Markdown
Expand Down Expand Up @@ -134,7 +139,6 @@ const ProjectDeployments: React.FC<Props> = ({ deployments, projectId, currentDe
<Typography.Link
active
onClick={() => {
form.setFieldValue('description', record.description || '');
setCurrentDeployment(record);
setDeploymentModal(true);
}}
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useCreateDeployment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export function useCreateDeployment(
description: deploymentDetails.description,
});

console.log('Uploaded version details', versionCid);
debugger;
const tx = await projectRegistry.updateDeployment(
projectId,
deploymentDetails.deploymentId,
Expand Down

0 comments on commit ea0d9bf

Please sign in to comment.