Skip to content

Commit

Permalink
Desktop-View: Prefilling System-URL in Guided Setup.
Browse files Browse the repository at this point in the history
Co-authored-by: Mantas Masalskis <mm@zammad.com>
Co-authored-by: Dominik Klein <dk@zammad.com>
  • Loading branch information
mantas and dominikklein committed Jan 16, 2024
1 parent e0ec054 commit 347b352
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
Expand Up @@ -64,7 +64,10 @@ describe('guided setup system information', () => {
expect(urlField).toBeInTheDocument()
expect(logoField).toBeInTheDocument()

expect(urlField).toHaveValue('http://localhost:3000')

await view.events.type(organizationField, "Don't be Evil Inc")
await view.events.clear(urlField)
await view.events.type(urlField, 'https://example.com')

const testValue =
Expand Down
Expand Up @@ -3,3 +3,11 @@
export interface SystemSetupManual {
setTitle: (title: string) => void
}

export interface SystemInformationData {
organization: string
logo: string
url: string
localeDefault: string
timezoneDefault: string
}
Expand Up @@ -4,21 +4,28 @@
import { shallowRef, computed, reactive } from 'vue'
import { useRouter } from 'vue-router'
import type { FormSubmitData } from '#shared/components/Form/types.ts'
import type {
FormSubmitData,
FormValues,
} from '#shared/components/Form/types.ts'
import Form from '#shared/components/Form/Form.vue'
import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
import { useApplicationStore } from '#shared/stores/application.ts'
import { useLogoUrl } from '#shared/composables/useLogoUrl.ts'
import type { SystemInformationData } from '../../types/setup-manual.ts'
import { useSystemSetupManual } from '../../composables/useSystemSetupManual.ts'
import GuidedSetupActionFooter from '../../components/GuidedSetupActionFooter.vue'
import { useGuidedSetupSetSystemInformationMutation } from '../../graphql/mutations/setSystemInformation.api.ts'
const router = useRouter()
const application = useApplicationStore()
const { logoUrl } = useLogoUrl()
const { setTitle } = useSystemSetupManual()
setTitle(__('System Information'))
const systemInformationSchema = [
{
isLayout: true,
Expand Down Expand Up @@ -55,26 +62,29 @@ const systemInformationSchema = [
},
]
setTitle(__('System Information'))
const getInitialInstanceUrl = () => {
const { fqdn } = application.config
interface SystemInformationData {
organization: string
logo: string
url: string
localeDefault: string
timezoneDefault: string
if (!fqdn || fqdn === 'zammad.example.com') {
return window.location.origin
}
return `${application.config.http_type}://${fqdn}`
}
const initialValues: FormValues = {
organization: application.config.organization,
url: getInitialInstanceUrl(),
}
const form = shallowRef()
const application = useApplicationStore()
const isSystemOnlineService = computed(
() => application.config.system_online_service,
)
const schemaData = reactive({
isSystemOnlineService,
logoPlaceholderUrl: logoUrl,
})
const dateTimeFormatOptions = Intl?.DateTimeFormat
Expand Down Expand Up @@ -102,6 +112,7 @@ const setSystemInformation = async (formData: SystemInformationData) => {
.then(() => {
router.push('/guided-setup/manual/email-notification')
})
.catch(() => {})
}
</script>

Expand All @@ -112,6 +123,7 @@ const setSystemInformation = async (formData: SystemInformationData) => {
form-class="mb-2.5"
:schema="systemInformationSchema"
:schema-data="schemaData"
:initial-values="initialValues"
@submit="
setSystemInformation($event as FormSubmitData<SystemInformationData>)
"
Expand Down

0 comments on commit 347b352

Please sign in to comment.