SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
Refactor AgentSettingsPage and enhance dropdown functionality
Salman-Ahamede6d45242662a
diff --git a/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx b/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsxindex 410dfb68..3c1c9c88 100644--- a/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx+++ b/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx@@ -26,9 +26,7 @@ import { BaseAgentSettingsTabs } from '../constants';const OPEN_TAB = 'Overview';-type Props = {};--export const AgentSettingsPage = (props: Props) => {+export const AgentSettingsPage = () => {return (<TooltipProvider delayDuration={300} skipDelayDuration={100}><AgentSettingsProvider>@@ -103,7 +101,7 @@ export const AgentSettingTabs = () => {],};- let mergedWidgets = { ...baseWidgets, ...pluginWidgets };+ const mergedWidgets = { ...baseWidgets, ...pluginWidgets };// we need to make sure that the original widgets objects are not overridden by the plugin widgets if the same key existsObject.keys(baseWidgets).forEach((key) => {@@ -133,7 +131,7 @@ export const AgentSettingTabs = () => {})}</div><div className="grid grid-cols-1 gap-6">- {Object.entries(mergedWidgets).map(([key, widgetlist]: [string, any[]], index) =>+ {Object.entries(mergedWidgets).map(([key, widgetlist]: [string, any[]]) =>widgetlist.map((widget, index) => (<div key={index} hidden={currentTab !== key}>{widget}@@ -145,11 +143,25 @@ export const AgentSettingTabs = () => {);};-export const AgentSettingsPageBody = (props: Props) => {+export const AgentSettingsPageBody = () => {const { agentId, agentQuery, agentTestDomainQuery, settingsQuery } = useAgentSettingsCtx();const { userInfo } = useAuthCtx();const isOnPaidPlan = userInfo?.subs?.plan?.paid ?? false;const containerRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ Observability.observeInteraction('upgrade_impression', {+ page_url: '/agent_settings',+ source: 'upgrade button displayed alongside My Workflow',+ });+ }, []);++ useEffect(() => {+ if (agentQuery.isFetched && settingsQuery.isFetched) {+ containerRef.current?.scrollIntoView({ block: 'start', behavior: 'smooth' });+ }+ }, [agentQuery.isFetched, settingsQuery.isFetched]);+if (!agentQuery.isLoading && !agentTestDomainQuery.isLoading) {if (agentQuery?.error?.['status'] == 403 || agentTestDomainQuery?.error?.['status'] == 403) {window.location.href = '/error/403';@@ -168,7 +180,9 @@ export const AgentSettingsPageBody = (props: Props) => {{agentQuery.data?.name && (<Breadcrumb.Item>- <Link to={`/agent-settings/${agentId}`}>'{agentQuery.data?.name}' Settings</Link>+ <Link to={`/agent-settings/${agentId}`}>+ '{agentQuery.data?.name}' Settings+ </Link></Breadcrumb.Item>)}</Breadcrumb>@@ -182,19 +196,6 @@ export const AgentSettingsPageBody = (props: Props) => {window.location.href = config.env.IS_DEV ? '/plans' : PRICING_PLAN_REDIRECT;};- useEffect(() => {- Observability.observeInteraction('upgrade_impression', {- page_url: '/agent_settings',- source: 'upgrade button displayed alongside My Workflow',- });- }, []);-- useEffect(() => {- if (agentQuery.isFetched && settingsQuery.isFetched) {- containerRef.current?.scrollIntoView({ block: 'start', behavior: 'smooth' });- }- }, [agentQuery.isFetched, settingsQuery.isFetched]);-return (<div ref={containerRef} className="w-full max-w-[822px] m-auto pb-10 pl-[58px] md:pl-0"><div className="flex justify-between items-center">{breadcrumb}</div>diff --git a/packages/app/views/menus/main-menu.ejs b/packages/app/views/menus/main-menu.ejsindex 1b16f82a..119cf59b 100644--- a/packages/app/views/menus/main-menu.ejs+++ b/packages/app/views/menus/main-menu.ejs@@ -38,9 +38,10 @@<div class="relative"><buttontype="button"- class="flex text-sm rounded-full"+ class="flex text-sm rounded-full ring-2 ring-transparent hover:ring-gray-200 focus:ring-primary-100 transition-all duration-150 cursor-pointer"id="user-menu-button"aria-expanded="false"+ aria-haspopup="true"data-dropdown-toggle="user-dropdown"data-dropdown-placement="bottom">@@ -62,8 +63,10 @@</button><div- class="hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow"+ class="hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow-lg border border-gray-100"id="user-dropdown"+ role="menu"+ aria-labelledby="user-menu-button"><div class="px-4 pt-3 pb-1"><span class="block text-sm text-gray-900"><%= user?.name %></span>@@ -86,9 +89,10 @@<div class="relative xl:hidden"><buttontype="button"- class="flex xl:hidden text-sm p-1 border-2 border-solid border-transparent focus:border-primary-100 rounded-lg focus:ring-0"+ class="flex xl:hidden text-sm p-1 border-2 border-solid border-transparent hover:border-gray-200 focus:border-primary-100 rounded-lg focus:ring-0 transition-all duration-150 cursor-pointer"id="hamburger-menu-button"aria-expanded="false"+ aria-haspopup="true"data-dropdown-toggle="hamburger-dropdown"data-dropdown-placement="bottom">@@ -111,8 +115,10 @@</button><div- class="hidden xl:hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow"+ class="hidden xl:hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow-lg border border-gray-100"id="hamburger-dropdown"+ role="menu"+ aria-labelledby="hamburger-menu-button"><ul class="block py-2"><% navPages?.forEach(page => { %>@@ -127,3 +133,101 @@</div></div></nav>++<script>+/**+ * Initializes dropdown toggle functionality for elements with data-dropdown-toggle attribute.+ * This handles click events on dropdown trigger buttons and closes dropdowns when clicking outside.+ */+(function initDropdownToggles() {+ 'use strict';++ /**+ * Toggles the visibility of a dropdown menu.+ * @param {HTMLElement} dropdown - The dropdown element to toggle+ * @param {HTMLElement} button - The button that triggered the toggle+ * @param {boolean} show - Whether to show (true) or hide (false) the dropdown+ */+ function toggleDropdown(dropdown, button, show) {+ if (show) {+ dropdown.classList.remove('hidden');+ button.setAttribute('aria-expanded', 'true');+ } else {+ dropdown.classList.add('hidden');+ button.setAttribute('aria-expanded', 'false');+ }+ }++ /**+ * Checks if a dropdown is currently visible.+ * @param {HTMLElement} dropdown - The dropdown element to check+ * @returns {boolean} True if the dropdown is visible+ */+ function isDropdownVisible(dropdown) {+ return !dropdown.classList.contains('hidden');+ }++ /**+ * Closes all open dropdowns except the one specified.+ * @param {HTMLElement|null} exceptDropdown - Dropdown to exclude from closing (optional)+ */+ function closeAllDropdowns(exceptDropdown) {+ var buttons = document.querySelectorAll('[data-dropdown-toggle]');+ buttons.forEach(function(btn) {+ var targetId = btn.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);+ if (dropdown && dropdown !== exceptDropdown && isDropdownVisible(dropdown)) {+ toggleDropdown(dropdown, btn, false);+ }+ });+ }++ // Initialize click handlers for all dropdown toggle buttons+ document.addEventListener('DOMContentLoaded', function() {+ var toggleButtons = document.querySelectorAll('[data-dropdown-toggle]');++ toggleButtons.forEach(function(button) {+ var targetId = button.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);++ if (!dropdown) {+ console.warn('Dropdown target not found:', targetId);+ return;+ }++ // Handle button click to toggle dropdown+ button.addEventListener('click', function(event) {+ event.preventDefault();+ event.stopPropagation();++ var shouldShow = !isDropdownVisible(dropdown);++ // Close other dropdowns first+ closeAllDropdowns(dropdown);++ // Toggle this dropdown+ toggleDropdown(dropdown, button, shouldShow);+ });+ });++ // Close dropdowns when clicking outside+ document.addEventListener('click', function(event) {+ var target = event.target;++ // Check if click is inside any dropdown or toggle button+ var clickedInsideDropdown = target.closest('[data-dropdown-toggle], [id$="-dropdown"]');++ if (!clickedInsideDropdown) {+ closeAllDropdowns(null);+ }+ });++ // Close dropdowns when pressing Escape key+ document.addEventListener('keydown', function(event) {+ if (event.key === 'Escape') {+ closeAllDropdowns(null);+ }+ });+ });+})();+</script>diff --git a/packages/app/views/pages/partials/chat/top-nav.ejs b/packages/app/views/pages/partials/chat/top-nav.ejsindex 23f8e947..3b862c80 100644--- a/packages/app/views/pages/partials/chat/top-nav.ejs+++ b/packages/app/views/pages/partials/chat/top-nav.ejs@@ -14,10 +14,10 @@- <div class="flex items-center md:order-2">+ <div class="flex items-center md:order-2 relative"><button type="button"- class="flex mr-3 text-sm bg-gray-800 rounded-full md:mr-0 focus:ring-4 focus:ring-gray-300 focus:ring-gray-600"- id="user-menu-button" aria-expanded="false" data-dropdown-toggle="user-dropdown"+ class="flex mr-3 text-sm bg-gray-800 rounded-full md:mr-0 ring-2 ring-transparent hover:ring-gray-500 focus:ring-gray-300 transition-all duration-150 cursor-pointer"+ id="user-menu-button" aria-expanded="false" aria-haspopup="true" data-dropdown-toggle="user-dropdown"data-dropdown-placement="bottom"><span class="sr-only">Open user menu</span><% if (user?.picture) { %>@@ -34,8 +34,10 @@<% } %></button><!-- Dropdown menu -->- <div class="z-50 hidden my-4 text-base list-none divide-y divide-gray-100 rounded-lg shadow bg-gray-700 divide-gray-600"- id="user-dropdown">+ <div class="z-50 hidden absolute right-0 top-full my-4 text-base list-none divide-y divide-gray-100 rounded-lg shadow-lg bg-gray-700 divide-gray-600 border border-gray-600"+ id="user-dropdown"+ role="menu"+ aria-labelledby="user-menu-button"><div class="px-4 pt-3 pb-1"><span class="block text-sm text-gray-900 text-white"><%= user?.name %></span><span class="block text-sm text-gray-500 truncate text-gray-400"><%= user?.email %></span>@@ -60,4 +62,108 @@</button></div></div>-</nav>\ No newline at end of file+</nav>++<script>+/**+ * Initializes dropdown toggle functionality for elements with data-dropdown-toggle attribute.+ * This handles click events on dropdown trigger buttons and closes dropdowns when clicking outside.+ */+(function initDropdownToggles() {+ 'use strict';++ // Skip if already initialized (prevents duplicate initialization)+ if (window.__dropdownTogglesInitialized) {+ return;+ }+ window.__dropdownTogglesInitialized = true;++ /**+ * Toggles the visibility of a dropdown menu.+ * @param {HTMLElement} dropdown - The dropdown element to toggle+ * @param {HTMLElement} button - The button that triggered the toggle+ * @param {boolean} show - Whether to show (true) or hide (false) the dropdown+ */+ function toggleDropdown(dropdown, button, show) {+ if (show) {+ dropdown.classList.remove('hidden');+ button.setAttribute('aria-expanded', 'true');+ } else {+ dropdown.classList.add('hidden');+ button.setAttribute('aria-expanded', 'false');+ }+ }++ /**+ * Checks if a dropdown is currently visible.+ * @param {HTMLElement} dropdown - The dropdown element to check+ * @returns {boolean} True if the dropdown is visible+ */+ function isDropdownVisible(dropdown) {+ return !dropdown.classList.contains('hidden');+ }++ /**+ * Closes all open dropdowns except the one specified.+ * @param {HTMLElement|null} exceptDropdown - Dropdown to exclude from closing (optional)+ */+ function closeAllDropdowns(exceptDropdown) {+ var buttons = document.querySelectorAll('[data-dropdown-toggle]');+ buttons.forEach(function(btn) {+ var targetId = btn.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);+ if (dropdown && dropdown !== exceptDropdown && isDropdownVisible(dropdown)) {+ toggleDropdown(dropdown, btn, false);+ }+ });+ }++ // Initialize click handlers for all dropdown toggle buttons+ document.addEventListener('DOMContentLoaded', function() {+ var toggleButtons = document.querySelectorAll('[data-dropdown-toggle]');++ toggleButtons.forEach(function(button) {+ var targetId = button.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);++ if (!dropdown) {+ console.warn('Dropdown target not found:', targetId);+ return;+ }++ // Handle button click to toggle dropdown+ button.addEventListener('click', function(event) {+ event.preventDefault();+ event.stopPropagation();++ var shouldShow = !isDropdownVisible(dropdown);++ // Close other dropdowns first+ closeAllDropdowns(dropdown);++ // Toggle this dropdown+ toggleDropdown(dropdown, button, shouldShow);+ });+ });++ // Close dropdowns when clicking outside+ document.addEventListener('click', function(event) {+ var target = event.target;++ // Check if click is inside any dropdown or toggle button+ var clickedInsideDropdown = target.closest('[data-dropdown-toggle], [id$="-dropdown"]');++ if (!clickedInsideDropdown) {+ closeAllDropdowns(null);+ }+ });++ // Close dropdowns when pressing Escape key+ document.addEventListener('keydown', function(event) {+ if (event.key === 'Escape') {+ closeAllDropdowns(null);+ }+ });+ });+})();+</script>\ No newline at end of filediff --git a/packages/app/views/pages/partials/studio/builder-menu.ejs b/packages/app/views/pages/partials/studio/builder-menu.ejsindex ac7b2f52..b1ce625a 100644--- a/packages/app/views/pages/partials/studio/builder-menu.ejs+++ b/packages/app/views/pages/partials/studio/builder-menu.ejs@@ -825,4 +825,106 @@}}}++ /**+ * Initializes dropdown toggle functionality for elements with data-dropdown-toggle attribute.+ * This handles click events on dropdown trigger buttons and closes dropdowns when clicking outside.+ */+ (function initDropdownToggles() {+ 'use strict';++ // Skip if already initialized (prevents duplicate initialization)+ if (window.__dropdownTogglesInitialized) {+ return;+ }+ window.__dropdownTogglesInitialized = true;++ /**+ * Toggles the visibility of a dropdown menu.+ * @param {HTMLElement} dropdown - The dropdown element to toggle+ * @param {HTMLElement} button - The button that triggered the toggle+ * @param {boolean} show - Whether to show (true) or hide (false) the dropdown+ */+ function toggleDropdown(dropdown, button, show) {+ if (show) {+ dropdown.classList.remove('hidden');+ button.setAttribute('aria-expanded', 'true');+ } else {+ dropdown.classList.add('hidden');+ button.setAttribute('aria-expanded', 'false');+ }+ }++ /**+ * Checks if a dropdown is currently visible.+ * @param {HTMLElement} dropdown - The dropdown element to check+ * @returns {boolean} True if the dropdown is visible+ */+ function isDropdownVisible(dropdown) {+ return !dropdown.classList.contains('hidden');+ }++ /**+ * Closes all open dropdowns except the one specified.+ * @param {HTMLElement|null} exceptDropdown - Dropdown to exclude from closing (optional)+ */+ function closeAllDropdowns(exceptDropdown) {+ var buttons = document.querySelectorAll('[data-dropdown-toggle]');+ buttons.forEach(function(btn) {+ var targetId = btn.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);+ if (dropdown && dropdown !== exceptDropdown && isDropdownVisible(dropdown)) {+ toggleDropdown(dropdown, btn, false);+ }+ });+ }++ // Initialize click handlers for all dropdown toggle buttons+ document.addEventListener('DOMContentLoaded', function() {+ var toggleButtons = document.querySelectorAll('[data-dropdown-toggle]');++ toggleButtons.forEach(function(button) {+ var targetId = button.getAttribute('data-dropdown-toggle');+ var dropdown = document.getElementById(targetId);++ if (!dropdown) {+ console.warn('Dropdown target not found:', targetId);+ return;+ }++ // Handle button click to toggle dropdown+ button.addEventListener('click', function(event) {+ event.preventDefault();+ event.stopPropagation();++ var shouldShow = !isDropdownVisible(dropdown);++ // Close other dropdowns first+ closeAllDropdowns(dropdown);++ // Toggle this dropdown+ toggleDropdown(dropdown, button, shouldShow);+ });+ });++ // Close dropdowns when clicking outside+ document.addEventListener('click', function(event) {+ var target = event.target;++ // Check if click is inside any dropdown or toggle button+ var clickedInsideDropdown = target.closest('[data-dropdown-toggle], [id$="-dropdown"]');++ if (!clickedInsideDropdown) {+ closeAllDropdowns(null);+ }+ });++ // Close dropdowns when pressing Escape key+ document.addEventListener('keydown', function(event) {+ if (event.key === 'Escape') {+ closeAllDropdowns(null);+ }+ });+ });+ })();</script>diff --git a/packages/app/views/pages/partials/studio/top-user-menu.ejs b/packages/app/views/pages/partials/studio/top-user-menu.ejsindex 2b911c8a..a44853fd 100644--- a/packages/app/views/pages/partials/studio/top-user-menu.ejs+++ b/packages/app/views/pages/partials/studio/top-user-menu.ejs@@ -1,9 +1,10 @@<div class="relative"><buttontype="button"- class="flex text-sm rounded-full"+ class="flex text-sm rounded-full ring-2 ring-transparent hover:ring-gray-200 focus:ring-primary-100 transition-all duration-150 cursor-pointer"id="user-menu-button"aria-expanded="false"+ aria-haspopup="true"data-dropdown-toggle="<%= dropdownId %>"data-dropdown-placement="bottom">@@ -25,8 +26,10 @@</button><div- class="hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow"+ class="hidden absolute right-0 z-50 mt-2 w-48 text-base text-left list-none bg-white divide-y divide-gray-100 rounded-lg shadow-lg border border-gray-100"id="<%= dropdownId %>"+ role="menu"+ aria-labelledby="user-menu-button"><div class="px-4 pt-3 pb-1"><span class="block text-sm text-gray-900"><%= user?.name %></span>