Skip to content

Commit

Permalink
Show record prop on additionalProps error if manual table input
Browse files Browse the repository at this point in the history
  • Loading branch information
js07 committed May 23, 2022
1 parent 2b037da commit b13ef25
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export default {
const tableSchema = await this.airtable.table(baseId, tableId);
return makeFieldProps(tableSchema);
} catch (err) {
const hasManualTableInput = !this.tableId?.label;
// If manual input and .table throws error, return a record prop
// otherwise, throw ConfigurationError
if (hasManualTableInput) {
return {
record: {
type: "object",
label: "Record",
description: "Enter the column name for the key and the corresponding column value. You can include all, some, or none of the field values. You may also pass a JSON object as a custom expression with key/value pairs representing columns and values.",
},
};
}
throw new ConfigurationError("Could not find a table for the specified base ID and table ID. Please adjust the action configuration to continue.");
}
},
Expand All @@ -42,7 +54,7 @@ export default {

const table = this.airtable.base(baseId)(tableId);

const record = makeRecord(this);
const record = this.record ?? makeRecord(this);

this.airtable.validateRecord(record);

Expand Down
12 changes: 11 additions & 1 deletion components/airtable/actions/update-record/update-record.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export default {
const tableSchema = await this.airtable.table(baseId, tableId);
return makeFieldProps(tableSchema);
} catch (err) {
const hasManualTableInput = !this.tableId?.label;
if (hasManualTableInput) {
return {
record: {
type: "object",
label: "Record",
description: "Enter the column name for the key and the corresponding column value. You can include all, some, or none of the field values. You may also pass a JSON object as a custom expression with key/value pairs representing columns and values.",
},
};
}
throw new ConfigurationError("Could not find a table for the specified base ID and table ID. Please adjust the action configuration to continue.");
}
},
Expand All @@ -43,7 +53,7 @@ export default {

this.airtable.validateRecordID(recordId);

const record = makeRecord(this);
const record = this.record ?? makeRecord(this);

const base = this.airtable.base(baseId);
let response;
Expand Down

0 comments on commit b13ef25

Please sign in to comment.