mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-17 01:09:36 -06:00
dbhub: Allow pushing to other user accounts to which you have access
This adds a new row to the Push dialog in which you can set the user name in case you want to push to a different account.
This commit is contained in:
@@ -379,7 +379,7 @@ void RemoteDock::pushDatabase(const QString& path, const QString& branch)
|
||||
|
||||
// Build push URL
|
||||
QString url = host;
|
||||
url.append(RemoteNetwork::get().getInfoFromClientCert(remoteModel->currentClientCertificate(), RemoteNetwork::CertInfoUser));
|
||||
url.append(pushDialog.user());
|
||||
url.append("/");
|
||||
url.append(pushDialog.name());
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ void RemoteNetwork::prepareProgressDialog(QNetworkReply* reply, bool upload, con
|
||||
}
|
||||
|
||||
void RemoteNetwork::fetch(const QUrl& url, RequestType type, const QString& clientCert,
|
||||
std::function<void(QByteArray)> when_finished, bool synchronous)
|
||||
std::function<void(QByteArray)> when_finished, bool synchronous, bool ignore_errors)
|
||||
{
|
||||
// Check if network is accessible. If not, abort right here
|
||||
if(m_manager->networkAccessible() == QNetworkAccessManager::NotAccessible)
|
||||
@@ -416,6 +416,7 @@ void RemoteNetwork::fetch(const QUrl& url, RequestType type, const QString& clie
|
||||
QNetworkReply* reply = m_manager->get(request);
|
||||
reply->setProperty("type", type);
|
||||
reply->setProperty("certfile", clientCert);
|
||||
reply->setProperty("ignore_errors", ignore_errors);
|
||||
|
||||
// Hook up custom handler when there is one and global handler otherwise
|
||||
if(when_finished)
|
||||
@@ -556,7 +557,7 @@ bool RemoteNetwork::handleReply(QNetworkReply* reply)
|
||||
if(reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
// Do not show error message when operation was cancelled on purpose
|
||||
if(reply->error() != QNetworkReply::OperationCanceledError)
|
||||
if(reply->error() != QNetworkReply::OperationCanceledError && !reply->property("ignore_errors").toBool())
|
||||
{
|
||||
QMessageBox::warning(nullptr, qApp->applicationName(),
|
||||
reply->errorString() + "\n" + reply->readAll());
|
||||
|
||||
@@ -46,7 +46,8 @@ public:
|
||||
RequestTypeDownload,
|
||||
};
|
||||
|
||||
void fetch(const QUrl& url, RequestType type, const QString& clientCert = QString(), std::function<void(QByteArray)> when_finished = {}, bool synchronous = false);
|
||||
void fetch(const QUrl& url, RequestType type, const QString& clientCert = QString(),
|
||||
std::function<void(QByteArray)> when_finished = {}, bool synchronous = false, bool ignore_errors = false);
|
||||
void push(const QString& filename, const QUrl& url, const QString& clientCert, const QString& remotename,
|
||||
const QString& commitMessage = QString(), const QString& licence = QString(), bool isPublic = false,
|
||||
const QString& branch = QString("master"), bool forcePush = false, const QString& last_commit = QString());
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
using json = nlohmann::json;
|
||||
|
||||
RemotePushDialog::RemotePushDialog(QWidget* parent, const QString& host, const QString& clientCert,
|
||||
const QString& name, const QString& branch) :
|
||||
const QString& name, const QString& branch, const QString& user) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::RemotePushDialog),
|
||||
m_host(host),
|
||||
@@ -23,10 +23,16 @@ RemotePushDialog::RemotePushDialog(QWidget* parent, const QString& host, const Q
|
||||
ui->setupUi(this);
|
||||
ui->editName->setValidator(m_nameValidator);
|
||||
ui->comboBranch->setValidator(m_branchValidator);
|
||||
ui->comboUser->setValidator(m_nameValidator);
|
||||
|
||||
// Set start values
|
||||
ui->editName->setText(name);
|
||||
|
||||
// Fill in usernames
|
||||
ui->comboUser->addItem(RemoteNetwork::get().getInfoFromClientCert(m_clientCert, RemoteNetwork::CertInfoUser));
|
||||
if(!user.isEmpty())
|
||||
ui->comboUser->addItem(user);
|
||||
|
||||
// Enable/disable accept button
|
||||
checkInput();
|
||||
|
||||
@@ -85,6 +91,9 @@ void RemotePushDialog::checkInput()
|
||||
if(ui->comboBranch->currentText().size() < 1 || ui->comboBranch->currentText().size() > 32)
|
||||
valid = false;
|
||||
|
||||
if(ui->comboUser->currentText().trimmed().isEmpty())
|
||||
valid = false;
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
|
||||
}
|
||||
|
||||
@@ -118,6 +127,11 @@ QString RemotePushDialog::branch() const
|
||||
return ui->comboBranch->currentText();
|
||||
}
|
||||
|
||||
QString RemotePushDialog::user() const
|
||||
{
|
||||
return ui->comboUser->currentText();
|
||||
}
|
||||
|
||||
bool RemotePushDialog::forcePush() const
|
||||
{
|
||||
return ui->checkForce->isChecked();
|
||||
@@ -127,7 +141,7 @@ void RemotePushDialog::reloadBranchList(const QString& select_branch)
|
||||
{
|
||||
QUrl url(m_host + "branch/list");
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("username", RemoteNetwork::get().getInfoFromClientCert(m_clientCert, RemoteNetwork::CertInfoUser));
|
||||
query.addQueryItem("username", ui->comboUser->currentText());
|
||||
query.addQueryItem("folder", "/");
|
||||
query.addQueryItem("dbname", ui->editName->text());
|
||||
url.setQuery(query);
|
||||
@@ -156,5 +170,5 @@ void RemotePushDialog::reloadBranchList(const QString& select_branch)
|
||||
// If a branch was suggested, select it now
|
||||
if(!select_branch.isEmpty())
|
||||
ui->comboBranch->setCurrentIndex(ui->comboBranch->findText(select_branch));
|
||||
});
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class RemotePushDialog : public QDialog
|
||||
|
||||
public:
|
||||
explicit RemotePushDialog(QWidget* parent, const QString& host, const QString& clientCert,
|
||||
const QString& name = QString(), const QString& branch = QString());
|
||||
const QString& name = QString(), const QString& branch = QString(), const QString& user = QString());
|
||||
~RemotePushDialog() override;
|
||||
|
||||
QString name() const;
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
QString licence() const;
|
||||
bool isPublic() const;
|
||||
QString branch() const;
|
||||
QString user() const;
|
||||
bool forcePush() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>583</width>
|
||||
<height>300</height>
|
||||
<height>315</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -49,8 +49,8 @@
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Oxygen-Sans';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
@@ -110,7 +110,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Force push</string>
|
||||
@@ -120,9 +120,26 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="checkForce"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboUser</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="comboUser">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -143,6 +160,8 @@ p, li { white-space: pre-wrap; }
|
||||
<tabstop>comboBranch</tabstop>
|
||||
<tabstop>checkPublic</tabstop>
|
||||
<tabstop>comboLicence</tabstop>
|
||||
<tabstop>comboUser</tabstop>
|
||||
<tabstop>checkForce</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
@@ -153,8 +172,8 @@ p, li { white-space: pre-wrap; }
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>257</x>
|
||||
<y>305</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
@@ -169,8 +188,8 @@ p, li { white-space: pre-wrap; }
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>325</x>
|
||||
<y>305</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
@@ -201,8 +220,8 @@ p, li { white-space: pre-wrap; }
|
||||
<slot>checkInput()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>171</x>
|
||||
<y>176</y>
|
||||
<x>345</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>210</x>
|
||||
@@ -249,8 +268,8 @@ p, li { white-space: pre-wrap; }
|
||||
<slot>checkInput()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>172</x>
|
||||
<y>138</y>
|
||||
<x>346</x>
|
||||
<y>160</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>33</x>
|
||||
@@ -265,8 +284,8 @@ p, li { white-space: pre-wrap; }
|
||||
<slot>checkInput()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>168</x>
|
||||
<y>240</y>
|
||||
<x>342</x>
|
||||
<y>269</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>62</x>
|
||||
@@ -274,6 +293,38 @@ p, li { white-space: pre-wrap; }
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>comboUser</sender>
|
||||
<signal>currentTextChanged(QString)</signal>
|
||||
<receiver>RemotePushDialog</receiver>
|
||||
<slot>reloadBranchList()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>373</x>
|
||||
<y>235</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>291</x>
|
||||
<y>157</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>comboUser</sender>
|
||||
<signal>currentTextChanged(QString)</signal>
|
||||
<receiver>RemotePushDialog</receiver>
|
||||
<slot>checkInput()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>373</x>
|
||||
<y>235</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>291</x>
|
||||
<y>157</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>checkInput()</slot>
|
||||
|
||||
Reference in New Issue
Block a user