2020-05-15 09:07:59 +00:00
|
|
|
import Vue from 'vue';
|
2021-02-25 03:10:50 +00:00
|
|
|
|
2020-05-15 09:07:59 +00:00
|
|
|
import ExpiresAtField from './components/expires_at_field.vue';
|
|
|
|
|
2020-12-23 21:10:24 +00:00
|
|
|
const getInputAttrs = (el) => {
|
2020-11-12 00:09:44 +00:00
|
|
|
const input = el.querySelector('input');
|
|
|
|
|
|
|
|
return {
|
|
|
|
id: input.id,
|
|
|
|
name: input.name,
|
|
|
|
placeholder: input.placeholder,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-02-25 03:10:50 +00:00
|
|
|
export const initExpiresAtField = () => {
|
2020-11-12 00:09:44 +00:00
|
|
|
const el = document.querySelector('.js-access-tokens-expires-at');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const inputAttrs = getInputAttrs(el);
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
render(h) {
|
|
|
|
return h(ExpiresAtField, {
|
|
|
|
props: {
|
|
|
|
inputAttrs,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2020-05-15 09:07:59 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-02-25 03:10:50 +00:00
|
|
|
export const initProjectsField = () => {
|
|
|
|
const el = document.querySelector('.js-access-tokens-projects');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const inputAttrs = getInputAttrs(el);
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|