fix: activity tracking description (#8268)
* feat: add no_activity flag to control issue activity tracking during partial updates * refactor: rename no_activity flag to skip_activity for clarity in issue activity tracking * enhance description input handling with migration update support * feat: implement skip_activity flag to conditionally log issue updates during partial updates * refactor: skip-activity * feat: add migration description update check to conditionally log issue updates --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
This commit is contained in:
parent
f0bc2bd3bd
commit
a9e9cb2983
9 changed files with 83 additions and 54 deletions
|
|
@ -22,6 +22,7 @@ const workspaceService = new WorkspaceService();
|
|||
type TFormData = {
|
||||
id: string;
|
||||
description_html: string;
|
||||
isMigrationUpdate: boolean;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
|
|
@ -56,7 +57,7 @@ type Props = {
|
|||
/**
|
||||
* @description Submit handler, the actual function which will be called when the form is submitted
|
||||
*/
|
||||
onSubmit: (value: string) => Promise<void>;
|
||||
onSubmit: (value: string, isMigrationUpdate?: boolean) => Promise<void>;
|
||||
/**
|
||||
* @description Placeholder, if not provided, the placeholder will be the default placeholder
|
||||
*/
|
||||
|
|
@ -108,6 +109,7 @@ export const DescriptionInput = observer(function DescriptionInput(props: Props)
|
|||
const [localDescription, setLocalDescription] = useState<TFormData>({
|
||||
id: entityId,
|
||||
description_html: initialValue?.trim() ?? "",
|
||||
isMigrationUpdate: false,
|
||||
});
|
||||
// ref to track if there are unsaved changes
|
||||
const hasUnsavedChanges = useRef(false);
|
||||
|
|
@ -119,17 +121,18 @@ export const DescriptionInput = observer(function DescriptionInput(props: Props)
|
|||
// translation
|
||||
const { t } = useTranslation();
|
||||
// form info
|
||||
const { handleSubmit, reset, control } = useForm<TFormData>({
|
||||
const { handleSubmit, reset, control, setValue } = useForm<TFormData>({
|
||||
defaultValues: {
|
||||
id: entityId,
|
||||
description_html: initialValue?.trim() ?? "",
|
||||
isMigrationUpdate: false,
|
||||
},
|
||||
});
|
||||
|
||||
// submit handler
|
||||
const handleDescriptionFormSubmit = useCallback(
|
||||
async (formData: TFormData) => {
|
||||
await onSubmit(formData.description_html);
|
||||
await onSubmit(formData.description_html, formData.isMigrationUpdate);
|
||||
},
|
||||
[onSubmit]
|
||||
);
|
||||
|
|
@ -140,10 +143,12 @@ export const DescriptionInput = observer(function DescriptionInput(props: Props)
|
|||
reset({
|
||||
id: entityId,
|
||||
description_html: initialValue?.trim() === "" ? "<p></p>" : (initialValue ?? "<p></p>"),
|
||||
isMigrationUpdate: false,
|
||||
});
|
||||
setLocalDescription({
|
||||
id: entityId,
|
||||
description_html: initialValue?.trim() === "" ? "<p></p>" : (initialValue ?? "<p></p>"),
|
||||
isMigrationUpdate: false,
|
||||
});
|
||||
// Reset unsaved changes flag when form is reset
|
||||
hasUnsavedChanges.current = false;
|
||||
|
|
@ -206,9 +211,10 @@ export const DescriptionInput = observer(function DescriptionInput(props: Props)
|
|||
workspaceId={workspaceDetails.id}
|
||||
projectId={projectId}
|
||||
dragDropEnabled
|
||||
onChange={(_description, description_html) => {
|
||||
onChange={(_description, description_html, options) => {
|
||||
setIsSubmitting("submitting");
|
||||
onChange(description_html);
|
||||
setValue("isMigrationUpdate", options?.isMigrationUpdate ?? false);
|
||||
hasUnsavedChanges.current = true;
|
||||
debouncedFormSave();
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -201,10 +201,11 @@ export const InboxIssueMainContent = observer(function InboxIssueMainContent(pro
|
|||
entityId={issue.id}
|
||||
fileAssetType={EFileAssetType.ISSUE_DESCRIPTION}
|
||||
initialValue={issue.description_html ?? "<p></p>"}
|
||||
onSubmit={async (value) => {
|
||||
onSubmit={async (value, isMigrationUpdate) => {
|
||||
if (!issue.id || !issue.project_id) return;
|
||||
await issueOperations.update(workspaceSlug, issue.project_id, issue.id, {
|
||||
description_html: value,
|
||||
...(isMigrationUpdate ? { skip_activity: "true" } : {}),
|
||||
});
|
||||
}}
|
||||
projectId={issue.project_id}
|
||||
|
|
|
|||
|
|
@ -134,10 +134,11 @@ export const IssueMainContent = observer(function IssueMainContent(props: Props)
|
|||
entityId={issue.id}
|
||||
fileAssetType={EFileAssetType.ISSUE_DESCRIPTION}
|
||||
initialValue={issue.description_html}
|
||||
onSubmit={async (value) => {
|
||||
onSubmit={async (value, isMigrationUpdate) => {
|
||||
if (!issue.id || !issue.project_id) return;
|
||||
await issueOperations.update(workspaceSlug, issue.project_id, issue.id, {
|
||||
description_html: value,
|
||||
...(isMigrationUpdate ? { skip_activity: "true" } : {}),
|
||||
});
|
||||
}}
|
||||
projectId={issue.project_id}
|
||||
|
|
|
|||
|
|
@ -134,10 +134,11 @@ export const PeekOverviewIssueDetails = observer(function PeekOverviewIssueDetai
|
|||
entityId={issue.id}
|
||||
fileAssetType={EFileAssetType.ISSUE_DESCRIPTION}
|
||||
initialValue={issueDescription}
|
||||
onSubmit={async (value) => {
|
||||
onSubmit={async (value, isMigrationUpdate) => {
|
||||
if (!issue.id || !issue.project_id) return;
|
||||
await issueOperations.update(workspaceSlug, issue.project_id, issue.id, {
|
||||
description_html: value,
|
||||
...(isMigrationUpdate ? { skip_activity: "true" } : {}),
|
||||
});
|
||||
}}
|
||||
setIsSubmitting={(value) => setIsSubmitting(value)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue