Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-web
Commits
62cf7e93
Commit
62cf7e93
authored
6 months ago
by
Hélène Jonin
Browse files
Options
Downloads
Patches
Plain Diff
Refactor Permalinks box
parent
ba351e0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1315
Refactor Permalinks box
Pipeline
#10722
passed
6 months ago
Stage: external
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cypress/e2e/swhids.cy.js
+30
-0
30 additions, 0 deletions
cypress/e2e/swhids.cy.js
swh/web/browse/assets/browse/swhid-utils.js
+17
-0
17 additions, 0 deletions
swh/web/browse/assets/browse/swhid-utils.js
with
47 additions
and
0 deletions
cypress/e2e/swhids.cy.js
+
30
−
0
View file @
62cf7e93
...
...
@@ -259,4 +259,34 @@ describe('SWHIDs Tests', function() {
});
});
it
(
'
should update copy buttons after clicking on them
'
,
function
()
{
cy
.
get
(
'
.ui-slideouttab-handle
'
)
.
click
();
for
(
const
td
of
testsData
)
{
cy
.
get
(
`a[href="#swhid-tab-
${
td
.
objectType
}
"]`
)
.
click
();
cy
.
get
(
`#swhid-tab-
${
td
.
objectType
}
`
)
.
should
(
'
be.visible
'
);
cy
.
get
(
`#swhid-tab-
${
td
.
objectType
}
.btn-swhid-copy`
)
.
should
(
'
contain.text
'
,
'
Copy identifier
'
)
.
should
(
'
not.contain.text
'
,
'
Copied!
'
)
.
click
()
.
should
(
'
have.text
'
,
'
Copied!
'
)
.
wait
(
1001
)
.
should
(
'
not.contain.text
'
,
'
Copied!
'
)
.
should
(
'
contain.text
'
,
'
Copy identifier
'
);
cy
.
get
(
`#swhid-tab-
${
td
.
objectType
}
.btn-swhid-url-copy`
)
.
should
(
'
contain.text
'
,
'
Copy permalink
'
)
.
should
(
'
not.contain.text
'
,
'
Copied!
'
)
.
click
()
.
should
(
'
have.text
'
,
'
Copied!
'
)
.
wait
(
1001
)
.
should
(
'
not.contain.text
'
,
'
Copied!
'
)
.
should
(
'
contain.text
'
,
'
Copy permalink
'
);
}
});
});
This diff is collapsed.
Click to expand it.
swh/web/browse/assets/browse/swhid-utils.js
+
17
−
0
View file @
62cf7e93
...
...
@@ -96,11 +96,26 @@ function updateSWHIDsTabSize() {
}
$
(
document
).
ready
(()
=>
{
const
toggleButtonText
=
(
button
,
text
)
=>
{
const
currentLabel
=
button
.
innerHTML
;
if
(
currentLabel
===
text
)
{
return
;
}
button
.
innerHTML
=
text
;
setTimeout
(
function
()
{
button
.
innerHTML
=
currentLabel
;
},
1000
);
};
new
ClipboardJS
(
'
.btn-swhid-copy
'
,
{
text
:
trigger
=>
{
const
swhId
=
$
(
trigger
).
closest
(
'
.swhid-ui
'
).
find
(
'
.swhid
'
).
text
();
return
swhId
.
replace
(
/;
\n
/g
,
'
;
'
);
}
}).
on
(
'
success
'
,
function
(
e
)
{
toggleButtonText
(
e
.
trigger
,
'
Copied!
'
);
});
new
ClipboardJS
(
'
.btn-swhid-url-copy
'
,
{
...
...
@@ -108,6 +123,8 @@ $(document).ready(() => {
const
swhIdUrl
=
$
(
trigger
).
closest
(
'
.swhid-ui
'
).
find
(
'
.swhid
'
).
attr
(
'
href
'
);
return
window
.
location
.
origin
+
swhIdUrl
;
}
}).
on
(
'
success
'
,
function
(
e
)
{
toggleButtonText
(
e
.
trigger
,
'
Copied!
'
);
});
// prevent automatic closing of SWHIDs tab during guided tour
...
...
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