From 56ed817c4fb7d8e3e439087d4056c4827506f45a Mon Sep 17 00:00:00 2001 From: Adrien Delannoy Date: Mon, 30 Sep 2024 13:04:24 +0200 Subject: [PATCH] fix: linting & pre-commit --- sdks/java/client/docs/WorkflowServiceApi.md | 4 +- sdks/python/client/docs/WorkflowServiceApi.md | 2 +- server/workflow/store/sqlite_store_test.go | 6 +- .../workflows-list/workflows-list.tsx | 79 +++++++++---------- 4 files changed, 45 insertions(+), 46 deletions(-) diff --git a/sdks/java/client/docs/WorkflowServiceApi.md b/sdks/java/client/docs/WorkflowServiceApi.md index b2f7144baf55..d99bc3d91623 100644 --- a/sdks/java/client/docs/WorkflowServiceApi.md +++ b/sdks/java/client/docs/WorkflowServiceApi.md @@ -323,7 +323,7 @@ Name | Type | Description | Notes # **workflowServiceListWorkflows** -> IoArgoprojWorkflowV1alpha1WorkflowList workflowServiceListWorkflows(namespace, listOptionsLabelSelector, listOptionsFieldSelector, listOptionsWatch, listOptionsAllowWatchBookmarks, listOptionsResourceVersion, listOptionsResourceVersionMatch, listOptionsTimeoutSeconds, listOptionsLimit, listOptionsContinue, listOptionsSendInitialEvents, fields) +> IoArgoprojWorkflowV1alpha1WorkflowList workflowServiceListWorkflows(namespace, listOptionsLabelSelector, listOptionsFieldSelector, listOptionsWatch, listOptionsAllowWatchBookmarks, listOptionsResourceVersion, listOptionsResourceVersionMatch, listOptionsTimeoutSeconds, listOptionsLimit, listOptionsContinue, listOptionsSendInitialEvents, fields, nameFilter) @@ -363,7 +363,7 @@ public class Example { String fields = "fields_example"; // String | Fields to be included or excluded in the response. e.g. \"items.spec,items.status.phase\", \"-items.status.nodes\". String nameFilter = "nameFilter_example"; // String | Filter type used for name filtering. Exact | Contains | Prefix. Default to Exact. try { - IoArgoprojWorkflowV1alpha1WorkflowList result = apiInstance.workflowServiceListWorkflows(namespace, listOptionsLabelSelector, listOptionsFieldSelector, listOptionsWatch, listOptionsAllowWatchBookmarks, listOptionsResourceVersion, listOptionsResourceVersionMatch, listOptionsTimeoutSeconds, listOptionsLimit, listOptionsContinue, listOptionsSendInitialEvents, fields); + IoArgoprojWorkflowV1alpha1WorkflowList result = apiInstance.workflowServiceListWorkflows(namespace, listOptionsLabelSelector, listOptionsFieldSelector, listOptionsWatch, listOptionsAllowWatchBookmarks, listOptionsResourceVersion, listOptionsResourceVersionMatch, listOptionsTimeoutSeconds, listOptionsLimit, listOptionsContinue, listOptionsSendInitialEvents, fields, nameFilter); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling WorkflowServiceApi#workflowServiceListWorkflows"); diff --git a/sdks/python/client/docs/WorkflowServiceApi.md b/sdks/python/client/docs/WorkflowServiceApi.md index 12467126e519..b2288e27aaee 100644 --- a/sdks/python/client/docs/WorkflowServiceApi.md +++ b/sdks/python/client/docs/WorkflowServiceApi.md @@ -57782,7 +57782,7 @@ with argo_workflows.ApiClient(configuration) as api_client: # example passing only required values which don't have defaults set # and optional values try: - api_response = api_instance.list_workflows(namespace, list_options_label_selector=list_options_label_selector, list_options_field_selector=list_options_field_selector, list_options_watch=list_options_watch, list_options_allow_watch_bookmarks=list_options_allow_watch_bookmarks, list_options_resource_version=list_options_resource_version, list_options_resource_version_match=list_options_resource_version_match, list_options_timeout_seconds=list_options_timeout_seconds, list_options_limit=list_options_limit, list_options_continue=list_options_continue, list_options_send_initial_events=list_options_send_initial_events, fields=fields) + api_response = api_instance.list_workflows(namespace, list_options_label_selector=list_options_label_selector, list_options_field_selector=list_options_field_selector, list_options_watch=list_options_watch, list_options_allow_watch_bookmarks=list_options_allow_watch_bookmarks, list_options_resource_version=list_options_resource_version, list_options_resource_version_match=list_options_resource_version_match, list_options_timeout_seconds=list_options_timeout_seconds, list_options_limit=list_options_limit, list_options_continue=list_options_continue, list_options_send_initial_events=list_options_send_initial_events, fields=fields, name_filter=name_filter) pprint(api_response) except argo_workflows.ApiException as e: print("Exception when calling WorkflowServiceApi->list_workflows: %s\n" % e) diff --git a/server/workflow/store/sqlite_store_test.go b/server/workflow/store/sqlite_store_test.go index cb5c035bd95b..cc96e4d0b8f9 100644 --- a/server/workflow/store/sqlite_store_test.go +++ b/server/workflow/store/sqlite_store_test.go @@ -136,7 +136,7 @@ func TestStoreOperation(t *testing.T) { t.Run("TestListWorkflows name", func(t *testing.T) { wfList, err := store.ListWorkflows(context.Background(), "argo", "Exact", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=flow"}) require.NoError(t, err) - assert.Len(t, wfList.Items, 0) + assert.Empty(t, wfList.Items) wfList, err = store.ListWorkflows(context.Background(), "argo", "Exact", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=workflow-1"}) require.NoError(t, err) @@ -149,7 +149,7 @@ func TestStoreOperation(t *testing.T) { t.Run("TestListWorkflows namePrefix", func(t *testing.T) { wfList, err := store.ListWorkflows(context.Background(), "argo", "Prefix", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=flow"}) require.NoError(t, err) - assert.Len(t, wfList.Items, 0) + assert.Empty(t, wfList.Items) wfList, err = store.ListWorkflows(context.Background(), "argo", "Prefix", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=workflow-"}) require.NoError(t, err) @@ -162,7 +162,7 @@ func TestStoreOperation(t *testing.T) { t.Run("TestListWorkflows namePattern", func(t *testing.T) { wfList, err := store.ListWorkflows(context.Background(), "argo", "Contains", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=non-existing-pattern"}) require.NoError(t, err) - assert.Len(t, wfList.Items, 0) + assert.Empty(t, wfList.Items) wfList, err = store.ListWorkflows(context.Background(), "argo", "Contains", metav1.ListOptions{Limit: 5, FieldSelector: "metadata.name=flow"}) require.NoError(t, err) diff --git a/ui/src/app/workflows/components/workflows-list/workflows-list.tsx b/ui/src/app/workflows/components/workflows-list/workflows-list.tsx index 519a103024db..8a5241e48339 100644 --- a/ui/src/app/workflows/components/workflows-list/workflows-list.tsx +++ b/ui/src/app/workflows/components/workflows-list/workflows-list.tsx @@ -1,36 +1,36 @@ -import { Page } from 'argo-ui/src/components/page/page'; -import { SlidingPanel } from 'argo-ui/src/components/sliding-panel/sliding-panel'; +import {Page} from 'argo-ui/src/components/page/page'; +import {SlidingPanel} from 'argo-ui/src/components/sliding-panel/sliding-panel'; import * as React from 'react'; -import { useContext, useEffect, useMemo, useState } from 'react'; -import { RouteComponentProps } from 'react-router-dom'; +import {useContext, useEffect, useMemo, useState} from 'react'; +import {RouteComponentProps} from 'react-router-dom'; import * as models from '../../../../models'; -import { isArchivedWorkflow, Workflow, WorkflowPhase, WorkflowPhases } from '../../../../models'; -import { uiUrl } from '../../../shared/base'; -import { CostOptimisationNudge } from '../../../shared/components/cost-optimisation-nudge'; -import { ErrorNotice } from '../../../shared/components/error-notice'; -import { ExampleManifests } from '../../../shared/components/example-manifests'; -import { Loading } from '../../../shared/components/loading'; -import { PaginationPanel } from '../../../shared/components/pagination-panel'; -import { ZeroState } from '../../../shared/components/zero-state'; -import { Context } from '../../../shared/context'; -import { historyUrl } from '../../../shared/history'; -import { ListWatch, sortByYouth } from '../../../shared/list-watch'; +import {isArchivedWorkflow, Workflow, WorkflowPhase, WorkflowPhases} from '../../../../models'; +import {uiUrl} from '../../../shared/base'; +import {CostOptimisationNudge} from '../../../shared/components/cost-optimisation-nudge'; +import {ErrorNotice} from '../../../shared/components/error-notice'; +import {ExampleManifests} from '../../../shared/components/example-manifests'; +import {Loading} from '../../../shared/components/loading'; +import {PaginationPanel} from '../../../shared/components/pagination-panel'; +import {ZeroState} from '../../../shared/components/zero-state'; +import {Context} from '../../../shared/context'; +import {historyUrl} from '../../../shared/history'; +import {ListWatch, sortByYouth} from '../../../shared/list-watch'; import * as nsUtils from '../../../shared/namespaces'; -import { Pagination, parseLimit } from '../../../shared/pagination'; -import { ScopedLocalStorage } from '../../../shared/scoped-local-storage'; -import { services } from '../../../shared/services'; -import { useCollectEvent } from '../../../shared/use-collect-event'; +import {Pagination, parseLimit} from '../../../shared/pagination'; +import {ScopedLocalStorage} from '../../../shared/scoped-local-storage'; +import {services} from '../../../shared/services'; +import {useCollectEvent} from '../../../shared/use-collect-event'; import * as Actions from '../../../shared/workflow-operations-map'; -import { WorkflowCreator } from '../workflow-creator'; -import type { NameFilterKeys } from '../workflow-filters/workflow-filters'; -import { NAME_FILTER_KEYS, WorkflowFilters } from '../workflow-filters/workflow-filters'; -import { WorkflowsRow } from '../workflows-row/workflows-row'; -import { WorkflowsSummaryContainer } from '../workflows-summary-container/workflows-summary-container'; -import { WorkflowsToolbar } from '../workflows-toolbar/workflows-toolbar'; +import {WorkflowCreator} from '../workflow-creator'; +import type {NameFilterKeys} from '../workflow-filters/workflow-filters'; +import {NAME_FILTER_KEYS, WorkflowFilters} from '../workflow-filters/workflow-filters'; +import {WorkflowsRow} from '../workflows-row/workflows-row'; +import {WorkflowsSummaryContainer} from '../workflows-summary-container/workflows-summary-container'; +import {WorkflowsToolbar} from '../workflows-toolbar/workflows-toolbar'; -import { TimestampSwitch } from '../../../shared/components/timestamp'; -import useTimestamp, { TIMESTAMP_KEYS } from '../../../shared/use-timestamp'; +import {TimestampSwitch} from '../../../shared/components/timestamp'; +import useTimestamp, {TIMESTAMP_KEYS} from '../../../shared/use-timestamp'; import './workflows-list.scss'; interface WorkflowListRenderOptions { @@ -55,9 +55,9 @@ const allBatchActionsEnabled: Actions.OperationDisabled = { const storage = new ScopedLocalStorage('ListOptions'); -export function WorkflowsList({ match, location, history }: RouteComponentProps) { +export function WorkflowsList({match, location, history}: RouteComponentProps) { const queryParams = new URLSearchParams(location.search); - const { navigation } = useContext(Context); + const {navigation} = useContext(Context); const [namespace, setNamespace] = useState(nsUtils.getNamespace(match.params.namespace) || ''); const [pagination, setPagination] = useState(() => { @@ -96,7 +96,7 @@ export function WorkflowsList({ match, location, history }: RouteComponentProps< }); const batchActionDisabled = useMemo(() => { - const nowDisabled: any = { ...allBatchActionsEnabled }; + const nowDisabled: any = {...allBatchActionsEnabled}; for (const action of Object.keys(nowDisabled)) { for (const wf of Array.from(selectedWorkflows.values())) { nowDisabled[action] = nowDisabled[action] || actions[action].disabled(wf); @@ -128,8 +128,7 @@ export function WorkflowsList({ match, location, history }: RouteComponentProps< // save history and localStorage useEffect(() => { // add empty selectedPhases + selectedLabels for forward-compat w/ old version: previous code relies on them existing, so if you move up a version and back down, it breaks - const options = { selectedPhases: [], selectedLabels: [] } as unknown as WorkflowListRenderOptions; - options[nameFilter.type] = nameFilter.value; + const options = {selectedPhases: [], selectedLabels: []} as unknown as WorkflowListRenderOptions; options.phases = phases; options.labels = labels; if (pagination.limit) { @@ -149,16 +148,16 @@ export function WorkflowsList({ match, location, history }: RouteComponentProps< if (nameValue) { params.append(nameFilter, nameValue); } - history.push(historyUrl('workflows' + (nsUtils.getManagedNamespace() ? '' : '/{namespace}'), { namespace, extraSearchParams: params })); + history.push(historyUrl('workflows' + (nsUtils.getManagedNamespace() ? '' : '/{namespace}'), {namespace, extraSearchParams: params})); }, [namespace, phases.toString(), labels.toString(), pagination.limit, pagination.offset, nameValue, nameFilter]); // referential equality, so use values, not refs useEffect(() => { const listWatch = new ListWatch( () => services.workflows.list(namespace, phases, labels, pagination, undefined, nameValue, nameFilter), - (resourceVersion: string) => services.workflows.watchFields({ namespace, phases, labels, resourceVersion }), + (resourceVersion: string) => services.workflows.watchFields({namespace, phases, labels, resourceVersion}), metadata => { setError(null); - setPagination({ ...pagination, nextOffset: metadata.continue }); + setPagination({...pagination, nextOffset: metadata.continue}); clearSelectedWorkflows(); }, () => setError(null), @@ -184,15 +183,15 @@ export function WorkflowsList({ match, location, history }: RouteComponentProps< title='Workflows' toolbar={{ breadcrumbs: [ - { title: 'Workflows', path: uiUrl('workflows') }, - { title: namespace, path: uiUrl('workflows/' + namespace) } + {title: 'Workflows', path: uiUrl('workflows')}, + {title: namespace, path: uiUrl('workflows/' + namespace)} ], actionMenu: { items: [ { title: 'Submit New Workflow', iconClassName: 'fa fa-plus', - action: () => navigation.goto('.', { sidePanel: 'submit-new-workflow' }) + action: () => navigation.goto('.', {sidePanel: 'submit-new-workflow'}) }, ...links.map(link => ({ title: link.name, @@ -348,7 +347,7 @@ export function WorkflowsList({ match, location, history }: RouteComponentProps< )} - navigation.goto('.', { sidePanel: null })}> + navigation.goto('.', {sidePanel: null})}> {getSidePanel() === 'submit-new-workflow' && ( { // don't count archived workflows as this is for GC purposes if (isArchivedWorkflow(wf)) {