Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { storeToRefs } from 'pinia';
import authAxios from '@/shared/axios/auth-axios';
import type { Contributor, CreateContributorPayload } from '@/modules/contributor/types/Contributor';
import type {
Contributor,
CreateContributorPayload,
} from '@/modules/contributor/types/Contributor';
import { useLfSegmentsStore } from '@/modules/lf/segments/store';

const getSegments = () => {
Expand All @@ -12,22 +15,17 @@ const getSegments = () => {

export class ContributorApiService {
static async find(id: string, segments: string[]): Promise<Contributor> {
const response = await authAxios.get(
`/member/${id}`,
{
params: {
segments,
},
const response = await authAxios.get(`/member/${id}`, {
params: {
segments,
},
);
});

return response.data;
}

static async mergeSuggestions(limit: number, offset: number, query: any, segments: string[]) {
const resolvedSegments = segments.length
? segments
: (getSegments() ?? []);
const resolvedSegments = segments.length ? segments : (getSegments() ?? []);

const data = {
limit,
Expand All @@ -37,31 +35,23 @@ export class ContributorApiService {
...query,
};

return authAxios.post(
'/membersToMerge',
data,
)
.then(({ data }) => Promise.resolve(data));
return authAxios.post('/membersToMerge', data).then(({ data }) => Promise.resolve(data));
}

static async update(id: string, data: Partial<Contributor>) {
return authAxios.put(
`/member/${id}`,
{
return authAxios
.put(`/member/${id}`, {
...data,
segments: getSegments(),
},
).then(({ data }) => Promise.resolve(data));
})
.then(({ data }) => Promise.resolve(data));
}

static async create(data: CreateContributorPayload, segments: string[]) {
const response = await authAxios.post(
'/member',
{
...data,
segments,
},
);
const response = await authAxios.post('/member', {
...data,
segments,
});

return response.data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const props = defineProps<{
lockRelation?: boolean,
}>();

const emit = defineEmits<{(e: 'update:modelValue', value: Filter), (e: 'fetch', value: FilterQuery), }>();
const emit = defineEmits<{(e: 'update:modelValue', value: Filter): void, (e: 'fetch', value: FilterQuery): void, }>();

const { trackEvent } = useProductTracking();
const router = useRouter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const props = defineProps<{
modelValue: string[]
}>();

const emit = defineEmits<{(e: 'update:modelValue', value: string[]), (e: 'open', value: string)}>();
const emit = defineEmits<{(e: 'update:modelValue', value: string[]): void, (e: 'open', value: string): void}>();

const open = ref<boolean>(false);
const search = ref<string>('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import LfIcon from '@/ui-kit/icon/Icon.vue';
import LfButton from '@/ui-kit/button/Button.vue';

const props = defineProps<{
modelValue: string,
modelValue: Record<string, unknown>,
open: string,
config: FilterConfig,
hideRemove?: boolean,
Expand Down Expand Up @@ -99,9 +99,8 @@ const isOpen = computed({
});

const getComponent = computed(() => {
const { type, component } = props.config;
if (type === FilterConfigType.CUSTOM) {
return component;
if (props.config.type === FilterConfigType.CUSTOM) {
return props.config.component;
}
return filterComponentByType[props.config.type];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const props = defineProps<{
placeholder?: string,
}>();

const emit = defineEmits<{(e: 'update:modelValue', value: string)}>();
const emit = defineEmits<{(e: 'update:modelValue', value: string): void}>();

const model = ref('');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ const timePicker = computed({

const isCustom = computed(() => !(typeof form.value.value === 'string' && timePickerOptionValues.includes(form.value.value)));

const checkIfBetween = (operator: string) => [FilterDateOperator.BETWEEN, FilterDateOperator.NOT_BETWEEN].includes(operator);
const checkIfBetween = (operator: FilterDateOperator) => [FilterDateOperator.BETWEEN, FilterDateOperator.NOT_BETWEEN].includes(operator);

const isBetween = computed(() => checkIfBetween(form.value.operator));

const operators = computed(() => {
if (props.datepickerType === 'year') {
return dateFilterOperators.filter((o) => !checkIfBetween(o.value));
return dateFilterOperators.filter((o) => !checkIfBetween(o.value as FilterDateOperator));
}
return dateFilterOperators;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ export const dateApiFilterRenderer = (property: string, { value, operator }: Dat
},
};
} else if ([FilterDateOperator.EQ, FilterDateOperator.NE].includes(operator)) {
// shortcut: these casts hide an array mappedValue, as on main. revisit: when filter values are typed per operator.
filter = {
[property]: {
between: [
dateHelper.utc(mappedValue).startOf('day').toISOString(),
dateHelper.utc(mappedValue).endOf('day').toISOString(),
dateHelper.utc(mappedValue as string).startOf('day').toISOString(),
dateHelper.utc(mappedValue as string).endOf('day').toISOString(),
],
},
};
} else {
let parsedValue = dateHelper.utc(mappedValue).startOf('day').toISOString();
// shortcut: these casts hide an array mappedValue, as on main. revisit: when filter values are typed per operator.
let parsedValue = dateHelper.utc(mappedValue as string).startOf('day').toISOString();

if (['last24h'].includes(value as string)) {
parsedValue = mappedValue as string;
} else if ([FilterDateOperator.GT, FilterDateOperator.GTE].includes(operator)) {
parsedValue = dateHelper.utc(mappedValue).endOf('day').toISOString();
parsedValue = dateHelper.utc(mappedValue as string).endOf('day').toISOString();
}

filter = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export const numberApiFilterRenderer = (
{
value, valueTo, operator,
}: NumberFilterValue,
parse: (value: number) => number,
parse?: (value: number) => number,
): any[] => {
const includeFilter = ![FilterNumberOperator.NE, FilterNumberOperator.NOT_BETWEEN].includes(operator);
let filterOperator = operator;
const parsedValue = parse ? parse(value) : +value;
const parsedValueTo = parse ? parse(valueTo) : +valueTo;
const parsedValue = parse ? parse(Number(value)) : Number(value);
const parsedValueTo = parse ? parse(Number(valueTo)) : Number(valueTo);

const filterValue = [FilterNumberOperator.BETWEEN, FilterNumberOperator.NOT_BETWEEN].includes(operator)
? [parsedValue, parsedValueTo!]
? [parsedValue, parsedValueTo]
: parsedValue;

if (operator === FilterNumberOperator.NE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
multiSelectApiFilterRenderer,
} from './apiFilterRenderer/multiselect.filter.renderer';

export const apiFilterRendererByType: Record<FilterConfigType, (property: string, value: any) => any[]> = {
export const apiFilterRendererByType: Record<FilterConfigType, (property: string, value: any, parse?: (value: number) => number) => any[]> = {
[FilterConfigType.BOOLEAN]: booleanApiFilterRenderer,
[FilterConfigType.NUMBER]: numberApiFilterRenderer,
[FilterConfigType.DATE]: dateApiFilterRenderer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
FilterDateOperator,
} from '@/shared/modules/filters/config/constants/date.constants';

const operatorText: Record<FilterDateOperator, string> = {
// shortcut: gte has no label and throws below (legacy). revisit: when gte is offered in the UI.
const operatorText: Partial<Record<FilterDateOperator, string>> = {
[FilterDateOperator.EQ]: '',
[FilterDateOperator.NE]: 'is not',
[FilterDateOperator.LT]: 'before',
Expand All @@ -16,7 +17,7 @@ const operatorText: Record<FilterDateOperator, string> = {
export const dateItemLabelRenderer = (property: string, { value, operator }: DateFilterValue): string => {
const dateOption = dateFilterTimePickerOptions.find((option) => option.value === value && option.operator === operator);
let valueText = `${value}`;
let operatorTextDisplay = operatorText[operator].length > 0 ? `${operatorText[operator]} ` : '';
let operatorTextDisplay = operatorText[operator]!.length > 0 ? `${operatorText[operator]} ` : '';

if (dateOption) {
valueText = dateOption.label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const props = defineProps<{
identities: {
[key: string]: {
handle: string;
link: string;
link: string | null;
verified: boolean;
}[];
};
limit?: number;
Expand All @@ -82,7 +83,8 @@ const parsedIdentities = computed(() => {
acc: {
[key: string]: {
handle: string;
link: string;
link: string | null;
verified: boolean;
}[];
},
k,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default ({
}

return acc;
}, {} as Record<Platform, { handle: string; link: string; verified: boolean }[]>);
}, {} as Record<string, { handle: string; link: string | null; verified: boolean }[]>);

const getAffiliatedProfiles = (): {
handle: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { ErrorMessage } from '../../types/MemberMessage';

export default ({ error }: ErrorMessage) => {
ToastStore.closeAll();
if (error.response.status === 404) {
// shortcut: assumes the merge error carries a response, as on main. revisit: when merge errors are typed.
if (error.response!.status === 404) {
ToastStore.success('Profiles already merged or deleted', {
message: `Sorry, the profiles you are trying to merge might have already been merged or deleted.
Please refresh to see the updated information.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ApiErrorMessage } from '../../types/OrganizationMessage';
export default ({ error }: ApiErrorMessage) => {
ToastStore.closeAll();

if (error.response.status === 404) {
// shortcut: assumes the merge error carries a response, as on main. revisit: when merge errors are typed.
if (error.response!.status === 404) {
ToastStore.success('Organizations already merged or deleted', {
message: `Sorry, the organizations you are trying to merge might have already been merged or deleted.
Please refresh to see the updated information.`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router';
import { ToastStore } from '@/shared/message/notification';
import type { LfPermission } from '@/shared/modules/permissions/types/Permissions';
import usePermissions from '@/shared/modules/permissions/helpers/usePermissions';
import { useAuthStore } from '@/modules/auth/store/auth.store';

export const PermissionGuard = (permission: LfPermission) => async (to, from, next) => {
export const PermissionGuard = (permission: LfPermission) => async (
to: RouteLocationNormalized,
from: RouteLocationNormalized,
next: NavigationGuardNext,
) => {
// Ensure user is loaded
const { ensureLoaded } = useAuthStore();
await ensureLoaded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const props = withDefaults(
size?: string;
identities?: {
handle: string;
link: string;
link: string | null;
}[];
asLink?: boolean;
asSvg?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ const submit = () => {
};

loading.value = true;
// shortcut: the modal only submits with an entity set, as on main. revisit: when the entity prop is required.
return authAxios.post(
`${getConfig.value.url(entity.value.id)}`,
`${getConfig.value.url(entity.value!.id)}`,
data,
)
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ContributorAffiliation } from '@/modules/contributor/types/Contributor';
import type { ReportDataTypeConfig } from '@/shared/modules/report-issue/config';
import ProjectAffiliation from './type-project-affiliation.vue';

export const projectAffiliation: ReportDataTypeConfig = {
description: (attribute: any) => {
const affiliations = Object.values(attribute.affiliations).flat();
const affiliations = Object.values<ContributorAffiliation[]>(attribute.affiliations).flat();

const list: string[] = [
`Project: ${attribute.name}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const props = defineProps<{
filters: Record<string, FilterConfig>,
customFilters?: Record<string, FilterConfig>,
placement: string,
view: SavedView | SavedViewCreate | null,
view: Partial<SavedView> | null,
}>();

const emit = defineEmits<{(e: 'update:modelValue', value: boolean): any,
Expand Down Expand Up @@ -346,15 +346,16 @@ const removeFilter = (key: any) => {
const fillForm = () => {
if (props.view) {
form.shared = hasPermission(LfPermission.customViewsTenantManage) ? props.view.visibility === 'tenant' : false;
form.name = props.view.name;
// shortcut: an edited view always has a name and config, as on main. revisit: when create and edit views get separate types.
form.name = props.view.name!;
const {
relation, order, settings, search, ...restFilters
} = props.view.config;
} = props.view.config!;
form.relation = relation;
form.sorting.prop = order.prop;
form.sorting.order = order.order;
form.filters = { ...restFilters } || {};
form.settings = { ...settings } || {};
form.filters = { ...restFilters };
form.settings = { ...settings };
filterList.value = Object.keys(restFilters);
formSnapshot();
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/typecheck-baseline.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "errors": 121 }
{ "errors": 88 }
Loading