Skip to content

Commit

Permalink
feat(Airtable Node): Overhaul (#6200)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency authored and OlegIvaniv committed Aug 3, 2023
1 parent 2a75136 commit 7e21d6c
Show file tree
Hide file tree
Showing 41 changed files with 3,988 additions and 871 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/17-sharing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ describe('Sharing', { disableAutoLogin: true }, () => {

cy.visit(credentialsPage.url);
credentialsPage.getters.emptyListCreateCredentialButton().click();
credentialsModal.getters.newCredentialTypeOption('Airtable API').click();
credentialsModal.getters.newCredentialTypeOption('Airtable Personal Access Token API').click();
credentialsModal.getters.newCredentialTypeButton().click();
credentialsModal.getters.connectionParameter('API Key').type('1234567890');
credentialsModal.getters.connectionParameter('Access Token').type('1234567890');
credentialsModal.actions.setName('Credential C2');
credentialsModal.actions.changeTab('Sharing');
credentialsModal.actions.addUser(INSTANCE_OWNER.email);
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ describe('NDV', () => {

it('should show validation errors only after blur or re-opening of NDV', () => {
workflowPage.actions.addNodeToCanvas('Manual');
workflowPage.actions.addNodeToCanvas('Airtable', true, true, 'Read data from a table');
workflowPage.actions.addNodeToCanvas('Airtable', true, true, 'Search records');
ndv.getters.container().should('be.visible');
cy.get('.has-issues').should('have.length', 0);
// cy.get('.has-issues').should('have.length', 0);
ndv.getters.parameterInput('table').find('input').eq(1).focus().blur();
ndv.getters.parameterInput('application').find('input').eq(1).focus().blur();
cy.get('.has-issues').should('have.length', 2);
ndv.getters.parameterInput('base').find('input').eq(1).focus().blur();
cy.get('.has-issues').should('have.length', 0);
ndv.getters.backToCanvas().click();
workflowPage.actions.openNode('Airtable');
cy.get('.has-issues').should('have.length', 3);
cy.get('.has-issues').should('have.length', 2);
cy.get('[class*=hasIssues]').should('have.length', 1);
});

Expand Down
16 changes: 13 additions & 3 deletions packages/editor-ui/src/components/ResourceMapper/MappingFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ const emit = defineEmits<{
const ndvStore = useNDVStore();
const fieldsUi = computed<INodeProperties[]>(() => {
function markAsReadOnly(field: ResourceMapperField): boolean {
if (
isMatchingField(field.id, props.paramValue.matchingColumns, props.showMatchingColumnsSelector)
) {
return false;
}
return field.readOnly || false;
}
const fieldsUi = computed<Array<Partial<INodeProperties> & { readOnly?: boolean }>>(() => {
return props.fieldsToMap
.filter((field) => field.display !== false && field.removed !== true)
.map((field) => {
Expand All @@ -64,11 +73,12 @@ const fieldsUi = computed<INodeProperties[]>(() => {
required: field.required,
description: getFieldDescription(field),
options: field.options,
readOnly: markAsReadOnly(field),
};
});
});
const orderedFields = computed<INodeProperties[]>(() => {
const orderedFields = computed<Array<Partial<INodeProperties> & { readOnly?: boolean }>>(() => {
// Sort so that matching columns are first
if (props.paramValue.matchingColumns) {
fieldsUi.value.forEach((field, i) => {
Expand Down Expand Up @@ -333,7 +343,7 @@ defineExpose({
:value="getParameterValue(field.name)"
:displayOptions="true"
:path="`${props.path}.${field.name}`"
:isReadOnly="refreshInProgress"
:isReadOnly="refreshInProgress || field.readOnly"
:hideIssues="true"
:nodeValues="nodeValues"
:class="$style.parameterInputFull"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const emit = defineEmits<{
const availableMatchingFields = computed<ResourceMapperField[]>(() => {
return props.fieldsToMap.filter((field) => {
return field.canBeUsedToMatch !== false && field.display !== false;
return (field.canBeUsedToMatch || field.defaultMatch) && field.display !== false;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ const hasAvailableMatchingColumns = computed<boolean>(() => {
return (
state.paramValue.schema.filter(
(field) =>
field.canBeUsedToMatch !== false && field.display !== false && field.removed !== true,
(field.canBeUsedToMatch || field.defaultMatch) &&
field.display !== false &&
field.removed !== true,
).length > 0
);
}
Expand All @@ -178,7 +180,7 @@ const defaultSelectedMatchingColumns = computed<string[]>(() => {
return state.paramValue.schema.length === 1
? [state.paramValue.schema[0].id]
: state.paramValue.schema.reduce((acc, field) => {
if (field.defaultMatch && field.canBeUsedToMatch === true) {
if (field.defaultMatch) {
acc.push(field.id);
}
return acc;
Expand Down
10 changes: 10 additions & 0 deletions packages/nodes-base/credentials/AirtableTokenApi.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export class AirtableTokenApi implements ICredentialType {
typeOptions: { password: true },
default: '',
},
{
displayName: `Make sure you enabled the following scopes for your token:<br>
<code>data.records:read</code><br>
<code>data.records:write</code><br>
<code>schema.bases:read</code><br>
`,
name: 'notice',
type: 'notice',
default: '',
},
];

authenticate: IAuthenticateGeneric = {
Expand Down
Loading

0 comments on commit 7e21d6c

Please sign in to comment.