-
Notifications
You must be signed in to change notification settings - Fork 458
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
[NAN-676] enforce cap when activating a script #1953
Merged
khaliqgant
merged 18 commits into
master
from
khaliq/nan-676-enforce-cap-when-activating-a-script
Apr 5, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bd7c56c
[nan-680] add plan types and admin only api to edit
khaliqgant c78711e
[nan-680] allow null
khaliqgant f6e4d07
[nan-677] start creation hook
khaliqgant d873fc0
[nan-680] is capped
khaliqgant 2253964
[nan-680] remove unused
khaliqgant 1118e38
[nan-680] proper reference
khaliqgant db1a39e
Merge branch 'khaliq/nan-680-implement-way-to-upgradedowngrade-custom…
khaliqgant 1bfda39
[nan-677] start logic for checking the connections
khaliqgant 4fd9580
[nan-680] remove try catch
khaliqgant 92b3ea7
Merge branch 'khaliq/nan-680-implement-way-to-upgradedowngrade-custom…
khaliqgant 5d694fd
[nan-677] auth capping for create and import
khaliqgant b95ea12
[nan-677] bring in latest
khaliqgant 3c50b11
[nan-677] feedback
khaliqgant 8656bc9
[nan-677] don't cap users actually until have a chance to set the cor…
khaliqgant 44eabf7
Merge branch 'master' of github.com:NangoHQ/nango into khaliq/nan-677…
khaliqgant 469a893
[nan-676] cap on activation
khaliqgant a3d6028
bring in latest
khaliqgant b597d66
[nan-676] make providerConfigKey required
khaliqgant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export const SYNC_TASK_QUEUE = 'nango-syncs'; | ||
export const WEBHOOK_TASK_QUEUE = 'nango-webhooks'; | ||
//export const CONNECTIONS_WITH_SCRIPTS_CAP_LIMIT = 3; | ||
export const CONNECTIONS_WITH_SCRIPTS_CAP_LIMIT = Infinity; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,28 @@ export default function EnableDisableSync({ | |
|
||
const [modalTitle, setModalTitle] = useState(''); | ||
const [modalContent, setModalContent] = useState(''); | ||
const [modalOkButtonTitle, setModalOkButtonTitle] = useState('Confirm'); | ||
const [modalCancelButtonTitle, setModalCancelButtonTitle] = useState('Cancel'); | ||
const [modalOkButtonLink, setModalOkButtonLink] = useState<string | null>(null); | ||
const [modalCancelButtonLink, setModalCancelButtonLink] = useState<string | null>(null); | ||
const [modalAction, setModalAction] = useState<(() => void) | null>(null); | ||
const [modalShowSpinner, setModalShowSpinner] = useState(false); | ||
const [modalTitleColor, setModalTitleColor] = useState('text-white'); | ||
|
||
const resetModal = () => { | ||
setModalTitle(''); | ||
setModalContent(''); | ||
setModalOkButtonTitle('Confirm'); | ||
setModalCancelButtonTitle('Cancel'); | ||
setModalOkButtonLink(null); | ||
setModalCancelButtonLink(null); | ||
setModalAction(null); | ||
setModalShowSpinner(false); | ||
setModalTitleColor('text-white'); | ||
}; | ||
|
||
const enableSync = (flow: Flow) => { | ||
resetModal(); | ||
setModalTitle(`Enable ${flow.type}?`); | ||
setModalTitleColor('text-white'); | ||
const content = | ||
|
@@ -96,9 +113,26 @@ export default function EnableDisableSync({ | |
reload(); | ||
} else { | ||
const payload = await res?.json(); | ||
toast.error(payload.error, { | ||
position: toast.POSITION.BOTTOM_CENTER | ||
}); | ||
if (payload.type === 'resource_capped') { | ||
setModalShowSpinner(false); | ||
setModalTitleColor('text-white'); | ||
setModalTitle('You’ve reached your connections limit!'); | ||
setModalContent( | ||
`Scripts are a paid feature. You can only use them with 3 connections or less. | ||
Upgrade or delete some connections to activate this script.` | ||
); | ||
setModalOkButtonTitle('Upgrade'); | ||
setModalCancelButtonTitle('Learn more'); | ||
setModalOkButtonLink('https://nango.dev/chat'); | ||
setModalCancelButtonLink('https://docs.nango.dev/REPLACE-ME'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it going to be replace later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, launch blocker to replace. |
||
setVisible(true); | ||
|
||
return; | ||
} else { | ||
toast.error(payload.error, { | ||
position: toast.POSITION.BOTTOM_CENTER | ||
}); | ||
} | ||
} | ||
setModalShowSpinner(false); | ||
if (setIsEnabling) { | ||
|
@@ -108,6 +142,7 @@ export default function EnableDisableSync({ | |
}; | ||
|
||
const disableSync = (flow: Flow) => { | ||
resetModal(); | ||
if (!flow.is_public) { | ||
const title = 'Custom syncs cannot be disabled from the UI'; | ||
const message = flow.pre_built | ||
|
@@ -182,6 +217,10 @@ export default function EnableDisableSync({ | |
modalShowSpinner={modalShowSpinner} | ||
modalTitleColor={modalTitleColor} | ||
setVisible={setVisible} | ||
modalOkTitle={modalOkButtonTitle} | ||
modalCancelTitle={modalCancelButtonTitle} | ||
modalOkLink={modalOkButtonLink} | ||
modalCancelLink={modalCancelButtonLink} | ||
/> | ||
{showSpinner && (!('version' in flow) || flow.version === null) && modalShowSpinner && ( | ||
<span className="mr-2"> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, very much so. We don't want to cap until we can set the account information correctly via the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thought about it during the night (could not sleep). We also have to think about enterprise/community 👌🏻