Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdminUI: Redesign of dialogs #717

Merged
merged 34 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7ce90a7
chore: redesign of dialogs
stamenione Jun 26, 2024
1e6ef57
fix: add trailing comma
stamenione Jun 26, 2024
65c2b4c
chore: rename buttons and title
stamenione Jun 26, 2024
0dee658
fix: add trailing comma
stamenione Jun 26, 2024
558233e
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jun 26, 2024
6e8a29f
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jun 26, 2024
464a39f
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jun 27, 2024
3243000
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jun 27, 2024
f8508fb
chore: add more dialog redesign
stamenione Jul 1, 2024
e70ec08
Merge branch 'NMSHDB-153-Redesign-dialogs' of https://github.com/nmsh…
stamenione Jul 1, 2024
a9b9764
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 1, 2024
179e01a
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 1, 2024
30aee6c
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 1, 2024
cb3dbe6
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 1, 2024
2fc49f9
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 2, 2024
0693142
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 2, 2024
da93117
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 2, 2024
53ec912
fix: add trailing comma
stamenione Jul 3, 2024
7344969
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
stamenione Jul 3, 2024
7411bec
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 3, 2024
8aed876
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 5, 2024
c48a700
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 5, 2024
2b5b494
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 5, 2024
d5c8c7f
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 8, 2024
806b01a
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
stamenione Jul 8, 2024
738c969
chore: add required into the dialogs
stamenione Jul 9, 2024
514988f
chore: swap the field places
stamenione Jul 9, 2024
d295644
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 9, 2024
0b183af
fix: remove duplicate create
stamenione Jul 10, 2024
d709b3e
refactor: code
stamenione Jul 10, 2024
1b73b99
fix: use contentPadding to wrap content instead of Padding
stamenione Jul 10, 2024
e1e7398
chore: add remove to translations
stamenione Jul 10, 2024
ddbcbf2
chore: use the default values except for bottom
stamenione Jul 10, 2024
449e78b
Merge branch 'main' into NMSHDB-153-Redesign-dialogs
mergify[bot] Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Future<void> showAddQuotaDialog({

await showDialog<void>(
context: context,
builder: (BuildContext context) => _AddQuotaDialog(
builder: (BuildContext context) => _AssignQuotaDialog(
availableMetrics: metrics.data,
addQuota: ({required String metricKey, required int max, required String period}) {
if (tierId != null) {
Expand All @@ -36,22 +36,22 @@ Future<void> showAddQuotaDialog({
);
}

class _AddQuotaDialog extends StatefulWidget {
class _AssignQuotaDialog extends StatefulWidget {
final List<Metric> availableMetrics;
final Future<ApiResponse<dynamic>> Function({required String metricKey, required int max, required String period}) addQuota;
final VoidCallback onQuotaAdded;

const _AddQuotaDialog({
const _AssignQuotaDialog({
required this.availableMetrics,
required this.addQuota,
required this.onQuotaAdded,
});

@override
State<_AddQuotaDialog> createState() => _AddQuotaDialogState();
State<_AssignQuotaDialog> createState() => _AssignQuotaDialogState();
}

class _AddQuotaDialogState extends State<_AddQuotaDialog> {
class _AssignQuotaDialogState extends State<_AssignQuotaDialog> {
final _maxAmountController = TextEditingController();

bool _saving = false;
Expand Down Expand Up @@ -82,58 +82,65 @@ class _AddQuotaDialogState extends State<_AddQuotaDialog> {
return PopScope(
canPop: !_saving,
child: AlertDialog(
title: Text(context.l10n.addQuota),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
title: Text(context.l10n.addQuota, textAlign: TextAlign.center),
content: SizedBox(
width: 500,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField(
value: _selectedMetric,
items: widget.availableMetrics.map((metric) => DropdownMenuItem(value: metric.key, child: Text(metric.displayName))).toList(),
onChanged: _saving ? null : (String? selected) => setState(() => _selectedMetric = selected),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.metric}*',
child: Padding(
padding: const EdgeInsets.only(bottom: 32),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8),
child: Text('*${context.l10n.required}'),
),
),
Gaps.h24,
TextField(
controller: _maxAmountController,
enabled: !_saving,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.maxAmount}*',
helperText: context.l10n.addQuotaDialog_maxAmount_message,
Gaps.h32,
DropdownButtonFormField(
value: _selectedMetric,
items: widget.availableMetrics.map((metric) => DropdownMenuItem(value: metric.key, child: Text(metric.displayName))).toList(),
onChanged: _saving ? null : (String? selected) => setState(() => _selectedMetric = selected),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.metric}*',
),
),
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number,
),
Gaps.h24,
DropdownButtonFormField(
value: _selectedPeriod,
items: [
DropdownMenuItem(value: 'Hour', child: Text(context.l10n.hour)),
DropdownMenuItem(value: 'Day', child: Text(context.l10n.day)),
DropdownMenuItem(value: 'Week', child: Text(context.l10n.week)),
DropdownMenuItem(value: 'Month', child: Text(context.l10n.month)),
DropdownMenuItem(value: 'Year', child: Text(context.l10n.year)),
],
onChanged: _saving ? null : (String? selected) => setState(() => _selectedPeriod = selected),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.period}*',
Gaps.h24,
TextField(
controller: _maxAmountController,
enabled: !_saving,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.maxAmount}*',
helperText: context.l10n.addQuotaDialog_maxAmount_message,
),
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number,
),
),
if (_errorMessage != null)
Padding(
padding: const EdgeInsets.only(top: 24),
child: Text(
_errorMessage!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
Gaps.h24,
DropdownButtonFormField(
value: _selectedPeriod,
items: [
DropdownMenuItem(value: 'Hour', child: Text(context.l10n.hour)),
DropdownMenuItem(value: 'Day', child: Text(context.l10n.day)),
DropdownMenuItem(value: 'Week', child: Text(context.l10n.week)),
DropdownMenuItem(value: 'Month', child: Text(context.l10n.month)),
DropdownMenuItem(value: 'Year', child: Text(context.l10n.year)),
],
onChanged: _saving ? null : (String? selected) => setState(() => _selectedPeriod = selected),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: '${context.l10n.period}*',
),
),
],
if (_errorMessage != null)
Padding(
padding: const EdgeInsets.only(top: 24),
child: Text(_errorMessage!, style: TextStyle(color: Theme.of(context).colorScheme.error)),
),
],
),
),
),
actions: [
Expand All @@ -143,7 +150,7 @@ class _AddQuotaDialogState extends State<_AddQuotaDialog> {
),
FilledButton(
onPressed: _isValid && !_saving ? _addQuota : null,
child: Text(context.l10n.add),
child: Text(context.l10n.assign),
),
],
),
Expand Down
10 changes: 7 additions & 3 deletions AdminUi/apps/admin_ui/lib/core/modals/confirmation_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ class _ConfirmationDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(title),
content: Text(message),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
title: Text(title, textAlign: TextAlign.center),
content: Padding(
padding: const EdgeInsets.only(bottom: 32, top: 32),
child: Text(message),
),
actions: [
OutlinedButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text(context.l10n.cancel),
),
FilledButton(
onPressed: () => Navigator.of(context).pop(true),
child: Text(context.l10n.confirm),
child: const Text('Remove'),
stamenione marked this conversation as resolved.
Show resolved Hide resolved
),
],
);
Expand Down
2 changes: 1 addition & 1 deletion AdminUi/apps/admin_ui/lib/core/modals/modals.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export 'add_quota_dialog.dart';
export 'assign_quota_dialog.dart';
export 'confirmation_dialog.dart';
export 'settings_dialog.dart';
41 changes: 23 additions & 18 deletions AdminUi/apps/admin_ui/lib/core/modals/settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,29 @@ class _SettingsDialog extends StatelessWidget with WatchItMixin {
final themeMode = watchValue((ThemeModeModel x) => x.themeMode);

return AlertDialog(
title: Text(context.l10n.settings),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.l10n.theme, style: Theme.of(context).textTheme.bodyLarge),
Gaps.h4,
SegmentedButton(
showSelectedIcon: false,
segments: [
ButtonSegment(value: ThemeMode.light, icon: const Icon(Icons.light_mode), label: Text(context.l10n.light)),
ButtonSegment(value: ThemeMode.system, icon: const Icon(Icons.settings), label: Text(context.l10n.system)),
ButtonSegment(value: ThemeMode.dark, icon: const Icon(Icons.dark_mode), label: Text(context.l10n.dark)),
],
selected: {themeMode},
onSelectionChanged: (selected) => GetIt.I<ThemeModeModel>().setThemeMode(selected.first),
),
],
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
title: Text(context.l10n.settings, textAlign: TextAlign.center),
content: Padding(
padding: const EdgeInsets.only(bottom: 32),
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Gaps.h8,
stamenione marked this conversation as resolved.
Show resolved Hide resolved
Text(context.l10n.theme, style: Theme.of(context).textTheme.bodyLarge),
Gaps.h4,
SegmentedButton(
showSelectedIcon: false,
segments: [
ButtonSegment(value: ThemeMode.light, icon: const Icon(Icons.light_mode), label: Text(context.l10n.light)),
ButtonSegment(value: ThemeMode.system, icon: const Icon(Icons.settings), label: Text(context.l10n.system)),
ButtonSegment(value: ThemeMode.dark, icon: const Icon(Icons.dark_mode), label: Text(context.l10n.dark)),
],
selected: {themeMode},
onSelectionChanged: (selected) => GetIt.I<ThemeModeModel>().setThemeMode(selected.first),
),
],
),
),
actions: [FilledButton(onPressed: () => context.pop(), child: Text(context.l10n.close))],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,58 +55,62 @@ class _ChangeClientSecretDialogState extends State<_ChangeClientSecretDialog> {
return PopScope(
canPop: !_saving,
child: AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
title: Text(context.l10n.changeClientSecret, textAlign: TextAlign.center),
content: SizedBox(
width: 500,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: _newClientSecretController,
focusNode: _focusNode,
readOnly: _saveSucceeded,
obscureText: _isClientSecretVisible,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: context.l10n.clientSecret,
helperText: context.l10n.clientSecret_message,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(_isClientSecretVisible ? Icons.visibility_off : Icons.visibility),
onPressed: () => setState(() => _isClientSecretVisible = !_isClientSecretVisible),
),
Gaps.w4,
CopyToClipboardButton(
tooltip: context.l10n.changeClientSecretDialog_copyToClipboard,
clipboardText: _newClientSecretController.text,
successMessage: context.l10n.clientSecret_copiedToClipboard,
),
],
child: Padding(
padding: const EdgeInsets.only(bottom: 32, top: 32),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: _newClientSecretController,
focusNode: _focusNode,
readOnly: _saveSucceeded,
obscureText: _isClientSecretVisible,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: context.l10n.clientSecret,
helperText: context.l10n.clientSecret_message,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(_isClientSecretVisible ? Icons.visibility_off : Icons.visibility),
onPressed: () => setState(() => _isClientSecretVisible = !_isClientSecretVisible),
),
Gaps.w4,
CopyToClipboardButton(
tooltip: context.l10n.changeClientSecretDialog_copyToClipboard,
clipboardText: _newClientSecretController.text,
successMessage: context.l10n.clientSecret_copiedToClipboard,
),
],
),
),
),
),
),
if (_saveSucceeded)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
context.l10n.clientSecret_save_message,
style: TextStyle(color: Theme.of(context).colorScheme.primary),
if (_saveSucceeded)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
context.l10n.clientSecret_save_message,
style: TextStyle(color: Theme.of(context).colorScheme.primary),
),
),
),
if (_errorMessage != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
_errorMessage!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
if (_errorMessage != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
_errorMessage!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
),
),
],
],
),
),
),
actions: [
Expand Down
Loading
Loading