Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent re-fetch runs #257

Merged
merged 2 commits into from
Mar 17, 2024
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
10 changes: 2 additions & 8 deletions packages/ecc-client-lit-ga4gh-tes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"types": "./dist/index.d.ts",
"componentsPrefix": "ecc-client-lit-ga4gh-tes-",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
"./dist/custom-elements.json": "./dist/custom-elements.json",
"./dist/index.js": "./dist/index.js",
"./dist/components/*": "./dist/components/*",
Expand All @@ -33,10 +30,7 @@
"lint:fix": "npm run lint -- --fix",
"prepublish": "npm run build"
},
"dependencies": {
"@elixir-cloud/design": "*",
"lit": "^2.8.0"
},
"dependencies": { "@elixir-cloud/design": "*", "lit": "^2.8.0" },
"devDependencies": {
"@custom-elements-manifest/analyzer": "^0.4.17",
"@open-wc/eslint-config": "^9.2.1",
Expand Down
17 changes: 10 additions & 7 deletions packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
label?: string;
path: string;
copy?: boolean;
defaultValue?: any;

Check warning on line 15 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type
}

export interface Field {
Expand Down Expand Up @@ -262,7 +262,7 @@
const eccUtilsDesignCollection = this.shadowRoot?.querySelector(
"ecc-utils-design-collection"
// Todo: Get the typeof Collections and use it instead of `any`
) as any;

Check warning on line 265 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type
eccUtilsDesignCollection.pageSize = this.pageSize;
if (changedProperties.has("pageSize")) {
this._fetchData(1);
Expand Down Expand Up @@ -331,12 +331,12 @@
const eccUtilsDesignCollection = this.shadowRoot?.querySelector(
"ecc-utils-design-collection"
// Todo: Get the typeof Collections and use it instead of `any`
) as any;

Check warning on line 334 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type

eccUtilsDesignCollection.totalItems = this.items.length;
} else this.nextPageToken[page] = data.next_page_token;
} catch (error) {
console.error({

Check warning on line 339 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected console statement
error,
breakPoint: "TESRuns.fetchData",
});
Expand All @@ -346,7 +346,7 @@
private async _handleExpandItem(event: CustomEvent) {
const eccUtilsDesignCollection = this.shadowRoot?.querySelector(
"ecc-utils-design-collection"
) as any;

Check warning on line 349 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type

const { target, detail } = event;

Expand All @@ -356,14 +356,14 @@
}

const { key } = detail;
const children = target.querySelectorAll(`[slot="${key}"]`);
const runData = await fetchTask(this.baseURL, detail.key);
const children = target!.shadowRoot?.querySelectorAll(

Check warning on line 359 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Forbidden non-null assertion
`slot[name='${key}']`
);

if (this.cache.has(key)) return;
// Cache the run data if not present
const runData = await fetchTask(this.baseURL, detail.key);
this.cache.set(key, runData);

if (children) {
if (children?.length) {
try {
const child = document.createElement("div");
child.setAttribute("slot", key);
Expand Down Expand Up @@ -399,7 +399,7 @@
// Add button event
const detailsElement = child.querySelector(
"ecc-utils-design-details"
) as any;

Check warning on line 402 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type
if (detailsElement) {
detailsElement.addEventListener(
`ecc-utils-button-click`,
Expand All @@ -409,7 +409,7 @@
if (buttonKey === key) {
// 0 is the index of the button as there is only one button
detailsElement.setButtonLoading(0, true);
const resp = (await deleteTask(this.baseURL, key)) as any;

Check warning on line 412 in packages/ecc-client-lit-ga4gh-tes/src/components/runs/runs.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Unexpected any. Specify a different type
detailsElement.setButtonLoading(0, false);

// If the response doesn't have run ID that means the run wasn't canceled.
Expand Down Expand Up @@ -440,8 +440,11 @@
@ecc-utils-page-change=${(event: CustomEvent) => {
this._fetchData(event.detail.page);
}}
@ecc-utils-expand=${(event: CustomEvent) =>
this._handleExpandItem(event)}
@ecc-utils-expand=${(event: CustomEvent) => {
if (!this.cache.has(event.detail.key)) {
this._handleExpandItem(event);
}
}}
>
</ecc-utils-design-collection>
`;
Expand Down
16 changes: 9 additions & 7 deletions packages/ecc-client-lit-ga4gh-wes/src/components/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,13 @@ export default class ECCClientGa4ghWesRuns extends LitElement {
}

const { key } = detail;
const children = target.querySelectorAll(`[slot="${key}"]`);
const children = target!.shadowRoot?.querySelectorAll(
`slot[name='${key}']`
);
const runData = await fetchWorkflow(this.baseURL, detail.key);

if (this.cache.has(key)) return;
// Cache the run data if not present
this.cache.set(key, runData);

if (children) {
if (children?.length) {
try {
const child = document.createElement("div");
child.setAttribute("slot", key);
Expand Down Expand Up @@ -428,8 +427,11 @@ export default class ECCClientGa4ghWesRuns extends LitElement {
@ecc-utils-page-change=${(event: CustomEvent) => {
this._fetchData(event.detail.page);
}}
@ecc-utils-expand=${(event: CustomEvent) =>
this._handleExpandItem(event)}
@ecc-utils-expand=${(event: CustomEvent) => {
if (!this.cache.has(event.detail.key)) {
this._handleExpandItem(event);
}
}}
>
</ecc-utils-design-collection>
`;
Expand Down
Loading