Skip to content

Commit

Permalink
Updates related to keyspaces actions in the treeview, ticket #547 (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdkrmabd authored Nov 25, 2024
1 parent d1a4d7a commit e8527dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 32 additions & 1 deletion renderer/js/events/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@
}]

try {
if (nodeType != 'cluster' && nodeType != 'keyspace')
if (['cluster'].every((type) => nodeType != type))
throw 0

contextMenu = contextMenu.concat([{
Expand Down Expand Up @@ -2013,6 +2013,12 @@
throw 0

contextMenu = contextMenu.concat([{
type: 'separator'
},
{
label: I18next.capitalizeFirstLetter(I18next.t('actions')),
enabled: false
}, {
label: I18next.capitalizeFirstLetter(I18next.t('alter keyspace')),
action: 'alter',
click: `() => views.main.webContents.send('alter-keyspace', {
Expand All @@ -2037,6 +2043,27 @@
contextMenu = contextMenu.filter((item) => item.action != 'drop')
} catch (e) {}

try {
if (nodeType != 'keyspaces')
throw 0

contextMenu = [{
label: I18next.capitalizeFirstLetter(I18next.t('actions')),
enabled: false
},
{
label: I18next.capitalizeFirstLetter(I18next.t('create keyspace')),
action: 'create',
click: `() => views.main.webContents.send('create-keyspace', {
datacenters: '${getAttributes(clusterElement, 'data-datacenters')}',
tabID: '_${cqlshSessionContentID}',
textareaID: '_${cqlshSessionStatementInputID}',
btnID: '_${executeStatementBtnID}'
})`
}
]
} catch (e) {}

// Send a request to the main thread regards pop-up a menu
IPCRenderer.send('show-context-menu', JSON.stringify(contextMenu))
})
Expand Down Expand Up @@ -5657,6 +5684,10 @@
clusterElement.attr('data-latest-cassandra-version', `${status.version}`)
} catch (e) {}

try {
clusterElement.attr('data-datacenters', `${JSON.stringify(status.datacenters)}`)
} catch (e) {}

// If the process has been terminated then skip the upcoming code and stop the process
if (status.terminated || isTerminated) {
// Update the associated flag
Expand Down
4 changes: 4 additions & 0 deletions renderer/js/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@ let buildTreeview = (metadata, ignoreTitles = false) => {
'text': `Keyspaces (<span>${metadata.keyspaces.length}</span>)`,
'type': 'default',
'icon': normalizePath(Path.join(extraIconsPath, 'keyspaces.png')),
'a_attr': {
'allow-right-context': 'true',
'type': 'keyspaces'
}
}
]
},
Expand Down

0 comments on commit e8527dd

Please sign in to comment.