Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Štěpán Šonovský
bc
Commits
41f77701
There was an error fetching the commit references. Please try again later.
Commit
41f77701
authored
7 months ago
by
Štěpán Šonovský
Browse files
Options
Downloads
Patches
Plain Diff
fix: two step downloading
parent
3606af6c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/components/CommitList.tsx
+29
-32
29 additions, 32 deletions
src/app/components/CommitList.tsx
src/app/csvDownload/CsvDownload.tsx
+12
-32
12 additions, 32 deletions
src/app/csvDownload/CsvDownload.tsx
src/app/csvDownload/CsvDownloadSize.tsx
+4
-2
4 additions, 2 deletions
src/app/csvDownload/CsvDownloadSize.tsx
with
45 additions
and
66 deletions
src/app/components/CommitList.tsx
+
29
−
32
View file @
41f77701
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
useCommits
from
"
@/app/hooks/useCommits
"
;
import
CsvDownloadPositivity
from
"
@/app/csvDownload/CsvDownload
"
;
import
CsvDownloadSize
from
"
@/app/csvDownload/CsvDownloadSize
"
;
...
...
@@ -8,16 +8,6 @@ const CommitList = ({ projectId, token, host, onCommitClick }) => {
const
[
showCsvDownloadPositivity
,
setShowCsvDownloadPositivity
]
=
useState
(
false
);
const
[
showCsvDownloadSize
,
setShowCsvDownloadSize
]
=
useState
(
false
);
useEffect
(()
=>
{
let
timer
;
if
(
showCsvDownloadPositivity
)
{
timer
=
setTimeout
(()
=>
setShowCsvDownloadPositivity
(
false
),
2000
);
}
else
if
(
showCsvDownloadSize
)
{
timer
=
setTimeout
(()
=>
setShowCsvDownloadSize
(
false
),
2000
);
}
return
()
=>
clearTimeout
(
timer
);
},
[
showCsvDownloadPositivity
,
showCsvDownloadSize
]);
if
(
loading
)
return
<
p
>
Loading...
</
p
>;
if
(
error
)
return
<
p
>
Error:
{
error
.
message
}
</
p
>;
...
...
@@ -38,29 +28,36 @@ const CommitList = ({ projectId, token, host, onCommitClick }) => {
)
:
(
<
p
>
No commits found
</
p
>
)
}
<
button
onClick
=
{
()
=>
setShowCsvDownloadSize
(
true
)
}
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 m-2"
>
Download CSV commits size
</
button
>
{
showCsvDownloadSize
&&
(
<
div
className
=
"mt-4"
>
<
CsvDownloadSize
commits
=
{
commits
}
projectId
=
{
projectId
}
token
=
{
token
}
/>
</
div
>
)
}
<
button
onClick
=
{
()
=>
setShowCsvDownloadPositivity
(
true
)
}
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 m-2"
>
Download CSV commits positivity
</
button
>
{
showCsvDownloadPositivity
&&
(
{
!
showCsvDownloadSize
?
(
<
button
onClick
=
{
()
=>
setShowCsvDownloadSize
(
prev
=>
!
prev
)
}
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 m-2"
>
{
"
Fetch CSV commits size
"
}
</
button
>
)
:
(
<
div
className
=
"mt-4"
>
<
CsvDownload
Positivity
commits
=
{
commits
}
projectId
=
{
projectId
}
token
=
{
token
}
/>
<
CsvDownload
Size
commits
=
{
commits
}
projectId
=
{
projectId
}
token
=
{
token
}
/>
</
div
>
)
}
)
}
{
!
showCsvDownloadPositivity
?
(
<
button
onClick
=
{
()
=>
setShowCsvDownloadPositivity
(
true
)
}
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 m-2"
>
Fetch CSV commits positivity
</
button
>
)
:
(
<
div
className
=
"mt-4"
>
<
CsvDownloadPositivity
commits
=
{
commits
}
projectId
=
{
projectId
}
token
=
{
token
}
/>
</
div
>
)
}
</
div
>
);
};
...
...
This diff is collapsed.
Click to expand it.
src/app/csvDownload/CsvDownload.tsx
+
12
−
32
View file @
41f77701
import
{
useState
,
useEffect
,
createRef
}
from
'
react
'
;
import
useCommitDetails
,
{
useCommitsPositivity
}
from
"
@/app/hooks/useCommitDetails
"
;
import
{
useState
,
useEffect
,
createRef
}
from
'
react
'
;
import
{
CSVLink
}
from
"
react-csv
"
;
type
CommitDetails
=
{
author
:
string
;
createdAt
:
string
;
projectId
:
string
;
};
import
useCommitDetails
,
{
useCommitsPositivity
}
from
"
@/app/hooks/useCommitDetails
"
;
const
CsvDownloadPositivity
=
({
commits
,
projectId
,
token
})
=>
{
const
{
data
,
isLoading
}
=
useCommitsPositivity
(
projectId
,
commits
,
token
);
const
{
data
,
isLoading
}
=
useCommitsPositivity
(
projectId
,
commits
,
token
);
const
csvlink
=
createRef
();
// useEffect(() => {
// if (!isLoading && data) {
// console.log("das");
// csvlink.current.link.click();
// }
// }, [csvlink, data, isLoading]);
//
// console.log(data);
return
(
<
div
>
{
!
isLoading
&&
data
?
(
<
div
>
<
CSVLink
data
=
{
data
}
ref
=
{
csvli
nk
}
target
=
"_blank"
enclosingCharacter
=
{
``
}
>
lol
</
CSVLink
>
</
div
>
<
CSVLink
data
=
{
data
}
ref
=
{
csvlink
}
target
=
"_bla
nk
"
enclosingCharacter
=
{
``
}
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700"
>
Download CSV commits positivity
</
CSVLink
>
)
:
(
<
p
>
Loading...
</
p
>
)
}
</
div
>
);
};
export
default
CsvDownloadPositivity
;
This diff is collapsed.
Click to expand it.
src/app/csvDownload/CsvDownloadSize.tsx
+
4
−
2
View file @
41f77701
...
...
@@ -33,11 +33,13 @@ const CsvDownloadSize = ({ commits, projectId, token }) => {
ref
=
{
csvlink
}
target
=
"_blank"
enclosingCharacter
=
{
``
}
>
lol
</
CSVLink
>
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700"
>
Download CSV size
</
CSVLink
>
</
div
>
)
:
(
<
p
>
Loading...
</
p
>
<
p
className
=
"mt-4 bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700"
>
Loading...
</
p
>
)
}
</
div
>
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment