Skip to content

Commit

Permalink
Merge pull request #1285 from Azanul/onboarding-wizard
Browse files Browse the repository at this point in the history
FIX: Onboarding wizard
  • Loading branch information
mlabouardy authored Jan 8, 2024
2 parents 39db86e + 9ca2703 commit ef29f84
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 8 deletions.
16 changes: 16 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import (
"errors"
"os"
"path/filepath"
"time"

"github.com/getsentry/sentry-go"
Expand Down Expand Up @@ -31,7 +33,21 @@ var startCmd = &cobra.Command{
if file == "" {
return errors.New("you must specify a config file with '--config PATH'")
}
if file == "config.toml" {
filename, err := filepath.Abs(file)
if err != nil {
return err
}

if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
log.Info("unable to use given config file:", err)
log.Info("Creating default config.toml")
err = os.WriteFile("config.toml", []byte{}, 0644)
if err != nil {
return err
}
}
}
regions, err := cmd.Flags().GetStringArray("regions")
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion dashboard/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Layout({ children }: LayoutProps) {
title="We could not find a cloud account"
message="Get Started Onboarding"
action={() => {
router.push('/onboarding/choose-cloud');
router.push('/onboarding/choose-database');
}}
actionLabel="Begin Onboarding"
secondaryAction={() => {
Expand Down
1 change: 1 addition & 0 deletions dashboard/components/onboarding-wizard/LabelledInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function LabelledInput({
}`}
onChange={onChange}
defaultValue={value}
autoComplete="off"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/onboarding/cloud-accounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function CloudAccounts() {
))}
</div>
<div className="fixed bottom-0 -mx-20 flex w-[calc(100%*6/11)] justify-end border-t border-gray-300 bg-white px-20 py-4">
<Button onClick={() => router.push('/onboarding/choose-database')}>
<Button onClick={() => router.push('/onboarding/complete')}>
Next
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/onboarding/database/postgres.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function PostgreSQLCredentials() {
message:
'Your Postgres database has been successfully connected to Komiser.'
});
router.push('/onboarding/complete/');
router.push('/onboarding/choose-cloud/');
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/onboarding/database/sqlite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function SqliteCredentials() {
message:
'Your Postgres database has been successfully connected to Komiser.'
});
router.push('/onboarding/complete/');
router.push('/onboarding/choose-cloud/');
}
});
};
Expand Down
8 changes: 4 additions & 4 deletions handlers/accounts_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/BurntSushi/toml"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/utils"
Expand All @@ -33,15 +32,15 @@ func (handler *ApiHandler) IsOnboardedHandler(c *gin.Context) {
}

if handler.db == nil {
output.Status = "PENDING_ACCOUNTS"
output.Status = "PENDING_DATABASE"
c.JSON(http.StatusOK, output)
return
}

accounts := make([]models.Account, 0)
err := handler.db.NewRaw("SELECT * FROM accounts").Scan(handler.ctx, &accounts)
if err != nil {
logrus.WithError(err).Error("scan failed")
log.WithError(err).Error("scan failed")
c.JSON(http.StatusInternalServerError, gin.H{"error": "scan failed"})
return
}
Expand All @@ -65,7 +64,7 @@ func (handler *ApiHandler) ListCloudAccountsHandler(c *gin.Context) {

err := handler.db.NewRaw("SELECT * FROM accounts").Scan(handler.ctx, &accounts)
if err != nil {
logrus.WithError(err).Error("scan failed")
log.WithError(err).Error("scan failed")
c.JSON(http.StatusInternalServerError, gin.H{"error": "scan failed"})
return
}
Expand Down Expand Up @@ -113,6 +112,7 @@ func (handler *ApiHandler) NewCloudAccountHandler(c *gin.Context) {

accountId, _ := result.LastInsertId()
account.Id = accountId
go fetchResourcesForAccount(c, account, handler.db, []string{})
}

if handler.telemetry {
Expand Down
Loading

0 comments on commit ef29f84

Please sign in to comment.