diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..14da5ef9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=lf \ No newline at end of file diff --git a/src/Dashboard/Component.purs b/src/Dashboard/Component.purs index 16affcf1..f04ac34f 100644 --- a/src/Dashboard/Component.purs +++ b/src/Dashboard/Component.purs @@ -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 @@ -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 diff --git a/src/Dashboard/Model.purs b/src/Dashboard/Model.purs index 7f4b6165..25dd5821 100644 --- a/src/Dashboard/Model.purs +++ b/src/Dashboard/Model.purs @@ -18,8 +18,6 @@ type CommitRow = { branch :: Gitlab.BranchName , hash :: Gitlab.CommitShortHash , authorImg :: String - , name :: String - , username :: String , commitTitle :: String } @@ -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 diff --git a/src/Dashboard/View.purs b/src/Dashboard/View.purs index f2983ebc..a96ac3ee 100644 --- a/src/Dashboard/View.purs +++ b/src/Dashboard/View.purs @@ -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 @@ -81,7 +79,6 @@ formatCommit { authorImg H.div [ ] [ authorImage authorImg - , H.text (" " <> name <> " (" <> username <> ")") , divider , fontAwesome $ Icon [] CodeFork , H.b_ [ H.text (" " <> branch) ] diff --git a/src/Gitlab.purs b/src/Gitlab.purs index 9174acda..1e9ba48f 100644 --- a/src/Gitlab.purs +++ b/src/Gitlab.purs @@ -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 @@ -114,8 +116,6 @@ type Project = type User = { avatar_url :: String - , name :: String - , username :: String } type Commit = @@ -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 diff --git a/src/Main.purs b/src/Main.purs index 921c6695..c6abb2d0 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -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 diff --git a/src/URLSearchParams.js b/src/URLSearchParams.js index f937732f..c4c27231 100644 --- a/src/URLSearchParams.js +++ b/src/URLSearchParams.js @@ -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"; }; };