Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=lf
6 changes: 4 additions & 2 deletions src/Dashboard/Component.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ data Query a = FetchProjects a
type Config =
{ baseUrl :: Gitlab.BaseUrl
, token :: Gitlab.Token
, groupId :: Gitlab.GroupId
, userId :: Gitlab.UserId
}

ui :: Config -> H.Component HH.HTML Query Unit Void Aff
ui { baseUrl, token } =
ui { baseUrl, token, groupId, userId } =
H.component
{ initialState: const initialState
, render
Expand Down Expand Up @@ -68,7 +70,7 @@ ui { baseUrl, token } =
getProjects :: Aff Gitlab.Projects
getProjects = do
log "Fetching list of projects..."
Gitlab.getProjects baseUrl token
Gitlab.getProjects baseUrl token groupId userId

getJobs :: Gitlab.Project -> Aff Gitlab.Jobs
getJobs project@{ id: Gitlab.ProjectId pid } = do
Expand Down
4 changes: 0 additions & 4 deletions src/Dashboard/Model.purs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type CommitRow =
{ branch :: Gitlab.BranchName
, hash :: Gitlab.CommitShortHash
, authorImg :: String
, name :: String
, username :: String
, commitTitle :: String
}

Expand Down Expand Up @@ -59,8 +57,6 @@ makePipelineRow jobs =
, hash: job.commit.short_id
, commitTitle: job.commit.title
, authorImg: job.user.avatar_url
, name: job.user.name
, username: job.user.username
}
}
where
Expand Down
3 changes: 0 additions & 3 deletions src/Dashboard/View.purs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ formatName { id

formatCommit :: ∀ p a. Model.CommitRow -> HTML p a
formatCommit { authorImg
, name
, username
, commitTitle
, hash: Gitlab.CommitShortHash hash
, branch: Gitlab.BranchName branch
Expand All @@ -81,7 +79,6 @@ formatCommit { authorImg
H.div
[ ]
[ authorImage authorImg
, H.text (" " <> name <> " (" <> username <> ")")
, divider
, fontAwesome $ Icon [] CodeFork
, H.b_ [ H.text (" " <> branch) ]
Expand Down
13 changes: 8 additions & 5 deletions src/Gitlab.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import Simple.JSON (class ReadForeign, class WriteForeign, readJSON)

newtype BaseUrl = BaseUrl String
newtype Token = Token String
newtype GroupId = GroupId String
newtype UserId = UserId String

data PipelineStatus
= Running
Expand Down Expand Up @@ -114,8 +116,6 @@ type Project =

type User =
{ avatar_url :: String
, name :: String
, username :: String
}

type Commit =
Expand Down Expand Up @@ -146,10 +146,13 @@ type Projects = Array Project
type Jobs = Array Job


getProjects :: BaseUrl -> Token -> Aff Projects
getProjects (BaseUrl baseUrl) (Token token) = do
getProjects :: BaseUrl -> Token -> GroupId -> UserId -> Aff Projects
getProjects (BaseUrl baseUrl) (Token token) (GroupId groupId) (UserId userId) = do
let url = baseUrl
<> "/api/v4/projects?private_token="
<> "/api/v4"
<> (if (groupId /= "null") then "/groups/" <> groupId else "")
<> (if (userId /= "null") then "/users/" <> userId else "")
<> "/projects?private_token="
<> token
<> "&simple=true&per_page=20&order_by=last_activity_at"
projectsRes <- get json url
Expand Down
4 changes: 3 additions & 1 deletion src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ main :: Effect Unit
main = do
token <- Gitlab.Token <$> URLParams.get "private_token"
baseUrl <- Gitlab.BaseUrl <$> URLParams.get "gitlab_url"
let config = { baseUrl, token }
groupId <- Gitlab.GroupId <$> URLParams.get "group_id"
userId <- Gitlab.UserId <$> URLParams.get "user_id"
let config = { baseUrl, token, groupId, userId }
-- TODO: display error if parameters are not provided
HA.runHalogenAff $ do
body <- HA.awaitBody
Expand Down
2 changes: 1 addition & 1 deletion src/URLSearchParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
exports.get = function(paramName) {
return function() {
var url = new URL(window.location.toString());
return url.searchParams.get(paramName);
return url.searchParams.get(paramName) || "null";
};
};