fixup! refactor(federatedfilesharing): migrate to Typescript and Vue 3

Ferdinand Thiessen 2025-12-10 15:55:28 +07:00
parent 045d9e4e1b
commit 34f48e7a02
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
5 changed files with 28 additions and 24 deletions

@ -20,7 +20,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{
(e: 'close', state: boolean, password?: string): void
close: [state: boolean, password?: string]
}>()
const password = ref('')
@ -56,16 +56,13 @@ const buttons = computed<INcDialogButtons>(() => [
<NcPasswordField
v-if="passwordRequired"
v-model="password"
class="remote-share-dialog__password"
:class="$style.remoteShareDialog__password"
:label="t('federatedfilesharing', 'Remote share password')" />
</NcDialog>
</template>
<style scoped lang="scss">
.remote-share-dialog {
&__password {
margin-block: 1em .5em;
}
<style module>
.remoteShareDialog__password {
margin-block: 1em .5em;
}
</style>

@ -47,7 +47,7 @@ describe('federatedfilesharing: dialog service', () => {
}
}
expect(await promise).toBe('')
await expect(promise).resolves.toBe('')
})
it('rejects if cancelled', async () => {
@ -60,6 +60,6 @@ describe('federatedfilesharing: dialog service', () => {
}
}
expect(async () => await promise).rejects.toThrow()
await expect(promise).rejects.toThrow()
})
})

@ -14,23 +14,24 @@ import RemoteShareDialog from '../components/RemoteShareDialog.vue'
* @param remote The remote address
* @param passwordRequired True if the share is password protected
*/
export function showRemoteShareDialog(
export async function showRemoteShareDialog(
name: string,
owner: string,
remote: string,
passwordRequired = false,
): Promise<string | void> {
const { promise, reject, resolve } = Promise.withResolvers<string | void>()
spawnDialog(RemoteShareDialog, { name, owner, remote, passwordRequired }, (status, password) => {
if (passwordRequired && status) {
resolve(password as string)
} else if (status) {
resolve(undefined)
} else {
reject()
}
const [status, password] = await spawnDialog(RemoteShareDialog, {
name,
owner,
remote,
passwordRequired,
})
return promise
if (passwordRequired && status) {
return password as string
} else if (status) {
return
} else {
throw new Error('Dialog was cancelled')
}
}

@ -3,7 +3,7 @@
"include": ["./apps/**/*.ts", "./apps/**/*.vue", "./core/**/*.ts", "./core/**/*.vue", "./*.d.ts"],
"exclude": ["./**/*.cy.ts"],
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"lib": ["DOM", "DOM.Iterable", "DOM.AsyncIterable", "ESNext"],
"outDir": "./dist/",
"target": "ESNext",
"module": "ESNext",

@ -3,5 +3,11 @@
* SPDX-License-Identifier: CC0-1.0
*/
import { defineConfig } from 'vitest/config'
// stub - for the moment see build/frontend/vitest.config.ts
export default {}
export default defineConfig({
test: {
projects: ['build/frontend*'],
},
})