OnBoarding: Launch the page for adding a deploy key

I'd added BitBucket, but bitbucket sucks as it doesn't have any way to
add an ssh key with write access.

With Gitlab I couldn't link to the exact point in the page, but oh well.
I'll try to file a bug with them.
This commit is contained in:
Vishesh Handa
2019-01-16 18:14:07 +01:00
parent 2876abb05d
commit 1a070b2c41

View File

@ -30,6 +30,8 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
var _pageInputUrlDone = false; var _pageInputUrlDone = false;
var _pageSshKeyDone = false; var _pageSshKeyDone = false;
var _gitCloneUrl = "";
var pageController = PageController(); var pageController = PageController();
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@ -106,6 +108,9 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
); );
SharedPreferences.getInstance().then((SharedPreferences pref) { SharedPreferences.getInstance().then((SharedPreferences pref) {
// We aren't calling setState as this isn't being used for rendering
_gitCloneUrl = sshUrl;
pref.setString("sshCloneUrl", sshUrl); pref.setString("sshCloneUrl", sshUrl);
this._generateSshKey(); this._generateSshKey();
}); });
@ -200,7 +205,6 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
void _generateSshKey() { void _generateSshKey() {
generateSSHKeys(comment: "GitJournal").then((String _publicKey) { generateSSHKeys(comment: "GitJournal").then((String _publicKey) {
setState(() { setState(() {
print("Changing the state");
publicKey = _publicKey; publicKey = _publicKey;
Clipboard.setData(ClipboardData(text: publicKey)); Clipboard.setData(ClipboardData(text: publicKey));
@ -209,9 +213,35 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
._scaffoldKey ._scaffoldKey
.currentState .currentState
.showSnackBar(new SnackBar(content: new Text(text))); .showSnackBar(new SnackBar(content: new Text(text)));
_launchDeployKeyPage();
}); });
}); });
} }
void _launchDeployKeyPage() async {
var lastIndex = _gitCloneUrl.lastIndexOf(".git");
if (lastIndex == -1) {
lastIndex = _gitCloneUrl.length;
}
var repoName =
_gitCloneUrl.substring(_gitCloneUrl.lastIndexOf(":"), lastIndex);
final gitHubUrl = 'https://github.com/' + repoName + '/settings/keys/new';
final gitLabUrl = 'https://gitlab.com/' + repoName + '/settings/repository';
try {
if (_gitCloneUrl.startsWith("git@github.com:")) {
await launch(gitHubUrl);
} else if (_gitCloneUrl.startsWith("git@gitlab.com:")) {
await launch(gitLabUrl);
}
} catch (err, stack) {
print('_launchDeployKeyPage: ' + err.toString());
print(stack.toString());
}
}
} }
class OnBoardingInitialChoice extends StatelessWidget { class OnBoardingInitialChoice extends StatelessWidget {