Skip to content

Commit

Permalink
PAUSED: Use git resume to continue working. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
himdel committed Nov 1, 2023
1 parent eba9e81 commit 1cf0cc1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
24 changes: 22 additions & 2 deletions src/containers/ansible-role/namespace-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
LegacyNamespaceListType,
LegacyRoleAPI,
LegacyRoleListType,
TagAPI,
} from 'src/api';
import {
AlertList,
Expand Down Expand Up @@ -61,6 +62,7 @@ interface NamespaceRolesState {
tags?: string[];
};
roles: LegacyRoleListType[];
tags: { id: string; title: string }[];
}

class NamespaceRoles extends React.Component<
Expand Down Expand Up @@ -88,6 +90,7 @@ class NamespaceRoles extends React.Component<
...params,
},
roles: [],
tags: [],
};
}

Expand Down Expand Up @@ -119,11 +122,28 @@ class NamespaceRoles extends React.Component<
);
}

// TODO call - but only HubListToolbar knows inputText
loadTags() {
const { inputText } = this.state;

TagAPI.listRoles({ name__icontains: inputText, sort: '-count' }).then(
({ data }) =>
this.setState({
tags: data.map(({ name, count }) => ({
id: name,
title: t`${name} (${count})`,
})),
}),
);
}

private get updateParams() {
return ParamHelper.updateParamsMixin();
}

render() {
const { count, loading, params, roles, tags } = this.state;

const updateParams = (params) =>
this.updateParams(params, () => this.query(params));

Expand All @@ -135,6 +155,8 @@ class NamespaceRoles extends React.Component<
{
id: 'tags',
title: t`Tags`,
inputType: 'typeahead' as const,
options: tags,
},
];

Expand All @@ -152,8 +174,6 @@ class NamespaceRoles extends React.Component<
},
];

const { count, loading, params, roles } = this.state;

const noData =
count === 0 &&
!filterIsSet(
Expand Down
25 changes: 22 additions & 3 deletions src/containers/ansible-role/role-list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { t } from '@lingui/macro';
import { DataList } from '@patternfly/react-core';
import React from 'react';
import { LegacyRoleAPI, LegacyRoleListType } from 'src/api';
import { LegacyRoleAPI, LegacyRoleListType, TagAPI } from 'src/api';
import {
AlertList,
AlertType,
Expand Down Expand Up @@ -32,6 +32,7 @@ interface RolesState {
sort?: string;
};
roles: LegacyRoleListType[];
tags: { id: string; title: string }[];
}

class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
Expand All @@ -54,6 +55,7 @@ class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
...params,
},
roles: [],
tags: [],
};
}

Expand All @@ -80,6 +82,21 @@ class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
);
}

// TODO call - but only HubListToolbar knows inputText
loadTags() {
const { inputText } = this.state;

TagAPI.listRoles({ name__icontains: inputText, sort: '-count' }).then(
({ data }) =>
this.setState({
tags: data.map(({ name, count }) => ({
id: name,
title: t`${name} (${count})`,
})),
}),
);
}

private get updateParams() {
return ParamHelper.updateParamsMixin();
}
Expand All @@ -95,6 +112,8 @@ class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
}

render() {
const { alerts, count, loading, params, roles, tags } = this.state;

const updateParams = (params) =>
this.updateParams(params, () => this.query(params));

Expand All @@ -110,6 +129,8 @@ class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
{
id: 'tags',
title: t`Tags`,
inputType: 'typeahead' as const,
options: tags,
},
];

Expand All @@ -127,8 +148,6 @@ class AnsibleRoleList extends React.Component<RouteProps, RolesState> {
},
];

const { alerts, count, loading, params, roles } = this.state;

const noData =
count === 0 &&
!filterIsSet(
Expand Down

0 comments on commit 1cf0cc1

Please sign in to comment.