Skip to content

Commit

Permalink
Update types and descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Mar 18, 2024
1 parent 0efc68a commit fdd7517
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 40 deletions.
3 changes: 2 additions & 1 deletion web/app/adapters/jira-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import DS from "ember-data";
import ApplicationAdapter from "./application";
import RSVP from "rsvp";
import ModelRegistry from "ember-data/types/registries/model";
import JiraIssueModel from "hermes/models/jira-issue";

export default class JiraIssueAdapter extends ApplicationAdapter {
findRecord<K extends string | number>(
_store: DS.Store,
_type: ModelRegistry[K],
id: string,
_snapshot: DS.Snapshot<K>,
): RSVP.Promise<any> {
): RSVP.Promise<JiraIssueModel> {
const issue = this.fetchSvc
.fetch(`/api/${this.configSvc.config.api_version}/jira/issues/${id}`)
.then((response) => response?.json());
Expand Down
5 changes: 3 additions & 2 deletions web/app/components/project/jira-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import { tracked } from "@glimmer/tracking";
import { inject as service } from "@ember/service";
import { restartableTask } from "ember-concurrency";
import FetchService from "hermes/services/fetch";
import { JiraIssue, JiraPickerResult } from "hermes/types/project";
import { JiraPickerResult } from "hermes/types/project";
import ConfigService from "hermes/services/config";
import { XDropdownListAnchorAPI } from "../x/dropdown-list";
import { next } from "@ember/runloop";
import { assert } from "@ember/debug";
import JiraIssueModel from "hermes/models/jira-issue";

interface ProjectJiraWidgetComponentSignature {
Element: HTMLDivElement;
Args: {
issue?: JiraPickerResult | JiraIssue;
issue?: JiraPickerResult | JiraIssueModel;
onIssueSelect?: (issue: any) => void;
onIssueRemove?: () => void;
isDisabled?: boolean;
Expand Down
9 changes: 3 additions & 6 deletions web/app/components/project/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { task } from "ember-concurrency";
import JiraIssueModel from "hermes/models/jira-issue";
import ConfigService from "hermes/services/config";
import FetchService from "hermes/services/fetch";
import StoreService from "hermes/services/store";
import {
HermesProject,
HermesProjectHit,
JiraIssue,
} from "hermes/types/project";
import { HermesProject, HermesProjectHit } from "hermes/types/project";

export const PROJECT_TILE_MAX_PRODUCTS = 3;

Expand Down Expand Up @@ -50,7 +47,7 @@ export default class ProjectTileComponent extends Component<ProjectTileComponent
* Used in the template to determine whether to show Jira-related data.
* Set by the `fetchJiraIssue` task if the project has a jiraIssueID.
*/
@tracked protected jiraIssue: JiraIssue | null = null;
@tracked protected jiraIssue: JiraIssueModel | null = null;

/**
* The project ID used as our LinkTo model.
Expand Down
29 changes: 16 additions & 13 deletions web/app/models/jira-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,50 @@ import Model, { attr } from "@ember-data/model";

export default class JiraIssueModel extends Model {
/**
*
* The Jira issue key, e.g., "PROJ-123".
* Used as the ID for the JiraIssue model.
*/
@attr declare key: string;

/**
*
* The summary of the issue.
*/
@attr declare summary: string;
@attr declare summary?: string;

/**
*
* The issue permalink.
*/
@attr declare url: string;

/**
*
* The status, e.g., "Open".
*/
@attr declare status: string;

/**
*
* The assignee of the issue.
*/
@attr declare assignee: string;
@attr declare assignee?: string;

/**
*
* The type of issue, e.g., "Bug".
*/
@attr declare issueType: string;
@attr declare issueType?: string;

/**
*
* The URL to the issue type image.
* TODO: Host these ourselves to avoid broken images.
*/
@attr declare issueTypeImage: string;

/**
*
* The issue priority, e.g., "High".
*/
@attr declare priority: string;
@attr declare priority?: string;

/**
*
* The URL to the priority image.
* TODO: Host these ourselves to avoid broken images.
*/
@attr declare priorityImage: string;
}
5 changes: 2 additions & 3 deletions web/app/serializers/jira-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import JiraIssueModel from "hermes/models/jira-issue";

export default class JiraIssueSerializer extends JSONSerializer {
/**
* The serializer for the `person` model.
* Handles `query` and `queryRecord` requests to the EmberData store.
* Formats the response to match the JSON spec.
* The serializer for the JiraIssue model.
* Formats responses to the JSON spec.
*/
normalizeResponse(
_store: DS.Store,
Expand Down
15 changes: 2 additions & 13 deletions web/app/types/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@ import {
import { ProjectStatus } from "./project-status";
import { HermesDocument } from "./document";
import { AlgoliaHit } from "hermes/services/algolia";

export interface JiraIssue {
key: string;
url: string;
priority: string;
priorityImage: string;
status: string;
assignee?: string;
issueType: string;
issueTypeImage: string;
summary: string;
}
import JiraIssueModel from "hermes/models/jira-issue";

export interface JiraPickerResult {
key: string;
Expand Down Expand Up @@ -47,5 +36,5 @@ export interface HermesProjectResources {
export interface HermesProject
extends HermesProjectInfo,
HermesProjectResources {
jiraIssue?: JiraIssue;
jiraIssue?: JiraIssueModel;
}
5 changes: 3 additions & 2 deletions web/tests/integration/components/project/jira-widget-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { MirageTestContext, setupMirage } from "ember-cli-mirage/test-support";
import { setupRenderingTest } from "ember-qunit";
import { click, fillIn, find, render, waitFor } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { JiraIssue, JiraPickerResult } from "hermes/types/project";
import { JiraPickerResult } from "hermes/types/project";
import {
TEST_JIRA_WORKSPACE_URL,
TEST_JIRA_ISSUE_SUMMARY,
setWebConfig,
} from "hermes/mirage/utils";
import JiraIssueModel from "hermes/models/jira-issue";

const JIRA_ICON = "[data-test-jira-icon]";
const ADD_JIRA_INPUT = "[data-test-add-jira-input]";
Expand All @@ -33,7 +34,7 @@ const PLUS_ICON = "[data-test-add-jira-button-plus]";

interface Context extends MirageTestContext {
contextIsForm: boolean;
issue: JiraPickerResult | JiraIssue;
issue: JiraPickerResult | JiraIssueModel;
isLoading: boolean;
onIssueSelect: () => void;
onIssueRemove: () => void;
Expand Down

0 comments on commit fdd7517

Please sign in to comment.