mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 09:06:43 +08:00
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:
@ -30,6 +30,8 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
|
||||
var _pageInputUrlDone = false;
|
||||
var _pageSshKeyDone = false;
|
||||
|
||||
var _gitCloneUrl = "";
|
||||
|
||||
var pageController = PageController();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
|
||||
@ -106,6 +108,9 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
|
||||
);
|
||||
|
||||
SharedPreferences.getInstance().then((SharedPreferences pref) {
|
||||
// We aren't calling setState as this isn't being used for rendering
|
||||
_gitCloneUrl = sshUrl;
|
||||
|
||||
pref.setString("sshCloneUrl", sshUrl);
|
||||
this._generateSshKey();
|
||||
});
|
||||
@ -200,7 +205,6 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
|
||||
void _generateSshKey() {
|
||||
generateSSHKeys(comment: "GitJournal").then((String _publicKey) {
|
||||
setState(() {
|
||||
print("Changing the state");
|
||||
publicKey = _publicKey;
|
||||
|
||||
Clipboard.setData(ClipboardData(text: publicKey));
|
||||
@ -209,9 +213,35 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
|
||||
._scaffoldKey
|
||||
.currentState
|
||||
.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 {
|
||||
|
Reference in New Issue
Block a user