-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from rstudio/dotnomad/create-destination-modal
Create add destination form page and flow
- Loading branch information
Showing
7 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,12 @@ | ||
// Copyright (C) 2023 by Posit Software, PBC. | ||
|
||
import { Account } from 'src/api'; | ||
|
||
export const calculateName = (account: Account) => { | ||
if (account.authType === 'token-key') { | ||
return account.accountName; | ||
} else if (account.authType === 'api-key') { | ||
return 'Using API Key'; | ||
} | ||
return ''; | ||
}; |
This file contains 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,82 @@ | ||
<!-- Copyright (C) 2023 by Posit Software, PBC. --> | ||
|
||
<template> | ||
<q-item | ||
tag="label" | ||
class="q-my-sm row items-center" | ||
:class="activeClass" | ||
> | ||
<q-item-section | ||
avatar | ||
top | ||
class="col-1" | ||
> | ||
<q-radio | ||
v-model="radioModel" | ||
name="account" | ||
:val="account.name" | ||
/> | ||
</q-item-section> | ||
<q-item-section | ||
class="q-ml-md" | ||
> | ||
<q-item-label> | ||
{{ account.name }} | ||
</q-item-label> | ||
<q-item-label | ||
caption | ||
class="account-caption" | ||
> | ||
Account: {{ calculateName(account) }} | ||
</q-item-label> | ||
<q-item-label | ||
caption | ||
class="account-url" | ||
> | ||
URL: {{ account.url }} | ||
</q-item-label> | ||
<q-item-label | ||
caption | ||
class="q-pt-sm account-credential" | ||
> | ||
Credentials managed by: {{ account.source }} | ||
</q-item-label> | ||
</q-item-section> | ||
</q-item> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { PropType, computed } from 'vue'; | ||
import { Account } from 'src/api'; | ||
import { calculateName } from 'src/utils/accounts'; | ||
|
||
const emit = defineEmits(['update:modelValue']); | ||
const props = defineProps({ | ||
modelValue: { | ||
type: String, | ||
required: true, | ||
}, | ||
account: { | ||
type: Object as PropType<Account>, | ||
required: true, | ||
}, | ||
}); | ||
|
||
const radioModel = computed({ | ||
get() { | ||
return props.modelValue; | ||
}, | ||
set(newValue) { | ||
emit('update:modelValue', newValue); | ||
} | ||
}); | ||
|
||
const selected = computed(() => { | ||
return props.account.name === props.modelValue; | ||
}); | ||
|
||
const activeClass = computed(() => { | ||
return selected.value ? 'account-item-selected' : 'account-item-not-selected'; | ||
}); | ||
|
||
</script> |
This file contains 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,80 @@ | ||
<!-- Copyright (C) 2023 by Posit Software, PBC. --> | ||
|
||
<template> | ||
<q-form | ||
class="q-gutter-md" | ||
@reset="resetForm" | ||
@submit.prevent="navigateToNewDestinationPage" | ||
> | ||
<div class="q-pa-sm"> | ||
<q-list> | ||
<AccountRadio | ||
v-for="account in accounts" | ||
:key="account.name" | ||
v-model="selectedAccountName" | ||
:account="account" | ||
/> | ||
</q-list> | ||
</div> | ||
|
||
<q-input | ||
v-model="contentId" | ||
label="Content ID" | ||
hint="Optional" | ||
/> | ||
|
||
<div class="flex row reverse"> | ||
<q-btn | ||
:to="destinationPage" | ||
type="submit" | ||
color="primary" | ||
label="Add" | ||
/> | ||
<q-btn | ||
type="reset" | ||
class="q-mr-sm" | ||
label="Cancel" | ||
@click="router.back()" | ||
/> | ||
</div> | ||
</q-form> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Account, useApi } from 'src/api'; | ||
import { computed, ref } from 'vue'; | ||
import { RouteLocationRaw, useRouter } from 'vue-router'; | ||
|
||
import AccountRadio from 'src/views/add-new-deployment/AccountRadio.vue'; | ||
|
||
const accounts = ref<Account[]>([]); | ||
const selectedAccountName = ref<string>(''); | ||
const contentId = ref<string>(''); | ||
|
||
const api = useApi(); | ||
const router = useRouter(); | ||
|
||
async function getAccounts() { | ||
const response = await api.accounts.getAll(); | ||
accounts.value = response.data.accounts; | ||
} | ||
|
||
function resetForm() { | ||
selectedAccountName.value = ''; | ||
contentId.value = ''; | ||
} | ||
|
||
const destinationPage = computed<RouteLocationRaw>(() => ({ | ||
name: 'newDeployment', | ||
params: { | ||
account: selectedAccountName.value, | ||
contentId: contentId.value, | ||
}, | ||
})); | ||
|
||
function navigateToNewDestinationPage() { | ||
router.push(destinationPage.value); | ||
} | ||
|
||
getAccounts(); | ||
</script> |
This file contains 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 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 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