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 <QComboBox>
25#include <QListWidget>
26#include <QToolButton>
27#include <QGroupBox>
28#include <vector>
29#include <boost/uuid/uuid.hpp>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.iam.api/domain/role.hpp"
33
34namespace ores::qt {
35
41class AccountRolesWidget : public QWidget {
42 Q_OBJECT
43
44private:
45 inline static std::string_view logger_name =
46 "ores.qt.account_roles_widget";
47
48 [[nodiscard]] static auto& lg() {
49 using namespace ores::logging;
50 static auto instance = make_logger(logger_name);
51 return instance;
52 }
53
54public:
55 explicit AccountRolesWidget(QWidget* parent = nullptr);
56 ~AccountRolesWidget() override = default;
57
58 void setClientManager(ClientManager* clientManager);
59 void setAccountId(const boost::uuids::uuid& accountId);
60
65 void load();
66
67 void setReadOnly(bool readOnly);
68
69 [[nodiscard]] bool hasPendingChanges() const;
70 [[nodiscard]] const std::vector<boost::uuids::uuid>& pendingAdds() const;
71 [[nodiscard]] const std::vector<boost::uuids::uuid>& pendingRemoves() const;
72
73signals:
74 void statusMessage(const QString& message);
75 void errorMessage(const QString& message);
76 void roleListChanged();
77
78private slots:
79 void onAssignRoleClicked();
80 void onRevokeRoleClicked();
81 void onRoleSelectionChanged();
82
83private:
84 void setupUi();
85 void updateButtonStates();
86 void refreshRolesList();
87
88 QGroupBox* groupBox_;
89 QListWidget* rolesList_;
90 QComboBox* roleCombo_;
91 QToolButton* assignButton_;
92 QToolButton* revokeButton_;
93
94 ClientManager* clientManager_ = nullptr;
95 boost::uuids::uuid accountId_;
96 bool isReadOnly_{false};
97
98 std::vector<iam::domain::role> assignedRoles_;
99 std::vector<iam::domain::role> allRoles_;
100 std::vector<boost::uuids::uuid> pendingAdds_;
101 std::vector<boost::uuids::uuid> pendingRemoves_;
102};
103
104}
105
106#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Widget for managing roles assigned to an account.
Definition AccountRolesWidget.hpp:41
void load()
Load roles. If accountId is set, also fetches assigned roles. If accountId is nil (create mode),...
Definition AccountRolesWidget.cpp:112
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109