Skip to content

Commit

Permalink
chore: ui linter fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Clucas <alan@clucas.org>
  • Loading branch information
Joibel committed Sep 20, 2024
1 parent 3a05962 commit 25bbb71
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
10 changes: 5 additions & 5 deletions ui/src/app/shared/pod-name.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ describe('pod names', () => {
});

test('getPodName', () => {
const node = {
const node = ({
name: 'nodename',
id: '1',
templateName: shortTemplateName
} as unknown as NodeStatus;
const wf = {
} as unknown) as NodeStatus;
const wf = ({
metadata: {
name: shortWfName,
annotations: {
[ANNOTATION_KEY_POD_NAME_VERSION]: POD_NAME_V1
}
}
} as unknown as Workflow;
} as unknown) as Workflow;

const v1podName = node.id;
const v2podName = `${shortWfName}-${shortTemplateName}-${createFNVHash(node.name)}`;
Expand All @@ -63,7 +63,7 @@ describe('pod names', () => {
test('getTemplateNameFromNode', () => {
// case: no template ref or template name
// expect fallback to empty string
const node = {} as unknown as NodeStatus;
const node = ({} as unknown) as NodeStatus;
expect(getTemplateNameFromNode(node)).toEqual('');

// case: template ref defined but no template name defined
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/pod-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getPodName(workflow: Workflow, node: NodeStatus): string {
const workflowName = workflow.metadata.name;
// convert containerSet node name to its corresponding pod node name by removing the ".<containerName>" postfix
// this part is from workflow/controller/container_set_template.go#executeContainerSet; the inverse never happens in the back-end, so is unique to the front-end
const podNodeName = node.type == 'Container' ? node.name.replace(/\.[^/.]+$/, '') : node.name;
const podNodeName = node.type === 'Container' ? node.name.replace(/\.[^/.]+$/, '') : node.name;
if (workflowName === podNodeName) {
return workflowName;
}
Expand All @@ -43,7 +43,7 @@ export function ensurePodNamePrefixLength(prefix: string): string {
}

return prefix;
};
}

export const createFNVHash = (input: string): number => {
let hashint = 2166136261;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const Utils = {

fixLocalStorageString(x: string): string {
// empty string is valid, so we cannot use `truthy`
if (x == null || x == 'null' || x == 'undefined') {
if (x == null || x === 'null' || x === 'undefined') {
return undefined; // explicitly return undefined
}
return x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Checkbox} from 'argo-ui';
import React, {useContext, useState} from 'react';
import {Parameter, ResubmitOpts, Workflow} from '../../../models';
import {Context} from '../../shared/context';
import {uiUrl} from '../../shared/base';
import {ErrorNotice} from '../../shared/components/error-notice';
import {ParametersInput} from '../../shared/components/parameters-input/parameters-input';
import {Context} from '../../shared/context';
import {services} from '../../shared/services';
import {Utils} from '../../shared/utils';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/workflows/components/retry-workflow-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Checkbox} from 'argo-ui';
import React, {useContext, useState} from 'react';
import {Parameter, RetryOpts, Workflow} from '../../../models';
import {Context} from '../../shared/context';
import {uiUrl} from '../../shared/base';
import {ErrorNotice} from '../../shared/components/error-notice';
import {ParametersInput} from '../../shared/components/parameters-input/parameters-input';
import {Context} from '../../shared/context';
import {services} from '../../shared/services';
import {Utils} from '../../shared/utils';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/workflows/components/submit-workflow-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Select} from 'argo-ui';
import React, {useContext, useMemo, useState} from 'react';
import {Parameter, Template} from '../../../models';
import {Context} from '../../shared/context';
import {uiUrl} from '../../shared/base';
import {ErrorNotice} from '../../shared/components/error-notice';
import {ParametersInput} from '../../shared/components/parameters-input/parameters-input';
import {TagsInput} from '../../shared/components/tags-input/tags-input';
import {Context} from '../../shared/context';
import {services} from '../../shared/services';
import {Utils} from '../../shared/utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps<
popup
.confirm('Confirm', () => <DeleteCheck isWfInDB={isArchivedWorkflow(workflow)} isWfInCluster={isWorkflowInCluster(workflow)} />)
.then(async yes => {
if (!yes) return;
if (!yes) {
return;
}

const allPromises = [];
if (isWorkflowInCluster(workflow)) {
Expand All @@ -218,7 +220,9 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps<
setSidePanel('retry');
} else {
popup.confirm('Confirm', `Are you sure you want to ${workflowOperation.title.toLowerCase()} this workflow?`).then(yes => {
if (!yes) return;
if (!yes) {
return;
}

workflowOperation.action(workflow).catch(setError);
});
Expand Down Expand Up @@ -466,7 +470,9 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps<

function renderResumePopup() {
return popup.confirm('Confirm', renderSuspendNodeOptions).then(yes => {
if (!yes) return;
if (!yes) {
return;
}

updateOutputParametersForNodeIfRequired()
.then(resumeNode)
Expand Down

0 comments on commit 25bbb71

Please sign in to comment.