Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 253
FEAT Enable/Disable all services - UI#365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
815b7f2
restructure
lohanidamodar 646ace7
pause resume
lohanidamodar 73a1a4c
paused tag
lohanidamodar f772440
pause with dialog
lohanidamodar 4072de0
typo and icon
lohanidamodar c2c50a5
fix resume also has dialog
lohanidamodar 401403b
enable disable all services
lohanidamodar d806249
fix white-space
lohanidamodar 3ffd2be
fix whitespace
lohanidamodar b9726aa
button list
lohanidamodar 42b60bf
service status
lohanidamodar 554a01c
Merge remote-tracking branch 'origin/main' into feat-pause-project
lohanidamodar 3020349
update SDK
lohanidamodar 826d2d1
Merge remote-tracking branch 'origin/main' into feat-pause-project
lohanidamodar ecebcf0
fix typo
lohanidamodar b6a8e6a
remove unnecessary code
lohanidamodar 5061cb3
fix
lohanidamodar 543ca2c
Merge branch 'main' into feat-pause-project
TorstenDittmann 183d5f3
fix: lint issues
TorstenDittmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18 src/routes/console/organization-[organization]/+page.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,8 @@ | ||
| import { base } from '$app/paths'; | ||
| import { page } from '$app/stores'; | ||
| import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; | ||
| import EnableAllServices from './enableAllServices.svelte'; | ||
| import DisableAllServices from './disableAllServices.svelte'; | ||
| import Transfer from './transferProject.svelte'; | ||
| let name: string = null; | ||
| @@ -30,6 +32,8 @@ | ||
| let showTransfer = false; | ||
| const endpoint = sdk.forConsole.client.config.endpoint; | ||
| const projectId = $page.params.project; | ||
| let showDisableAll = false; | ||
| let showEnableAll = false; | ||
| onMount(async () => { | ||
| name ??= $project.name; | ||
| @@ -54,6 +58,50 @@ | ||
| } | ||
| } | ||
| async function toggleAllServices(status: boolean) { | ||
| if (status && !showEnableAll) { | ||
| showEnableAll = true; | ||
| return; | ||
| } | ||
| if (!status && !showDisableAll) { | ||
| showDisableAll = true; | ||
| return; | ||
| } | ||
| try { | ||
| const path = '/projects/' + $project.$id + '/service/all'; | ||
| await sdk.forConsole.client.call( | ||
| 'PATCH', | ||
| new URL(sdk.forConsole.client.config.endpoint + path), | ||
| { | ||
| 'content-type': 'application/json' | ||
| }, | ||
| { | ||
| status: status | ||
| } | ||
| ); | ||
| invalidate(Dependencies.PROJECT); | ||
| addNotification({ | ||
| type: 'success', | ||
| message: | ||
| 'All services for ' + | ||
| $project.name + | ||
| ' has been ' + | ||
| (status ? 'enabled.' : 'disabled.') | ||
| }); | ||
| trackEvent(Submit.ProjectService); | ||
| } catch (error) { | ||
| addNotification({ | ||
| type: 'error', | ||
| message: error.message | ||
| }); | ||
| trackError(error, Submit.ProjectService); | ||
| } finally { | ||
| showDisableAll = false; | ||
| showEnableAll = false; | ||
| } | ||
TorstenDittmann marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| async function serviceUpdate(service: Service) { | ||
| try { | ||
| await sdk.forConsole.projects.updateServiceStatus( | ||
| @@ -132,8 +180,18 @@ | ||
| services are not accessible to client SDKs but remain accessible to server SDKs. | ||
| </p> | ||
| <svelte:fragment slot="aside"> | ||
| <ul class="buttons-list u-main-end"> | ||
| <li class="buttons-list-item"> | ||
| <Button text={true} on:click={() => toggleAllServices(true)} | ||
| >Enable all</Button> | ||
| </li> | ||
| <li class="buttons-list-item"> | ||
| <Button text={true} on:click={() => toggleAllServices(false)} | ||
| >Disable all</Button> | ||
| </li> | ||
| </ul> | ||
| <FormList> | ||
| <form class="form"> | ||
| <form class="form card-separator"> | ||
| <ul class="form-list is-multiple"> | ||
| {#each $services.list as service} | ||
| <InputSwitch | ||
| @@ -198,6 +256,8 @@ | ||
| </Container> | ||
| <Delete bind:showDelete /> | ||
| <DisableAllServices handleDisableAll={() => toggleAllServices(false)} bind:show={showDisableAll} /> | ||
| <EnableAllServices handleEnableAll={() => toggleAllServices(true)} bind:show={showEnableAll} /> | ||
| {#if teamId} | ||
| <Transfer | ||
| bind:teamId | ||
19 changes: 19 additions & 0 deletions
19 src/routes/console/project-[project]/settings/disableAllServices.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <script lang="ts"> | ||
| import { Modal } from '$lib/components'; | ||
| import { Button } from '$lib/elements/forms'; | ||
| export let show = false; | ||
| export let handleDisableAll; | ||
| </script> | ||
| <Modal icon="exclamation" state="warning" bind:show onSubmit={handleDisableAll}> | ||
| <svelte:fragment slot="header">Disable all services</svelte:fragment> | ||
| <p class="text" data-private> | ||
| Are you sure you want to disable all services? This will disable API requests to your | ||
| project. | ||
| </p> | ||
| <svelte:fragment slot="footer"> | ||
| <Button text on:click={() => (show = false)}>Cancel</Button> | ||
| <Button secondary submit>Disable All</Button> | ||
| </svelte:fragment> | ||
| </Modal> |
16 changes: 16 additions & 0 deletions
16 src/routes/console/project-[project]/settings/enableAllServices.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <script lang="ts"> | ||
| import { Modal } from '$lib/components'; | ||
| import { Button } from '$lib/elements/forms'; | ||
| export let show = false; | ||
| export let handleEnableAll; | ||
| </script> | ||
| <Modal bind:show onSubmit={handleEnableAll}> | ||
| <svelte:fragment slot="header">Enable all services</svelte:fragment> | ||
| <p class="text" data-private>All project services will be enabled.</p> | ||
| <svelte:fragment slot="footer"> | ||
| <Button text on:click={() => (show = false)}>Cancel</Button> | ||
| <Button secondary submit>Enable all</Button> | ||
| </svelte:fragment> | ||
| </Modal> |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.