MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / handlePermissionChange

Function handlePermissionChange

packages/ui/src/views/apikey/APIKeyDialog.jsx:141–177  ·  view source on GitHub ↗
(category, key)

Source from the content-addressed store, hash-verified

139 }
140
141 const handlePermissionChange = (category, key) => {
142 setSelectedPermissions((prevPermissions) => {
143 const updatedCategoryPermissions = {
144 ...prevPermissions[category],
145 [key]: !prevPermissions[category]?.[key]
146 }
147
148 if (category === 'templates') {
149 if (key !== 'templates:marketplace' && key !== 'templates:custom') {
150 updatedCategoryPermissions['templates:marketplace'] = true
151 updatedCategoryPermissions['templates:custom'] = true
152 }
153 } else {
154 const viewPermissionKey = `${category}:view`
155 if (key !== viewPermissionKey) {
156 const hasEnabledPermissions = Object.entries(updatedCategoryPermissions).some(
157 ([permissionKey, isEnabled]) => permissionKey !== viewPermissionKey && isEnabled
158 )
159 if (hasEnabledPermissions) {
160 updatedCategoryPermissions[viewPermissionKey] = true
161 }
162 } else {
163 const hasEnabledPermissions = Object.entries(updatedCategoryPermissions).some(
164 ([permissionKey, isEnabled]) => permissionKey === viewPermissionKey && isEnabled
165 )
166 if (hasEnabledPermissions) {
167 updatedCategoryPermissions[key] = true
168 }
169 }
170 }
171
172 return {
173 ...prevPermissions,
174 [category]: updatedCategoryPermissions
175 }
176 })
177 }
178
179 const isCheckboxDisabled = (permissions, category, key) => {
180 if (category === 'templates') {

Callers 1

APIKeyDialogFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected