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
4 changes: 1 addition & 3 deletions lib/angular-ui/src/lib/atoms/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-card',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class CardComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-icon-btn',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class IconBtnComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-check-circle-icon',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class CheckCircleIconComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-dash-circle-icon',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DashCircleIconComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-profile-icon',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class ProfileIconComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ type TouchedFn = () => void;
multi: true,
},
],
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class RadioInputComponent implements ControlValueAccessor {
private notifyChange: ChangeFn = () => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-text-btn',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class TextBtnComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-collapsible',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class CollapsibleComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-copy-to-clipboard',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class CopyToClipboardComponent {
public readonly value =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-dropdown-btn-menu-item',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DropdownBtnMenuItemComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-dropdown-link-menu-item',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DropdownLinkMenuItemComponent {
public readonly routerLink =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-dropdown-menu',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DropdownMenuComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { DefineCustomElement } from '../../../define-custom-element';
selector: 'cg-dropdown-trigger',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DropdownTriggerComponent {
public readonly isIconBtn =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { DefineCustomElement } from '../../define-custom-element';
selector: 'cg-dropdown',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class DropdownComponent {
public readonly anchorAlign = input<HTMLCgDropdownElement['anchorAlign']>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ type ImagesSelectedEvent = CustomEvent<
selector: 'cg-image-uploader-btn',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class ImageUploaderBtnComponent {
@HostListener('imagesSelected', ['$event'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { defineCustomElement } from '@cg/ui/dist/components/cg-footer';
selector: 'cg-footer',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class FooterComponent {
public readonly links = input.required<HTMLCgFooterElement['links']>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {
selector: 'cg-navbar',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class NavbarComponent {
public readonly homeUrl = input.required<HTMLCgNavbarElement['homeUrl']>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export { NavLink, NavLinkCategory } from '@cg/ui/dist/types';
selector: 'cg-sidenav',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-content />
`,
template: `<ng-content />`,
})
export class SidenavComponent {
public readonly homeUrl = input.required<HTMLCgSidenavElement['homeUrl']>();
Expand Down
2 changes: 1 addition & 1 deletion prettier.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
htmlWhitespaceSensitivity: 'ignore',
htmlWhitespaceSensitivity: 'strict',
plugins: ['prettier-plugin-astro'],
overrides: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function mapGetProposalReviewCommitResponse(
): GetProposalReviewCommitResponse {
return {
id: res.id,
listId: res.id,
proposalReviewId: res.proposal_review_commit.proposal_review_id,
userId: res.proposal_review_commit.user_id,
createdAt: fromCandidDate(res.proposal_review_commit.created_at),
Expand All @@ -74,17 +73,17 @@ export function mapGetProposalReviewCommitResponse(
function mapReviewCommitRequestDetails(
req: ReviewCommitDetails,
): ReviewCommitState {
if (req.reviewed === false) {
return { not_reviewed: null };
if (req.reviewed) {
return {
reviewed: {
highlights: req.highlights,
comment: toCandidOpt(req.comment),
matches_description: toCandidOpt(req.matchesDescription),
},
};
}

return {
reviewed: {
highlights: req.highlights,
comment: toCandidOpt(req.comment),
matches_description: toCandidOpt(req.matchesDescription),
},
};
return { not_reviewed: null };
}

function mapReviewCommitResponseDetails(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export interface DeleteProposalReviewCommitRequest {
}

export interface GetProposalReviewCommitResponse {
id: string | null;
listId: string;
id: string;
proposalReviewId: string;
userId: string;
createdAt: Date;
lastUpdatedAt: Date | null;
commitSha: string;
commitSha: string | null;
details: ReviewCommitDetails;
}

Expand All @@ -36,5 +35,5 @@ export interface ReviewedCommitDetails {
}

export interface NotReviewedCommitDetails {
reviewed: false;
reviewed: false | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('CommitReviewApiService', () => {
proposal_review_id: 'proposalReviewId',
user_id: 'userId',
commit_sha: 'commitSha',
created_at: new Date(2024, 1, 1, 0, 0, 0, 0).getTime().toString(),
created_at: new Date(2024, 1, 1, 0, 0, 0, 0).toISOString(),
last_updated_at: [],
state: {
reviewed: {
Expand All @@ -80,7 +80,6 @@ describe('CommitReviewApiService', () => {
};
const commonResponse: GetProposalReviewCommitResponse = {
id: 'id',
listId: 'id',
userId: 'userId',
commitSha: 'commitSha',
proposalReviewId: 'proposalReviewId',
Expand Down
35 changes: 30 additions & 5 deletions src/frontend/src/app/core/api/review/review-api.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
GetProposalReviewRequest as GetProposalReviewApiRequest,
GetMyProposalReviewRequest as GetMyProposalReviewApiRequest,
ProposalReviewStatus as ProposalReviewStatusApi,
ProposalVote as ApiProposalVote,
} from '@cg/backend';
import {
GetProposalReviewResponse,
Expand All @@ -23,7 +24,6 @@ import {
ListProposalReviewsRequest,
GetProposalReviewRequest,
ProposalReviewStatus,
ProposalReviewVote,
} from './review-api.model';

export function mapCreateProposalReviewRequest(
Expand All @@ -34,7 +34,7 @@ export function mapCreateProposalReviewRequest(
review_duration_mins: toCandidOpt(req.reviewDurationMins),
summary: toCandidOpt(req.summary),
build_reproduced: toCandidOpt(req.buildReproduced),
vote: [],
vote: mapProposalVoteRequest(req.vote),
};
}

Expand All @@ -48,7 +48,7 @@ export function mapUpdateProposalReviewRequest(
review_duration_mins: toCandidOpt(req.reviewDurationMins),
summary: toCandidOpt(req.summary),
build_reproduced: toCandidOpt(req.buildReproduced),
vote: [],
vote: mapProposalVoteRequest(req.vote),
};
}

Expand Down Expand Up @@ -86,8 +86,7 @@ export function mapGetProposalReviewResponse(
id: res.id,
proposalId: review.proposal_id,
userId: review.user_id,
// [TODO] - connect with API once it's implemented
vote: ProposalReviewVote.NoVote,
vote: mapProposalVoteResponse(review.vote),
createdAt: fromCandidDate(review.created_at),
lastUpdatedAt: fromCandidOptDate(review.last_updated_at),
status: mapProposalReviewStatusResponse(review.status),
Expand All @@ -112,6 +111,32 @@ function mapProposalReviewStatusResponse(
return ProposalReviewStatus.Draft;
}

function mapProposalVoteRequest(vote?: boolean | null): [] | [ApiProposalVote] {
switch (vote) {
case true: {
return [{ yes: null }];
}
case false: {
return [{ no: null }];
}
default: {
return [];
}
}
}

function mapProposalVoteResponse(vote: ApiProposalVote): boolean | null {
if ('yes' in vote) {
return true;
}

if ('no' in vote) {
return false;
}

return null;
}

function getReviewImages(): ImageSet[] {
return [
{
Expand Down
19 changes: 10 additions & 9 deletions src/frontend/src/app/core/api/review/review-api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import { ImageSet } from '@cg/angular-ui';

export interface CreateProposalReviewRequest {
proposalId: string;
summary: string | null;
reviewDurationMins: number | null;
buildReproduced: boolean | null;
reproducedBuildImageId: string | null;
summary?: string | null;
reviewDurationMins?: number | null;
buildReproduced?: boolean | null;
vote?: boolean | null;
}

export interface UpdateProposalReviewRequest {
proposalId: string;
reviewDurationMins: number | null;
summary: string | null;
buildReproduced: boolean | null;
reviewDurationMins?: number | null;
summary?: string | null;
buildReproduced?: boolean | null;
vote?: boolean | null;
}

export interface ListProposalReviewsRequest {
Expand All @@ -33,7 +34,7 @@ export interface GetProposalReviewResponse {
id: string;
proposalId: string;
userId: string;
vote: ProposalReviewVote;
vote: boolean | null;
createdAt: Date;
lastUpdatedAt: Date | null;
status: ProposalReviewStatus;
Expand Down Expand Up @@ -63,7 +64,7 @@ export interface ProposalCommitReviewHighlight {
export interface ProposalCommitReviewSummary {
proposalId: string;
commitId: string;
commitSha: string;
commitSha: string | null;
highlights: ProposalCommitReviewHighlight[];
totalReviewers: number;
reviewedCount: number;
Expand Down
Loading
Loading