fix: read-only iam
This commit is contained in:
@@ -58,11 +58,10 @@ export const appSession: Writable<AppSession> = writable({
|
|||||||
});
|
});
|
||||||
export const disabledButton: Writable<boolean> = writable(false);
|
export const disabledButton: Writable<boolean> = writable(false);
|
||||||
export const isDeploymentEnabled: Writable<boolean> = writable(false);
|
export const isDeploymentEnabled: Writable<boolean> = writable(false);
|
||||||
export function checkIfDeploymentEnabledApplications(isAdmin: boolean, application: any) {
|
export function checkIfDeploymentEnabledApplications(application: any) {
|
||||||
return !!(
|
return !!(
|
||||||
isAdmin &&
|
|
||||||
(application.buildPack === 'compose') ||
|
(application.buildPack === 'compose') ||
|
||||||
(application.fqdn || application.settings.isBot) &&
|
(application.fqdn || application.settings?.isBot) &&
|
||||||
((application.gitSource &&
|
((application.gitSource &&
|
||||||
application.repository &&
|
application.repository &&
|
||||||
application.buildPack) || application.simpleDockerfile) &&
|
application.buildPack) || application.simpleDockerfile) &&
|
||||||
@@ -70,9 +69,8 @@ export function checkIfDeploymentEnabledApplications(isAdmin: boolean, applicati
|
|||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export function checkIfDeploymentEnabledServices(isAdmin: boolean, service: any) {
|
export function checkIfDeploymentEnabledServices( service: any) {
|
||||||
return (
|
return (
|
||||||
isAdmin &&
|
|
||||||
service.fqdn &&
|
service.fqdn &&
|
||||||
service.destinationDocker &&
|
service.destinationDocker &&
|
||||||
service.version &&
|
service.version &&
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
let forceDelete = false;
|
let forceDelete = false;
|
||||||
let stopping = false;
|
let stopping = false;
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications(application);
|
||||||
|
|
||||||
async function deleteApplication(name: string, force: boolean) {
|
async function deleteApplication(name: string, force: boolean) {
|
||||||
const sure = confirm($t('application.confirm_to_delete', { name }));
|
const sure = confirm($t('application.confirm_to_delete', { name }));
|
||||||
@@ -292,7 +292,6 @@
|
|||||||
<a
|
<a
|
||||||
href={$isDeploymentEnabled ? `/applications/${id}/logs` : null}
|
href={$isDeploymentEnabled ? `/applications/${id}/logs` : null}
|
||||||
class="btn btn-sm text-sm gap-2"
|
class="btn btn-sm text-sm gap-2"
|
||||||
sveltekit:prefetch
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -363,7 +362,7 @@
|
|||||||
<button
|
<button
|
||||||
on:click={restartApplication}
|
on:click={restartApplication}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -383,7 +382,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
on:click={() => handleDeploySubmit(true)}
|
on:click={() => handleDeploySubmit(true)}
|
||||||
>
|
>
|
||||||
@@ -409,7 +408,7 @@
|
|||||||
<button
|
<button
|
||||||
on:click={stopApplication}
|
on:click={stopApplication}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -432,7 +431,7 @@
|
|||||||
<button
|
<button
|
||||||
on:click={stopApplication}
|
on:click={stopApplication}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -453,7 +452,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
on:click={() => handleDeploySubmit(true)}
|
on:click={() => handleDeploySubmit(true)}
|
||||||
>
|
>
|
||||||
{#if $status.application.overallStatus !== 'degraded'}
|
{#if $status.application.overallStatus !== 'degraded'}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
}
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
} finally {
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications(application);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
$status.application.overallStatus === 'degraded' ||
|
$status.application.overallStatus === 'degraded' ||
|
||||||
$status.application.overallStatus === 'healthy' ||
|
$status.application.overallStatus === 'healthy' ||
|
||||||
$status.application.initialLoading;
|
$status.application.initialLoading;
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications(application);
|
||||||
let statues: any = {};
|
let statues: any = {};
|
||||||
let loading = {
|
let loading = {
|
||||||
save: false,
|
save: false,
|
||||||
@@ -235,7 +235,7 @@
|
|||||||
}
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
} finally {
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications(application);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function handleSubmit(toast: boolean = true) {
|
async function handleSubmit(toast: boolean = true) {
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
}
|
}
|
||||||
await saveForm(id, application, baseDatabaseBranch, dockerComposeConfiguration);
|
await saveForm(id, application, baseDatabaseBranch, dockerComposeConfiguration);
|
||||||
setLocation(application, settings);
|
setLocation(application, settings);
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledApplications($appSession.isAdmin, application);
|
$isDeploymentEnabled = checkIfDeploymentEnabledApplications(application);
|
||||||
|
|
||||||
forceSave = false;
|
forceSave = false;
|
||||||
if (toast) {
|
if (toast) {
|
||||||
|
|||||||
@@ -96,7 +96,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Storage on:refresh={refreshStorage} isNew />
|
<Storage on:refresh={refreshStorage} isNew />
|
||||||
{}
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -76,11 +76,10 @@
|
|||||||
import { dev } from '$app/env';
|
import { dev } from '$app/env';
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
|
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service);
|
$isDeploymentEnabled = checkIfDeploymentEnabledServices(service);
|
||||||
|
|
||||||
let statusInterval: any;
|
let statusInterval: any;
|
||||||
|
|
||||||
|
|
||||||
async function deleteService() {
|
async function deleteService() {
|
||||||
const sure = confirm($t('application.confirm_to_delete', { name: service.name }));
|
const sure = confirm($t('application.confirm_to_delete', { name: service.name }));
|
||||||
if (sure) {
|
if (sure) {
|
||||||
@@ -291,7 +290,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{:else if $status.service.overallStatus === 'healthy'}
|
{:else if $status.service.overallStatus === 'healthy'}
|
||||||
<button
|
<button
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
on:click={() => restartService()}
|
on:click={() => restartService()}
|
||||||
>
|
>
|
||||||
@@ -317,7 +316,7 @@
|
|||||||
<button
|
<button
|
||||||
on:click={() => stopService(false)}
|
on:click={() => stopService(false)}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -338,10 +337,10 @@
|
|||||||
</button>
|
</button>
|
||||||
{:else if $status.service.overallStatus === 'degraded'}
|
{:else if $status.service.overallStatus === 'degraded'}
|
||||||
<button
|
<button
|
||||||
on:click={stopService}
|
on:click={() => stopService()}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -362,7 +361,7 @@
|
|||||||
{#if $status.service.overallStatus === 'degraded'}
|
{#if $status.service.overallStatus === 'degraded'}
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
on:click={() => restartService()}
|
on:click={() => restartService()}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -386,7 +385,7 @@
|
|||||||
{:else if $status.service.overallStatus === 'stopped'}
|
{:else if $status.service.overallStatus === 'stopped'}
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled || !$appSession.isAdmin}
|
||||||
on:click={() => startService()}
|
on:click={() => startService()}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
if (formData) service = await saveForm(formData, service);
|
if (formData) service = await saveForm(formData, service);
|
||||||
setLocation(service);
|
setLocation(service);
|
||||||
forceSave = false;
|
forceSave = false;
|
||||||
$isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service);
|
$isDeploymentEnabled = checkIfDeploymentEnabledServices(service);
|
||||||
return addToast({
|
return addToast({
|
||||||
message: 'Configuration saved.',
|
message: 'Configuration saved.',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
|
|||||||
Reference in New Issue
Block a user