Skip to content

Commit 17c39b7

Browse files
committed
Re-enable action buttons after errors and show error alert
This is a temporary solution, we'll be switching to Apollo 3 and mutation hooks
1 parent 1b1af55 commit 17c39b7

File tree

7 files changed

+172
-111
lines changed

7 files changed

+172
-111
lines changed

src/components/Arguments/components.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,20 @@ export const ActionButton: React.FC<InteractionButtonProps> = ({
244244
active = true,
245245
onClick,
246246
}) => {
247-
const { project, active: activeEditor, getActiveCode } = useProject();
247+
const {
248+
project,
249+
active: activeEditor,
250+
getActiveCode,
251+
showSavingMessage,
252+
} = useProject();
248253
const label = getLabel(type, project, activeEditor);
249-
const { isSavingCode } = useProject();
250-
const sendingTransaction = false;
251254
const code = getActiveCode()[0].trim();
252255
return (
253256
<Controls>
254257
<Button
255258
onClick={onClick}
256259
Icon={FaArrowCircleRight}
257-
disabled={isSavingCode || !active || code.length === 0}
258-
isLoading={sendingTransaction}
260+
disabled={showSavingMessage || !active || code.length === 0}
259261
>
260262
{label}
261263
</Button>

src/components/Arguments/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ type ProcessingArgs = {
141141
};
142142

143143
const useTemplateType = (): ProcessingArgs => {
144-
const { isSavingCode } = useProject();
144+
const { showSavingMessage } = useProject();
145145
const {
146146
createScriptExecution,
147147
createTransactionExecution,
148148
updateAccountDeployedCode,
149149
} = useProject();
150150

151151
return {
152-
disabled: isSavingCode,
152+
disabled: showSavingMessage,
153153
scriptFactory: createScriptExecution,
154154
transactionFactory: createTransactionExecution,
155155
contractDeployment: updateAccountDeployedCode,
@@ -218,7 +218,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
218218
const {
219219
project,
220220
active,
221-
isSavingCode,
221+
showSavingMessage,
222222
lastSigners,
223223
// updateAccountDeployedCode
224224
} = useProject();
@@ -356,7 +356,7 @@ const Arguments: React.FC<ArgumentsProps> = (props) => {
356356
let statusIcon = isOk ? <FaRegCheckCircle /> : <FaRegTimesCircle />;
357357
let statusMessage = isOk ? 'Ready' : 'Fix errors';
358358

359-
const progress = isSavingCode || processingStatus;
359+
const progress = showSavingMessage || processingStatus;
360360

361361
if (progress) {
362362
statusIcon = <FaSpinner className="spin" />;

src/components/CadenceEditor/ControlPanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const ControlPanel: React.FC<ControlPanelProps> = (props) => {
6565
// ===========================================================================
6666
// GLOBAL HOOKS
6767
const { languageClient } = useContext(CadenceCheckerContext);
68-
const { project, active, isSavingCode } = useProject();
68+
const { project, active, showSavingMessage } = useProject();
6969

7070
// HOOKS -------------------------------------------------------------------
7171
const [executionArguments, setExecutionArguments] = useState({});
@@ -366,7 +366,7 @@ const ControlPanel: React.FC<ControlPanelProps> = (props) => {
366366
break;
367367
}
368368

369-
const progress = isSavingCode || processingStatus;
369+
const progress = showSavingMessage || processingStatus;
370370
if (progress) {
371371
statusIcon = <FaSpinner className="spin" />;
372372
statusMessage = 'Please, wait...';

src/components/CadenceEditor/ControlPanel/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ export const getLabel = (
9898
};
9999

100100
export const useTemplateType = (): ProcessingArgs => {
101-
const { isSavingCode } = useProject();
101+
const { showSavingMessage } = useProject();
102102
const {
103103
createScriptExecution,
104104
createTransactionExecution,
105105
updateAccountDeployedCode,
106106
} = useProject();
107107

108108
return {
109-
disabled: isSavingCode,
109+
disabled: showSavingMessage,
110110
scriptFactory: createScriptExecution,
111111
transactionFactory: createTransactionExecution,
112112
contractDeployment: updateAccountDeployedCode,

src/containers/Editor/components.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ const ShareSaveButton = ({
121121
onSave,
122122
icon,
123123
}: ShareSaveButtonProps) => {
124-
const { isSavingCode } = useProject();
124+
const { showSavingMessage } = useProject();
125125
return (
126126
<Box sx={{ marginRight: '0.5rem' }}>
127127
{showShare ? (
128128
<ShareButton url={url} />
129129
) : (
130130
<FlowButton
131131
onClick={() => onSave()}
132-
disabled={isSavingCode}
132+
disabled={showSavingMessage}
133133
Icon={icon}
134134
>
135135
{saveText}

src/containers/Editor/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const EditorLayout: React.FC = () => {
4949
const {
5050
project,
5151
updateProject,
52-
isSavingCode,
52+
showSavingMessage,
5353
isLoading,
5454
active,
5555
setSelectedResourceAccount,
@@ -197,7 +197,7 @@ const EditorLayout: React.FC = () => {
197197
}}
198198
>
199199
<AnimatePresence exitBeforeEnter>
200-
{project && project.persist && isSavingCode && (
200+
{project && project.persist && showSavingMessage && (
201201
<motion.div
202202
initial={{ opacity: 0 }}
203203
animate={{ opacity: 1 }}
@@ -209,7 +209,7 @@ const EditorLayout: React.FC = () => {
209209
Autosaving...
210210
</motion.div>
211211
)}
212-
{project && project.persist && !isSavingCode && (
212+
{project && project.persist && !showSavingMessage && (
213213
<motion.div
214214
initial={{ opacity: 0 }}
215215
animate={{ opacity: 1 }}

0 commit comments

Comments
 (0)