WIP: Don't allow to edit downloaded packages.

This commit is contained in:
Matthias Koefferlein 2017-04-22 21:56:37 +02:00
parent 42756a76f6
commit 1f92b89e16
2 changed files with 7 additions and 2 deletions

View File

@ -337,7 +337,9 @@ SaltGrain::xml_struct ()
bool
SaltGrain::is_readonly () const
{
return !QFileInfo (tl::to_qstring (path ())).isWritable ();
// A grain is readonly if the directory is not writable or there is a download URL
// (this means the grain has been installed from an URL).
return !QFileInfo (tl::to_qstring (path ())).isWritable () || !m_url.empty ();
}
void

View File

@ -512,7 +512,10 @@ SaltManagerDialog::edit_properties ()
{
SaltGrain *g = current_grain ();
if (g) {
if (mp_properties_dialog->exec_dialog (g, mp_salt)) {
if (g->is_readonly ()) {
QMessageBox::critical (this, tr ("Package is not Editable"),
tr ("This package cannot be edited.\n\nEither you don't have write permissions on the directory or the package was installed from a repository."));
} else if (mp_properties_dialog->exec_dialog (g, mp_salt)) {
current_changed ();
}
}