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

refactor(tes): remove filter by status dead code #272

Closed
Closed
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
Expand Up @@ -8,7 +8,7 @@ import {
fastTextField,
} from '@microsoft/fast-components';
import { html, repeat, when } from '@microsoft/fast-element';
import TESRuns, { stateOption } from './tesRuns.js';
import TESRuns from './tesRuns.js';
import { TESRun } from '../../tes-run/index.js';

provideFASTDesignSystem().register(
Expand All @@ -29,16 +29,6 @@ const template = html<TESRuns>`
@input=${(x, c) => x.handleNameInput(c.event)}
>
</fast-text-field>
<fast-select
:value=${(x) => x.stateInput}
@input=${(x, c) => x.handleStateInput(c.event)}
>
<fast-option value="ALL">ALL</fast-option>
${repeat(
() => stateOption,
html`<fast-option value=${(x) => x}>${(x) => x}</fast-option>`
)}
</fast-select>
</div>
<div class="list">
<fast-accordion>
Expand Down Expand Up @@ -113,7 +103,9 @@ const template = html<TESRuns>`
>
<fast-button
appearance="neutral"
?disabled=${(x) => x.tokens[x.pageNumber + 1] === undefined}
?disabled=${(x) =>
x.tokens[x.pageNumber + 1] === undefined ||
Object.entries(x.data).length === 0}
@click=${(x) => x.handleNext()}
>
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export default class TESRuns extends FASTElement {
// Seach input for name_prefix filter
@observable searchInput = '';

@observable stateInput = 'ALL';

@observable unfilterdData: Data = {
tasks: [],
next_page_token: '',
Expand Down Expand Up @@ -102,9 +100,6 @@ export default class TESRuns extends FASTElement {

// Cache next click
handleNext = async () => {
// Reset the state filter
this.stateInput = 'ALL';

// Calculate the next page
const nextPageNumber = this.pageNumber + 1;
this.pageNumber = nextPageNumber; // Increment the pageNumber
Expand All @@ -121,7 +116,6 @@ export default class TESRuns extends FASTElement {

// Handle prev click
handlePrev = async () => {
this.stateInput = 'ALL';
const prevPageNumber = this.pageNumber - 1;
const prevPageToken = this.tokens[prevPageNumber];
await this.fetchData(prevPageToken, this.searchInput);
Expand All @@ -137,16 +131,4 @@ export default class TESRuns extends FASTElement {
// Fetch new data
this.fetchData('', this.searchInput);
}

handleStateInput(event: Event) {
this.stateInput = (event.target as HTMLInputElement).value;

// Filter data on current page based on the filter input
if (this.stateInput === 'ALL') this.data = this.unfilterdData.tasks;
else {
this.data = this.unfilterdData.tasks.filter(
(task) => task.state === this.stateInput
);
}
}
}
33 changes: 3 additions & 30 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 @@ -45,7 +45,7 @@

export interface FilterProp {
key: string;
type: "search" | "select";
type: "search";
options?: string[];
selectConfig?: {
multiple?: boolean;
Expand Down Expand Up @@ -80,7 +80,6 @@
@property({ type: String }) private baseURL =
"https://protes.rahtiapp.fi/ga4gh/tes/v1";

@property({ type: Boolean }) private filter = true;
@property({ type: Boolean }) private search = true;
@property({ type: Array }) private fields: Array<Field> = [
{
Expand Down Expand Up @@ -215,27 +214,6 @@
type: "search",
placeholder: "Search by prefix",
},
{
key: "tag",
type: "select",
options: [
"UNKNOWN",
"QUEUED",
"INITIALIZING",
"RUNNING",
"PAUSED",
"COMPLETE",
"EXECUTOR_ERROR",
"SYSTEM_ERROR",
"CANCELED",
"PREEMPTED",
"CANCELING",
],
placeholder: "Filter by status",
selectConfig: {
multiple: false,
},
},
];

@state() private items: ItemProp[] = [];
Expand All @@ -262,14 +240,14 @@
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 243 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);
}

// Handle filter render
if (changedProperties.has("filter") || changedProperties.has("search")) {
// Handle search by prefix render
if (changedProperties.has("search")) {
this.filters = this.getUpdatedFilters();
}
}
Expand All @@ -278,11 +256,6 @@
let updatedFilters = [...this.filters];

// Modify the array based on the conditions
if (!this.filter) {
updatedFilters = updatedFilters.filter(
(filter) => filter.type !== "select"
);
}
if (!this.search) {
updatedFilters = updatedFilters.filter(
(filter) => filter.type !== "search"
Expand Down Expand Up @@ -331,12 +304,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 307 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 312 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 +319,7 @@
private async _handleExpandItem(event: CustomEvent) {
const eccUtilsDesignCollection = this.shadowRoot?.querySelector(
"ecc-utils-design-collection"
) as any;

Check warning on line 322 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,7 +329,7 @@
}

const { key } = detail;
const children = target!.shadowRoot?.querySelectorAll(

Check warning on line 332 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}']`
);

Expand Down Expand Up @@ -399,7 +372,7 @@
// Add button event
const detailsElement = child.querySelector(
"ecc-utils-design-details"
) as any;

Check warning on line 375 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 +382,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 385 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
Loading