Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
a4b31c15
Commit
a4b31c15
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Plain Diff
Merge branch 'remove_link_component' into 'master'
Removing unused link component See merge request
!161
parents
043e5bd8
c0aacb37
No related branches found
No related tags found
1 merge request
!161
Removing unused link component
Pipeline
#100734
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/components/link/index.tsx
+0
-129
0 additions, 129 deletions
frontend/src/components/link/index.tsx
frontend/src/components/link/link.test.tsx
+0
-13
0 additions, 13 deletions
frontend/src/components/link/link.test.tsx
with
0 additions
and
142 deletions
frontend/src/components/link/index.tsx
deleted
100644 → 0
+
0
−
129
View file @
043e5bd8
import
React
from
'
react
'
import
styled
from
'
@emotion/styled/macro
'
interface
IStyledLink
{
external
?:
boolean
underline
?:
boolean
marginRight
?:
boolean
inheritColor
?:
boolean
noUnderline
?:
boolean
}
interface
ILink
{
to
:
string
external
?:
boolean
children
?:
React
.
ReactNode
marginRight
?:
boolean
noExternalIcon
?:
boolean
mail
?:
boolean
inheritColor
?:
boolean
underline
?:
boolean
noUnderline
?:
boolean
}
const
externalLinkIcon
=
(
<
svg
width
=
"15.3"
height
=
"12.6"
viewBox
=
"0 0 17 14"
>
<
g
fill
=
"#0F748D"
fillRule
=
"evenodd"
>
<
path
d
=
"M13.044 8.157h-.607a.3.3 0 0 0-.218.082.276.276 0 0 0-.085.208v2.907c0 .4-.148.742-.445 1.027a1.493 1.493 0 0 1-1.072.427H2.73c-.417 0-.774-.143-1.071-.427a1.371 1.371 0 0 1-.446-1.027V3.796c0-.4.149-.742.446-1.026a1.493 1.493 0 0 1 1.071-.427h6.674a.302.302 0 0 0 .218-.082.277.277 0 0 0 .085-.209v-.581a.277.277 0 0 0-.085-.21.302.302 0 0 0-.218-.08H2.73c-.752 0-1.395.255-1.93.767-.533.511-.8 1.128-.8 1.848v7.558c0 .721.267 1.337.801 1.849a2.689 2.689 0 0 0 1.93.768h7.886c.752 0 1.395-.256 1.93-.768.534-.512.8-1.128.8-1.849V8.448a.276.276 0 0 0-.085-.21.302.302 0 0 0-.218-.081z"
/>
<
path
d
=
"M16.807.19a.596.596 0 0 0-.426-.173h-4.854a.596.596 0 0 0-.426.173.548.548 0 0 0-.18.409c0 .157.06.294.18.409l1.668 1.598-6.18 5.923a.281.281 0 0 0-.095.21c0 .078.031.148.094.208L7.67 9.983a.306.306 0 0 0 .436 0l6.18-5.923 1.67 1.599c.12.115.262.172.426.172a.596.596 0 0 0 .426-.172.547.547 0 0 0 .18-.409V.599a.548.548 0 0 0-.18-.409z"
/>
</
g
>
</
svg
>
)
const
ExternalIcon
=
styled
.
span
`
margin-left: 1.2rem;
position: relative;
top: 1px;
z-index: -1;
`
const
StyledLink
=
styled
.
a
<
IStyledLink
>
`
display: inline-flex;
align-items: center;
`
// TODO Put back when routes are set up
// const StyledRouterLink = styled(RouterLink)`
// ${baseInputStyles};
// `
function
Link
(
props
:
ILink
)
{
const
{
children
,
external
,
to
,
noExternalIcon
,
mail
,
underline
,
marginRight
,
inheritColor
,
noUnderline
,
}
=
props
if
(
mail
)
{
return
(
<
StyledLink
href
=
{
`mailto:
${
to
}
`
}
external
=
{
external
}
underline
=
{
underline
}
marginRight
=
{
marginRight
}
inheritColor
=
{
inheritColor
}
noUnderline
=
{
noUnderline
}
>
{
children
}
</
StyledLink
>
)
}
if
(
external
)
{
const
urlRegex
=
/^
((
http|https
)
:
\/\/)
/
const
href
=
urlRegex
.
test
(
to
)
?
to
:
`//
${
to
}
`
return
(
<
StyledLink
href
=
{
href
}
target
=
"_blank"
rel
=
"noopener noreferrer"
external
=
{
external
}
underline
=
{
underline
}
marginRight
=
{
marginRight
}
inheritColor
=
{
inheritColor
}
noUnderline
=
{
noUnderline
}
>
{
children
}
{
!
noExternalIcon
&&
<
ExternalIcon
>
{
externalLinkIcon
}
</
ExternalIcon
>
}
</
StyledLink
>
)
}
// TODO Use StyledRouterLink for internal links when routes are set up
// return (
// <StyledRouterLink {...props}>
// {children}
// </StyledRouterLink>
// )
return
(
<
StyledLink
external
=
{
external
}
underline
=
{
underline
}
marginRight
=
{
marginRight
}
inheritColor
=
{
inheritColor
}
noUnderline
=
{
noUnderline
}
>
{
children
}
</
StyledLink
>
)
}
Link
.
defaultProps
=
{
external
:
false
,
children
:
undefined
,
marginRight
:
false
,
noExternalIcon
:
false
,
mail
:
false
,
inheritColor
:
false
,
underline
:
false
,
noUnderline
:
false
,
}
export
default
Link
This diff is collapsed.
Click to expand it.
frontend/src/components/link/link.test.tsx
deleted
100644 → 0
+
0
−
13
View file @
043e5bd8
import
React
from
'
react
'
import
{
render
,
waitFor
,
screen
}
from
'
@testing-library/react
'
import
Link
from
'
./index
'
describe
(
'
Tests for Link component
'
,
()
=>
{
test
(
'
External link prefixes route link with //
'
,
async
()
=>
{
render
(<
Link
external
to
=
"example.org"
/>)
await
waitFor
(()
=>
screen
.
getByRole
(
'
link
'
))
expect
(
screen
.
getByRole
(
'
link
'
)).
toHaveAttribute
(
'
href
'
,
'
//example.org
'
)
})
})
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