Add a "this device" hint
This commit is contained in:
parent
861ea5ab50
commit
fbaab3744e
@ -311,8 +311,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
case AuthentikUserSettingsChangeDialogStatus.userSettingsObtained:
|
case AuthentikUserSettingsChangeDialogStatus.userSettingsObtained:
|
||||||
title = Text("User Settings Obtained");
|
title = Text("User Settings Obtained");
|
||||||
children = [Text("You can now edit your user settings.")];
|
children = [Text("You can now edit your user settings.")];
|
||||||
for (var key in authentikApiState.allKeys) {
|
for (var k in authentikApiState.allKeys) {
|
||||||
children.add(KeepOrDeleteKey(sshKey: key));
|
children.add(KeepOrDeleteKey(sshKey: k, isOurKey: k == key));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!authentikApiState.allKeys.contains(key)) {
|
||||||
|
// If the key is not already in the list, add it
|
||||||
|
children.add(KeepOrDeleteKey(sshKey: key, isOurKey: true));
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.add(
|
actions.add(
|
||||||
@ -584,12 +589,21 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
|||||||
|
|
||||||
class KeepOrDeleteKey extends StatelessWidget {
|
class KeepOrDeleteKey extends StatelessWidget {
|
||||||
final String sshKey;
|
final String sshKey;
|
||||||
|
final bool isOurKey;
|
||||||
|
|
||||||
const KeepOrDeleteKey({super.key, required this.sshKey});
|
const KeepOrDeleteKey({
|
||||||
|
super.key,
|
||||||
|
required this.sshKey,
|
||||||
|
this.isOurKey = false,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final key = sshKey;
|
final key = sshKey;
|
||||||
|
final isKeyPreviouslyExisting = context
|
||||||
|
.select<AuthentikUserSettingsChangeDialogState, bool>(
|
||||||
|
(keylist) => keylist.allKeys.contains(key),
|
||||||
|
);
|
||||||
final isKeySelectedToKeep = context
|
final isKeySelectedToKeep = context
|
||||||
.select<AuthentikUserSettingsChangeDialogState, bool>(
|
.select<AuthentikUserSettingsChangeDialogState, bool>(
|
||||||
(keylist) => keylist.isKeySelectedToKeep(key),
|
(keylist) => keylist.isKeySelectedToKeep(key),
|
||||||
@ -622,14 +636,41 @@ class KeepOrDeleteKey extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var textPush = "Keep Key";
|
||||||
|
var textDoNotPush = "Select for Deletion";
|
||||||
|
|
||||||
|
if (!isKeyPreviouslyExisting) {
|
||||||
|
textPush = "Push Key";
|
||||||
|
textDoNotPush = "Do Not Push Key";
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget titleWidget = Text(title, style: TextStyle(fontSize: 25));
|
||||||
|
|
||||||
|
if (isOurKey) {
|
||||||
|
titleWidget = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
titleWidget,
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green,
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(5),
|
||||||
|
child: Text(
|
||||||
|
"This Device",
|
||||||
|
style: TextStyle(fontSize: 15, color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: EdgeInsets.fromLTRB(20, 20, 20, 0),
|
margin: EdgeInsets.fromLTRB(20, 20, 20, 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(padding: EdgeInsets.all(20), child: titleWidget),
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Text(title, style: TextStyle(fontSize: 25)),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
|
padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||||
child: Text(sshKey, style: TextStyle(fontSize: 15)),
|
child: Text(sshKey, style: TextStyle(fontSize: 15)),
|
||||||
@ -644,20 +685,20 @@ class KeepOrDeleteKey extends StatelessWidget {
|
|||||||
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
||||||
context,
|
context,
|
||||||
listen: false,
|
listen: false,
|
||||||
).selectKeyForDeletion(sshKey);
|
).keepKey(sshKey);
|
||||||
},
|
},
|
||||||
style: buttonStyleDelete,
|
style: buttonStyleKeep,
|
||||||
child: Text('Select for Deletion'),
|
child: Text(textPush),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
||||||
context,
|
context,
|
||||||
listen: false,
|
listen: false,
|
||||||
).keepKey(sshKey);
|
).selectKeyForDeletion(sshKey);
|
||||||
},
|
},
|
||||||
style: buttonStyleKeep,
|
style: buttonStyleDelete,
|
||||||
child: Text('Keep Key'),
|
child: Text(textDoNotPush),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user