Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
2c852206
Commit
2c852206
authored
May 03, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dialog for generating tokens.
parent
1afd9958
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
1 deletion
+102
-1
static/galene.css
static/galene.css
+4
-0
static/galene.html
static/galene.html
+15
-0
static/galene.js
static/galene.js
+83
-1
No files found.
static/galene.css
View file @
2c852206
...
...
@@ -1337,3 +1337,7 @@ header .collapse:hover {
margin-left
:
10px
;
margin-right
:
10px
;
}
#invite-dialog
{
background-color
:
#eee
;
}
static/galene.html
View file @
2c852206
...
...
@@ -281,6 +281,21 @@
</div>
</div>
<dialog
id=
"invite-dialog"
>
<form
method=
"dialog"
>
<label
for=
"invite-username"
>
Username (optional):
</label>
<input
id=
"invite-username"
type=
"text"
/>
<br>
<label
for=
"invite-not-before"
>
Not before:
</label>
<input
id=
"invite-not-before"
type=
"datetime-local"
/>
<br>
<label
for=
"invite-expires"
>
Expires:
</label>
<input
id=
"invite-expires"
type=
"datetime-local"
/>
<br>
<button
id=
"invite-cancel"
value=
"cancel"
type=
"button"
>
Cancel
</button>
<button
value=
"invite"
value=
"invite"
>
Invite
</button>
</dialog>
<script
src=
"/protocol.js"
defer
></script>
<script
src=
"/external/toastify/toastify.js"
defer
></script>
<script
src=
"/external/contextual/contextual.js"
defer
></script>
...
...
static/galene.js
View file @
2c852206
...
...
@@ -2094,6 +2094,88 @@ function stringCompare(a, b) {
return
0
}
/**
* @param {string} v
*/
function
dateFromInput
(
v
)
{
let
d
=
new
Date
(
v
);
if
(
d
.
toString
()
===
'
Invalid Date
'
)
throw
new
Error
(
'
Invalid date
'
);
return
d
;
}
/**
* @param {Date} d
*/
function
dateToInput
(
d
)
{
let
dd
=
new
Date
(
d
);
dd
.
setMinutes
(
dd
.
getMinutes
()
-
dd
.
getTimezoneOffset
());
return
dd
.
toISOString
().
slice
(
0
,
-
1
);
}
function
inviteMenu
()
{
let
d
=
/** @type {HTMLDialogElement} */
(
document
.
getElementById
(
'
invite-dialog
'
));
if
(
!
(
'
HTMLDialogElement
'
in
window
)
||
!
d
.
showModal
)
{
makeToken
();
return
;
}
d
.
returnValue
=
''
;
let
c
=
getButtonElement
(
'
invite-cancel
'
);
c
.
onclick
=
function
(
e
)
{
d
.
close
(
'
cancel
'
);
};
let
u
=
getInputElement
(
'
invite-username
'
);
u
.
value
=
''
;
let
now
=
new
Date
();
now
.
setMilliseconds
(
0
);
now
.
setSeconds
(
0
);
let
nb
=
getInputElement
(
'
invite-not-before
'
);
nb
.
min
=
dateToInput
(
now
);
let
ex
=
getInputElement
(
'
invite-expires
'
);
let
expires
=
new
Date
(
now
);
expires
.
setDate
(
expires
.
getDate
()
+
2
);
ex
.
min
=
dateToInput
(
expires
);
ex
.
value
=
dateToInput
(
expires
);
d
.
showModal
();
}
document
.
getElementById
(
'
invite-dialog
'
).
onclose
=
function
(
e
)
{
if
(
!
(
this
instanceof
HTMLDialogElement
))
throw
new
Error
(
'
Unexpected type for this
'
);
let
dialog
=
/** @type {HTMLDialogElement} */
(
this
);
if
(
dialog
.
returnValue
!==
'
invite
'
)
return
;
let
u
=
getInputElement
(
'
invite-username
'
);
let
username
=
u
.
value
.
trim
()
||
null
;
let
nb
=
getInputElement
(
'
invite-not-before
'
);
let
notBefore
=
null
;
if
(
nb
.
value
)
{
try
{
notBefore
=
dateFromInput
(
nb
.
value
);
}
catch
(
e
)
{
displayError
(
`Couldn't parse
${
nb
.
value
}
:
${
e
}
`
);
return
;
}
}
let
ex
=
getInputElement
(
'
invite-expires
'
);
let
expires
=
null
;
if
(
ex
.
value
)
{
try
{
expires
=
dateFromInput
(
ex
.
value
);
}
catch
(
e
)
{
displayError
(
`Couldn't parse
${
nb
.
value
}
:
${
e
}
`
);
return
;
}
}
let
template
=
{}
if
(
username
)
template
.
username
=
username
;
if
(
notBefore
)
template
[
'
not-before
'
]
=
notBefore
;
if
(
expires
)
template
.
expires
=
expires
;
makeToken
(
template
);
};
/**
* @param {HTMLElement} elt
*/
...
...
@@ -2122,7 +2204,7 @@ function userMenu(elt) {
if
(
serverConnection
.
version
!==
"
1
"
&&
serverConnection
.
permissions
.
indexOf
(
'
token
'
)
>=
0
)
{
items
.
push
({
label
:
'
Invite user
'
,
onClick
:
()
=>
{
makeToken
();
inviteMenu
();
}});
}
if
(
serverConnection
.
permissions
.
indexOf
(
'
present
'
)
>=
0
&&
canFile
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment