continue working on default credentials
This commit is contained in:
@ -6,25 +6,29 @@
|
||||
import ErrorAlert from '../../ui/ErrorAlert.svelte';
|
||||
import Icon from '../../ui/Icon.svelte';
|
||||
|
||||
export let record
|
||||
export let record;
|
||||
export let defaults;
|
||||
|
||||
import PassphraseInput from '../../ui/PassphraseInput.svelte';
|
||||
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
// if record.credential is blank when component is first instantiated, this is
|
||||
// a newly-added credential, so show details so that data can be filled out
|
||||
let showDetails = record.isNew ? true : false;
|
||||
|
||||
let localName = name;
|
||||
let local = JSON.parse(JSON.stringify(record));
|
||||
$: isModified = JSON.stringify(local) !== JSON.stringify(record);
|
||||
|
||||
// explicitly subscribe to updates to `default`, so that we can update
|
||||
// our local copy even if the component hasn't been recreated
|
||||
// (sadly we can't use a reactive binding because reasons I guess)
|
||||
defaults.subscribe(d => local.is_default = local.id === d[local.credential.type])
|
||||
|
||||
let error, alert;
|
||||
async function saveCredential() {
|
||||
try {
|
||||
await invoke('save_credential', {cred: local});
|
||||
await invoke('save_credential', {record: local});
|
||||
dispatch('update');
|
||||
showDetails = false;
|
||||
}
|
||||
@ -34,11 +38,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let confirmDelete;
|
||||
let deleteModal;
|
||||
function conditionalDelete() {
|
||||
if (!record.isNew) {
|
||||
confirmDelete.showModal();
|
||||
deleteModal.showModal();
|
||||
}
|
||||
else {
|
||||
deleteCredential();
|
||||
@ -139,7 +142,7 @@
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
<dialog bind:this={confirmDelete} class="modal">
|
||||
<dialog bind:this={deleteModal} class="modal">
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">Delete AWS credential "{record.name}"?</h3>
|
||||
<div class="modal-action">
|
||||
|
Reference in New Issue
Block a user