dbhub: Add toolbar action for fetching the latest commit

This adds a new toolbar action to the Current Database tab of the Remote
dock which downloads and updates to the latest commit of the currently
opened database and branch.
This commit is contained in:
Martin Kleusberg
2020-07-23 13:22:50 +02:00
parent e51aa2eebe
commit 2e9580365b
2 changed files with 31 additions and 3 deletions
+16 -1
View File
@@ -72,6 +72,20 @@ RemoteDock::RemoteDock(MainWindow* parent)
ui->treeDatabaseCommits->expandAll();
});
// Fetch latest commit action
connect(ui->actionFetchLatestCommit, &QAction::triggered, [this]() {
// Fetch last commit of current branch
// The URL and the branch name is that of the currently opened database file.
// The latest commit id is stored in the data bits of the branch combo box.
QUrl url(QString::fromStdString(currently_opened_file_info.url));
QUrlQuery query;
query.addQueryItem("branch", QString::fromStdString(currently_opened_file_info.branch));
query.addQueryItem("commit", ui->comboDatabaseBranch->itemData(
ui->comboDatabaseBranch->findText(QString::fromStdString(currently_opened_file_info.branch))).toString());
url.setQuery(query);
fetchDatabase(url.toString());
});
// Prepare context menu for list of remote databases
connect(ui->treeRemote->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex& index, const QModelIndex&) {
// Only enable database actions when a database was selected
@@ -244,9 +258,10 @@ void RemoteDock::enableButtons()
bool logged_in = !remoteModel->currentClientCertificate().isEmpty();
ui->buttonPushDatabase->setEnabled(db_opened && logged_in);
ui->actionRefresh->setEnabled(logged_in);
ui->actionCloneDatabaseLink->setEnabled(logged_in);
ui->actionDatabaseOpenBrowser->setEnabled(db_opened && logged_in);
ui->actionRefresh->setEnabled(logged_in);
ui->actionFetchLatestCommit->setEnabled(db_opened && logged_in);
}
void RemoteDock::pushDatabase()
+15 -2
View File
@@ -126,8 +126,8 @@
<property name="floatable">
<bool>false</bool>
</property>
<addaction name="actionCloneDatabaseLink"/>
<addaction name="actionRefresh"/>
<addaction name="actionCloneDatabaseLink"/>
</widget>
</item>
<item>
@@ -193,8 +193,9 @@
<property name="floatable">
<bool>false</bool>
</property>
<addaction name="actionDatabaseOpenBrowser"/>
<addaction name="actionRefresh"/>
<addaction name="actionDatabaseOpenBrowser"/>
<addaction name="actionFetchLatestCommit"/>
</widget>
</item>
<item>
@@ -502,6 +503,18 @@
</font>
</property>
</action>
<action name="actionFetchLatestCommit">
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/db_revert</normaloff>:/icons/db_revert</iconset>
</property>
<property name="text">
<string>Check out Latest Commit</string>
</property>
<property name="toolTip">
<string>Check out the latest commit of the current branch</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>comboUser</tabstop>