Skip to content

Commit

Permalink
refactor(api): convert ACL routes to open-api
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashroch committed May 17, 2024
1 parent af4fe99 commit 99d389d
Show file tree
Hide file tree
Showing 99 changed files with 1,606 additions and 2,326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import type { PropType } from 'vue';
import { defineComponent } from 'vue';
import type { Character } from '@intake24/common/feedback';
import type { NutrientTypeEntry } from '@intake24/common/types/http/admin';
import type { NutrientTypeAttributes } from '@intake24/common/types/http/admin';
import { useEntry } from '@intake24/admin/stores';
import { CharacterSentiments } from '../partials';
Expand Down Expand Up @@ -67,7 +67,7 @@ export default defineComponent({
},
computed: {
nutrientTypes(): NutrientTypeEntry[] {
nutrientTypes(): NutrientTypeAttributes[] {
return useEntry().refs.nutrientTypes ?? [];
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import { computed, defineComponent } from 'vue';
import { PollsJobList, usePollsForJobs } from '@intake24/admin/components/jobs';
import { useHttp } from '@intake24/admin/services';
export default defineComponent({
name: 'RespondentsAuthUrlExport',
Expand All @@ -62,30 +63,30 @@ export default defineComponent({
},
setup(props) {
const http = useHttp();
const jobType = 'SurveyAuthUrlsExport';
const jobQuery = computed(() => ({ surveyId: props.surveyId }));
const { dialog, jobs, jobInProgress, startPolling } = usePollsForJobs(jobType, jobQuery);
return { dialog, jobs, jobInProgress, startPolling };
},
methods: {
close() {
this.dialog = false;
},
const close = () => {
dialog.value = false;
};
async submit() {
if (this.jobInProgress)
const submit = async () => {
if (jobInProgress.value)
return;
const { data } = await this.$http.post(
`admin/surveys/${this.surveyId}/respondents/export-auth-urls`,
const { data } = await http.post(
`admin/surveys/${props.surveyId}/tasks`,
{ type: jobType, params: { surveyId: props.surveyId } },
);
this.jobs.unshift(data);
await this.startPolling();
},
jobs.value.unshift(data);
await startPolling();
};
return { close, dialog, jobs, jobInProgress, startPolling, submit };
},
});
</script>
Expand Down
44 changes: 25 additions & 19 deletions apps/admin/src/views/surveys/respondents/respondents-upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<v-row>
<v-col cols="12" sm>
<v-file-input
v-model="form.file"
v-model="form.params.file"
:error-messages="form.errors.get('file')"
hide-details="auto"
:label="$t('common.file.csv')"
Expand Down Expand Up @@ -67,7 +67,11 @@ import { PollsJobList, usePollsForJobs } from '@intake24/admin/components/jobs';
import { createForm } from '@intake24/admin/util';
type RespondentsUploadForm = {
file: File | null;
type: 'SurveyRespondentsImport';
params: {
surveyId: string;
file: File | null;
};
};
export default defineComponent({
Expand All @@ -86,30 +90,32 @@ export default defineComponent({
const jobType = 'SurveyRespondentsImport';
const jobQuery = computed(() => ({ surveyId: props.surveyId }));
const form = reactive(createForm<RespondentsUploadForm>({ file: null }, { multipart: true }));
const form = reactive(createForm<RespondentsUploadForm>(
{
type: jobType,
params: { file: null, surveyId: props.surveyId },
},
{ multipart: true },
));
const { dialog, jobs, jobInProgress, startPolling } = usePollsForJobs(jobType, jobQuery);
return { form, dialog, jobs, jobInProgress, startPolling };
},
methods: {
close() {
this.form.reset();
this.dialog = false;
},
const close = () => {
form.reset();
dialog.value = false;
};
async submit() {
if (this.jobInProgress)
const submit = async () => {
if (jobInProgress.value)
return;
const job = await this.form.post<JobAttributes>(
`admin/surveys/${this.surveyId}/respondents/upload`,
);
const job = await form.post<JobAttributes>(`admin/surveys/${props.surveyId}/tasks`);
this.jobs.unshift(job);
await this.startPolling();
},
jobs.value.unshift(job);
await startPolling();
};
return { close, form, dialog, jobs, jobInProgress, startPolling, submit };
},
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/views/user/jobs/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default defineComponent({
mixins: [formMixin],
setup(_props) {
setup() {
const { i18n } = useI18n();
const jobTypeList = computed(() =>
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/views/users/read.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</tbody>
<tbody v-else>
<tr>
<td colspan="2">
<td colspan="3">
{{ $t('users.aliases.none') }}
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default () => {
});

it('should return 400 for missing input data', async () => {
await suite.sharedTests.assertInvalidInput('put', url, ['name', 'displayName']);
await suite.sharedTests.assertInvalidInput('put', url, ['displayName']);
});

it('should return 400 for invalid input data', async () => {
await suite.sharedTests.assertInvalidInput('put', url, ['name', 'displayName'], {
input: { name: '', displayName: '' },
await suite.sharedTests.assertInvalidInput('put', url, ['displayName', 'description'], {
input: { displayName: '', description: {} },
});
});

Expand Down
4 changes: 2 additions & 2 deletions apps/api/__tests__/integration/admin/roles/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default () => {
await suite.sharedTests.assertInvalidInput(
'post',
url,
['name', 'displayName', 'permissions'],
{ input: { name: '', displayName: '', permissions: [1, 'invalidId', 2] } },
['name', 'displayName', 'description', 'permissions.0', 'permissions.1', 'permissions.2'],
{ input: { name: '', displayName: '', description: {}, permissions: [1, 'invalidId', 2] } },
);
});

Expand Down
5 changes: 2 additions & 3 deletions apps/api/__tests__/integration/admin/roles/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default () => {

it('should return 400 for missing input data', async () => {
await suite.sharedTests.assertInvalidInput('put', url, [
'name',
'displayName',
'permissions',
]);
Expand All @@ -55,8 +54,8 @@ export default () => {
await suite.sharedTests.assertInvalidInput(
'put',
url,
['name', 'displayName', 'permissions'],
{ input: { name: '', displayName: '', permissions: [1, 'invalidId', 2] } },
['displayName', 'description', 'permissions.0', 'permissions.1', 'permissions.2'],
{ input: { displayName: '', description: [], permissions: [1, 'invalidId', 2] } },
);
});

Expand Down
10 changes: 2 additions & 8 deletions apps/api/__tests__/integration/admin/surveys/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@ export default () => {
describe('get /api/admin/surveys/:surveyId/respondents', respondents.browse);
describe('post /api/admin/surveys/:surveyId/respondents', respondents.store);
describe('get /api/admin/surveys/:surveyId/respondents/:surveyId', respondents.read);
describe('get /api/admin/surveys/:surveyId/respondents/:surveyId/edit', respondents.edit);
describe('patch /api/admin/surveys/:surveyId/respondents/:userId', respondents.update);
describe('delete /api/admin/surveys/:surveyId/respondents/:userId', respondents.destroy);
describe('post /api/admin/surveys/:surveyId/respondents/upload', respondents.upload);
describe(
'post /api/admin/surveys/:surveyId/respondents/export-auth-urls',
respondents.exportAuthUrls,
);
// describe('GET /api/admin/surveys/:surveyId/respondents/:userId', downloadFeedback);
// describe('POST /api/admin/surveys/:surveyId/respondents/:userId', emailFeedback);
// describe('GET /api/admin/surveys/:surveyId/respondents/:userId/feedback', downloadFeedback);
// describe('POST /api/admin/surveys/:surveyId/respondents/:userId/feedback', emailFeedback);

// Surveys submissions
describe('get /api/admin/surveys/:surveyId/submissions', submissions.browse);
Expand Down
115 changes: 0 additions & 115 deletions apps/api/__tests__/integration/admin/surveys/respondents/edit.test.ts

This file was deleted.

0 comments on commit 99d389d

Please sign in to comment.