ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountRolesWidget.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_ACCOUNT_ROLES_WIDGET_HPP
21#define ORES_QT_ACCOUNT_ROLES_WIDGET_HPP
22
23#include <QWidget>
24#include <QListWidget>
25#include <QToolButton>
26#include <QGroupBox>
27#include <vector>
28#include <functional>
29#include <boost/uuid/uuid.hpp>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.iam/domain/role.hpp"
33
34namespace ores::qt {
35
42class AccountRolesWidget : public QWidget {
43 Q_OBJECT
44
45private:
46 inline static std::string_view logger_name =
47 "ores.qt.account_roles_widget";
48
49 [[nodiscard]] static auto& lg() {
50 using namespace ores::logging;
51 static auto instance = make_logger(logger_name);
52 return instance;
53 }
54
55public:
56 explicit AccountRolesWidget(QWidget* parent = nullptr);
57 ~AccountRolesWidget() override = default;
58
62 void setClientManager(ClientManager* clientManager);
63
67 void setAccountId(const boost::uuids::uuid& accountId);
68
72 void loadRoles();
73
77 void setReadOnly(bool readOnly);
78
82 std::vector<boost::uuids::uuid> getAssignedRoleIds() const;
83
84signals:
85 void statusMessage(const QString& message);
86 void errorMessage(const QString& message);
87 void rolesChanged();
88
89private slots:
90 void onAssignRoleClicked();
91 void onRevokeRoleClicked();
92 void onRoleSelectionChanged();
93
94private:
95 void updateButtonStates();
96 void refreshRolesList();
97
106 void executeRoleOperation(
107 std::function<std::pair<bool, std::string>()> requestFunc,
108 const std::string& roleName,
109 const QString& successMessage,
110 const QString& errorTitle);
111
112private:
113 QGroupBox* groupBox_;
114 QListWidget* rolesList_;
115 QToolButton* assignButton_;
116 QToolButton* revokeButton_;
117
118 ClientManager* clientManager_;
119 boost::uuids::uuid accountId_;
120 std::vector<iam::domain::role> assignedRoles_;
121 std::vector<iam::domain::role> allRoles_;
122 bool isReadOnly_{false};
123};
124
125}
126
127#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Widget for managing roles assigned to an account.
Definition AccountRolesWidget.hpp:42
void loadRoles()
Loads the roles for the current account.
Definition AccountRolesWidget.cpp:95
void setClientManager(ClientManager *clientManager)
Sets the client manager for making requests.
Definition AccountRolesWidget.cpp:87
std::vector< boost::uuids::uuid > getAssignedRoleIds() const
Gets the currently assigned role IDs.
Definition AccountRolesWidget.cpp:184
void setAccountId(const boost::uuids::uuid &accountId)
Sets the account ID to manage roles for.
Definition AccountRolesWidget.cpp:91
void setReadOnly(bool readOnly)
Sets the widget to read-only mode.
Definition AccountRolesWidget.cpp:179
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90