Skip to content

Commit

Permalink
Disable buttons when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed Aug 22, 2024
1 parent 9080a8c commit 719ebde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
handleExecute,
handlePublish,
handleReset,
resetPublishDisabled,
onChange,
}: {
formValues: ServerlessFunctionFormValues;
handleExecute: () => void;
handlePublish: () => void;
handleReset: () => void;
resetPublishDisabled: boolean;
onChange: (key: string) => (value: string) => void;
}) => {
const TestButton = (
Expand All @@ -41,6 +43,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
size="small"
Icon={IconGitCommit}
onClick={handlePublish}
disabled={resetPublishDisabled}
/>
);
const ResetButton = (
Expand All @@ -50,6 +53,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
size="small"
Icon={IconRestore}
onClick={handleReset}
disabled={resetPublishDisabled}
/>
);

Expand All @@ -65,7 +69,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
const Header = (
<CoreEditorHeader
leftNodes={[HeaderTabList]}
rightNodes={[TestButton, PublishButton, ResetButton]}
rightNodes={[ResetButton, PublishButton, TestButton]}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const SettingsServerlessFunctionDetail = () => {
};
};

const resetPublishDisabled = latestVersionCode === formValues.code;

const handleReset = async () => {
try {
const newState = {
Expand Down Expand Up @@ -167,6 +169,7 @@ export const SettingsServerlessFunctionDetail = () => {
handleExecute={handleExecute}
handlePublish={handlePublish}
handleReset={handleReset}
resetPublishDisabled={resetPublishDisabled}
onChange={onChange}
/>
);
Expand Down

0 comments on commit 719ebde

Please sign in to comment.