Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fbc73df6
Commit
fbc73df6
authored
Feb 23, 2021
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change how projects field is dynamically imported
Should reduce the bundle size
parent
fa159909
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
28 deletions
+31
-28
app/assets/javascripts/access_tokens/index.js
app/assets/javascripts/access_tokens/index.js
+17
-11
app/assets/javascripts/pages/profiles/personal_access_tokens/index.js
...avascripts/pages/profiles/personal_access_tokens/index.js
+2
-13
locale/gitlab.pot
locale/gitlab.pot
+0
-3
spec/frontend/access_tokens/index_spec.js
spec/frontend/access_tokens/index_spec.js
+12
-1
No files found.
app/assets/javascripts/access_tokens/index.js
View file @
fbc73df6
import
Vue
from
'
vue
'
;
import
ExpiresAtField
from
'
./components/expires_at_field.vue
'
;
import
ProjectsField
from
'
./components/projects_field.vue
'
;
const
getInputAttrs
=
(
el
)
=>
{
const
input
=
el
.
querySelector
(
'
input
'
);
...
...
@@ -42,14 +42,20 @@ export const initProjectsField = () => {
const
inputAttrs
=
getInputAttrs
(
el
);
return
new
Vue
({
el
,
render
(
h
)
{
return
h
(
ProjectsField
,
{
props
:
{
inputAttrs
,
},
});
},
});
if
(
window
.
gon
.
features
.
personalAccessTokensScopedToProjects
)
{
const
ProjectsField
=
()
=>
import
(
'
./components/projects_field.vue
'
);
return
new
Vue
({
el
,
render
(
h
)
{
return
h
(
ProjectsField
,
{
props
:
{
inputAttrs
,
},
});
},
});
}
return
null
;
};
app/assets/javascripts/pages/profiles/personal_access_tokens/index.js
View file @
fbc73df6
import
{
initExpiresAtField
}
from
'
~/access_tokens
'
;
import
createFlash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
initExpiresAtField
,
initProjectsField
}
from
'
~/access_tokens
'
;
initExpiresAtField
();
if
(
window
.
gon
.
features
.
personalAccessTokensScopedToProjects
)
{
import
(
'
~/access_tokens
'
)
.
then
(({
initProjectsField
})
=>
{
initProjectsField
();
})
.
catch
(()
=>
{
createFlash
(
__
(
'
An error occurred while loading the access tokens form, please try again.
'
));
});
}
initProjectsField
();
locale/gitlab.pot
View file @
fbc73df6
...
...
@@ -3433,9 +3433,6 @@ msgstr ""
msgid "An error occurred while loading project creation UI"
msgstr ""
msgid "An error occurred while loading the access tokens form, please try again."
msgstr ""
msgid "An error occurred while loading the data. Please try again."
msgstr ""
...
...
spec/frontend/access_tokens/index_spec.js
View file @
fbc73df6
import
{
createWrapper
}
from
'
@vue/test-utils
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
initExpiresAtField
,
initProjectsField
}
from
'
~/access_tokens
'
;
import
ExpiresAtField
from
'
~/access_tokens/components/expires_at_field.vue
'
;
import
ProjectsField
from
'
~/access_tokens/components/projects_field.vue
'
;
describe
(
'
access tokens
'
,
()
=>
{
beforeEach
(()
=>
{
window
.
gon
=
{
features
:
{
personalAccessTokensScopedToProjects
:
true
}
};
});
afterEach
(()
=>
{
document
.
body
.
innerHTML
=
''
;
window
.
gon
=
{};
});
describe
.
each
`
...
...
@@ -29,8 +36,12 @@ describe('access tokens', () => {
document
.
body
.
appendChild
(
mountEl
);
});
it
(
`mounts component and sets \`inputAttrs\` prop`
,
()
=>
{
it
(
`mounts component and sets \`inputAttrs\` prop`
,
async
()
=>
{
const
wrapper
=
createWrapper
(
initFunction
());
// Wait for dynamic imports to resolve
await
waitForPromises
();
const
component
=
wrapper
.
findComponent
(
expectedComponent
);
expect
(
component
.
exists
()).
toBe
(
true
);
...
...
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