Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed revert Button disabled #333

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pr-notification.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR Notification to Google Chat

on:
pull_request:
pull_request_target:
types: [opened, synchronize, closed]
branches:
- develop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface HistoryModalProps {
historyCount: number;
currentVersionId?:number|string;
disabledData:{key:string,value:any}
ignoreFirstEntryDisable?: boolean
}

interface AllHistory {
Expand Down Expand Up @@ -111,6 +112,7 @@ export const HistoryModal: React.FC<HistoryModalProps> = React.memo(
categoryType,
historyCount,
currentVersionId,
ignoreFirstEntryDisable = false,
disabledData = {key:"", value:""} // we can pass the key and its value based on that we can disable revert button eg: key:"processKey",value:"bpmn" if the data[key] == value it will disable
}) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -225,7 +227,8 @@ export const HistoryModal: React.FC<HistoryModalProps> = React.memo(
const cloned_form_id =
categoryType === "FORM" ? entry.changeLog.cloned_form_id : null;
const process_id = categoryType === "WORKFLOW" ? entry.id : null;
const isLastEntry = index === allHistory.length - 1;
const isLastEntry = index === allHistory.length - 1;
const revertButtonDisabled = entry[disabledData.key] == disabledData.value || (!ignoreFirstEntryDisable && index === 0);
const fields = [
{ id:1, heading: t("Last Edit On"), value: formatDate(entry.created) },
{ id:2, heading: t("Last Edit By"), value: entry.createdBy },
Expand All @@ -234,6 +237,7 @@ export const HistoryModal: React.FC<HistoryModalProps> = React.memo(
? [{ id:4, heading: t("Type"), value: entry.processType }]
: []),
];

return (
<React.Fragment key={`${entry.version}-${index}`}>
{isMajorVersion && (
Expand All @@ -248,7 +252,7 @@ export const HistoryModal: React.FC<HistoryModalProps> = React.memo(
<RevertField
variant="secondary"
size="sm"
disabled={currentVersionId == entry.id || entry[disabledData.key] == disabledData.value}
disabled={revertButtonDisabled}
label={revertBtnText}
onClick={() =>
handleRevertClick(version, cloned_form_id, process_id)
Expand All @@ -271,7 +275,7 @@ export const HistoryModal: React.FC<HistoryModalProps> = React.memo(
variant="secondary"
size="sm"
label={revertBtnText}
disabled={currentVersionId == entry.id || entry[disabledData.key] == disabledData.value}
disabled={revertButtonDisabled}
onClick={() =>
handleRevertClick(version, cloned_form_id, process_id)
}
Expand Down
Loading