Skip to content

Commit

Permalink
fixed struts message and save persist store
Browse files Browse the repository at this point in the history
  • Loading branch information
avneesh-akto committed Dec 13, 2024
1 parent f2a3cfc commit fc400cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public String editCollectionName() {
}

if (apiCollection.getHostName() != null) {
String errorMessage = "Traffic API collection can't edited";
String errorMessage = "Unable to modify the Traffic API collection";
addActionError(errorMessage);
return Action.ERROR.toUpperCase();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7389,7 +7389,7 @@
<interceptor-ref name="roleAccessInterceptor">
<param name="featureLabel">API_COLLECTIONS</param>
<param name="accessType">READ_WRITE</param>
<param name="actionDescription">User created an empty collection</param>
<param name="actionDescription">User edited collection name</param>
</interceptor-ref>
<result name="FORBIDDEN" type="json">
<param name="statusCode">403</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function ApiEndpoints(props) {
const setShowDetails = ObserveStore(state => state.setInventoryFlyout)
const collectionsMap = PersistStore(state => state.collectionsMap)
const allCollections = PersistStore(state => state.allCollections);
const setCollectionsMap = PersistStore(state => state.setCollectionsMap)
const setAllCollections = PersistStore(state => state.setAllCollections)

const [ pageTitle, setPageTitle] = useState(collectionsMap[apiCollectionId])
const [apiEndpoints, setApiEndpoints] = useState([])
Expand Down Expand Up @@ -907,12 +909,24 @@ function ApiEndpoints(props) {
)
]

function updateCollectionName(list, apiCollectionId, newName) {
list.forEach(item => {
if (item.id === apiCollectionId) {
item.displayName = newName;
item.name = newName;
}
});
}


const handleSaveClick = async () => {
api.editCollectionName(apiCollectionId, editableTitle).then((resp) => {
func.setToast(true, false, 'Collection name updated successfully!')
setPageTitle(editableTitle)
collectionsMap[apiCollectionId] = editableTitle
setCollectionsMap(collectionsMap)
updateCollectionName(allCollections, parseInt(apiCollectionId, 10), editableTitle)
setAllCollections(allCollections)
setIsEditing(false);
}).catch((err) => {
setEditableTitle(pageTitle)
Expand Down

0 comments on commit fc400cf

Please sign in to comment.