fix: public gh repo reload compose
This commit is contained in:
@@ -351,7 +351,7 @@
|
|||||||
}
|
}
|
||||||
async function reloadCompose() {
|
async function reloadCompose() {
|
||||||
if (loading.reloadCompose) return;
|
if (loading.reloadCompose) return;
|
||||||
if (!$appSession.tokens.github) {
|
if (!$appSession.tokens.github && !isPublicRepository) {
|
||||||
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
||||||
$appSession.tokens.github = token;
|
$appSession.tokens.github = token;
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (application.gitSource.type === 'gitlab') {
|
if (application.gitSource.type === 'gitlab') {
|
||||||
if (!$appSession.tokens.gitlab) {
|
if (!$appSession.tokens.gitlab && !isPublicRepository) {
|
||||||
await getGitlabToken();
|
await getGitlabToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if repositories.length === 0 && loading.repositories === false}
|
{#if repositories.length === 0 && loading.repositories === false}
|
||||||
<div class="flex-col text-center">
|
<div class="flex-col text-center">
|
||||||
<div class="pb-4">{$t('application.configuration.no_repositories_configured')}</div>
|
<div class="pb-4">{$t('application.configuration.no_repositories_configured')}</div>
|
||||||
@@ -134,43 +135,45 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<form on:submit|preventDefault={handleSubmit} class="px-10">
|
<form on:submit|preventDefault={handleSubmit} class="px-10">
|
||||||
<div class="flex lg:flex-row flex-col lg:space-y-0 space-y-2 space-x-0 lg:space-x-2 items-center lg:justify-center">
|
<div
|
||||||
<div class="custom-select-wrapper w-full"><label for="repository" class="pb-1">Repository</label>
|
class="flex lg:flex-row flex-col lg:space-y-0 space-y-2 space-x-0 lg:space-x-2 items-center lg:justify-center"
|
||||||
<Select
|
>
|
||||||
placeholder={loading.repositories
|
<div class="custom-select-wrapper w-full">
|
||||||
? $t('application.configuration.loading_repositories')
|
<label for="repository" class="pb-1">Repository</label>
|
||||||
: $t('application.configuration.select_a_repository')}
|
<Select
|
||||||
id="repository"
|
placeholder={loading.repositories
|
||||||
showIndicator={!loading.repositories}
|
? $t('application.configuration.loading_repositories')
|
||||||
isWaiting={loading.repositories}
|
: $t('application.configuration.select_a_repository')}
|
||||||
on:select={loadBranches}
|
id="repository"
|
||||||
items={reposSelectOptions}
|
showIndicator={!loading.repositories}
|
||||||
isDisabled={loading.repositories}
|
isWaiting={loading.repositories}
|
||||||
isClearable={false}
|
on:select={loadBranches}
|
||||||
/>
|
items={reposSelectOptions}
|
||||||
</div>
|
isDisabled={loading.repositories}
|
||||||
<input class="hidden" bind:value={selected.projectId} name="projectId" />
|
isClearable={false}
|
||||||
<div class="custom-select-wrapper w-full"><label for="repository" class="pb-1">Branch</label>
|
/>
|
||||||
<Select
|
</div>
|
||||||
placeholder={loading.branches
|
<input class="hidden" bind:value={selected.projectId} name="projectId" />
|
||||||
? $t('application.configuration.loading_branches')
|
<div class="custom-select-wrapper w-full">
|
||||||
: !selected.repository
|
<label for="repository" class="pb-1">Branch</label>
|
||||||
? $t('application.configuration.select_a_repository_first')
|
<Select
|
||||||
: $t('application.configuration.select_a_branch')}
|
placeholder={loading.branches
|
||||||
isWaiting={loading.branches}
|
? $t('application.configuration.loading_branches')
|
||||||
showIndicator={selected.repository && !loading.branches}
|
: !selected.repository
|
||||||
id="branches"
|
? $t('application.configuration.select_a_repository_first')
|
||||||
on:select={selectBranch}
|
: $t('application.configuration.select_a_branch')}
|
||||||
items={branchSelectOptions}
|
isWaiting={loading.branches}
|
||||||
isDisabled={loading.branches || !selected.repository}
|
showIndicator={selected.repository && !loading.branches}
|
||||||
isClearable={false}
|
id="branches"
|
||||||
/>
|
on:select={selectBranch}
|
||||||
</div></div>
|
items={branchSelectOptions}
|
||||||
|
isDisabled={loading.branches || !selected.repository}
|
||||||
|
isClearable={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="pt-5 flex-col flex justify-center items-center space-y-4">
|
<div class="pt-5 flex-col flex justify-center items-center space-y-4">
|
||||||
<button
|
<button class="btn btn-wide btn-primary" type="submit" disabled={!showSave}
|
||||||
class="btn btn-wide btn-primary"
|
|
||||||
type="submit"
|
|
||||||
disabled={!showSave}
|
|
||||||
>{$t('forms.save')}</button
|
>{$t('forms.save')}</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -366,16 +366,16 @@
|
|||||||
async function reloadCompose() {
|
async function reloadCompose() {
|
||||||
if (loading.reloadCompose) return;
|
if (loading.reloadCompose) return;
|
||||||
loading.reloadCompose = true;
|
loading.reloadCompose = true;
|
||||||
if (!$appSession.tokens.github) {
|
if (!$appSession.tokens.github && !isPublicRepository) {
|
||||||
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
||||||
$appSession.tokens.github = token;
|
$appSession.tokens.github = token;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (application.gitSource.type === 'github') {
|
if (application.gitSource.type === 'github') {
|
||||||
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
|
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
|
||||||
? application.dockerComposeFileLocation
|
? application.dockerComposeFileLocation
|
||||||
: `/${application.dockerComposeFileLocation}`;
|
: `/${application.dockerComposeFileLocation}`;
|
||||||
|
|
||||||
const headers = isPublicRepository
|
const headers = isPublicRepository
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
@@ -402,17 +402,17 @@
|
|||||||
if (!$appSession.tokens.gitlab) {
|
if (!$appSession.tokens.gitlab) {
|
||||||
await getGitlabToken();
|
await getGitlabToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
|
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
|
||||||
? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start
|
? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start
|
||||||
: application.dockerComposeFileLocation;
|
: application.dockerComposeFileLocation;
|
||||||
|
|
||||||
// If the file is in a subdirectory, lastIndex will be > 0
|
// If the file is in a subdirectory, lastIndex will be > 0
|
||||||
// Otherwise it will be -1 and path will be an empty string
|
// Otherwise it will be -1 and path will be an empty string
|
||||||
const lastIndex = composeLocation.lastIndexOf('/') + 1
|
const lastIndex = composeLocation.lastIndexOf('/') + 1;
|
||||||
const path = composeLocation.substring(0, lastIndex)
|
const path = composeLocation.substring(0, lastIndex);
|
||||||
const fileName = composeLocation.substring(lastIndex)
|
const fileName = composeLocation.substring(lastIndex);
|
||||||
|
|
||||||
const headers = isPublicRepository
|
const headers = isPublicRepository
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
@@ -425,8 +425,7 @@
|
|||||||
...headers
|
...headers
|
||||||
});
|
});
|
||||||
const dockerComposeFileYml = files.find(
|
const dockerComposeFileYml = files.find(
|
||||||
(file: { name: string; type: string }) =>
|
(file: { name: string; type: string }) => file.name === fileName && file.type === 'blob'
|
||||||
file.name === fileName && file.type === 'blob'
|
|
||||||
);
|
);
|
||||||
const id = dockerComposeFileYml.id;
|
const id = dockerComposeFileYml.id;
|
||||||
|
|
||||||
@@ -506,7 +505,14 @@
|
|||||||
<div class="grid grid-flow-row gap-2 px-4">
|
<div class="grid grid-flow-row gap-2 px-4">
|
||||||
<div class="mt-2 grid grid-cols-2 items-center">
|
<div class="mt-2 grid grid-cols-2 items-center">
|
||||||
<label for="name">{$t('forms.name')}</label>
|
<label for="name">{$t('forms.name')}</label>
|
||||||
<input name="name" id="name" class="w-full" bind:value={application.name} disabled={!$appSession.isAdmin} required />
|
<input
|
||||||
|
name="name"
|
||||||
|
id="name"
|
||||||
|
class="w-full"
|
||||||
|
bind:value={application.name}
|
||||||
|
disabled={!$appSession.isAdmin}
|
||||||
|
required
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if !isSimpleDockerfile}
|
{#if !isSimpleDockerfile}
|
||||||
<div class="grid grid-cols-2 items-center">
|
<div class="grid grid-cols-2 items-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user