mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add eslint rule padding-line-between-statements (#1593)
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
7b77f18376
commit
dcf253e7d5
401 files changed
+2018
-40
No files matched your search
@@ -22,10 +22,12 @@ interface Props extends KubeObjectDetailsProps<CustomResourceDefinition> {
|
||||
export class CRDDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { object: crd } = this.props;
|
||||
|
||||
if (!crd) return null;
|
||||
const { plural, singular, kind, listKind } = crd.getNames();
|
||||
const printerColumns = crd.getPrinterColumns();
|
||||
const validation = crd.getValidation();
|
||||
|
||||
return (
|
||||
<div className="CRDDetails">
|
||||
<KubeObjectMeta object={crd}/>
|
||||
@@ -60,6 +62,7 @@ export class CRDDetails extends React.Component<Props> {
|
||||
{
|
||||
crd.getConditions().map(condition => {
|
||||
const { type, message, lastTransitionTime, status } = condition;
|
||||
|
||||
return (
|
||||
<Badge
|
||||
key={type}
|
||||
@@ -103,6 +106,7 @@ export class CRDDetails extends React.Component<Props> {
|
||||
{
|
||||
printerColumns.map((column, index) => {
|
||||
const { name, type, jsonPath } = column;
|
||||
|
||||
return (
|
||||
<TableRow key={index}>
|
||||
<TableCell className="name">{name}</TableCell>
|
||||
|
||||
@@ -30,6 +30,7 @@ export class CrdList extends React.Component {
|
||||
onGroupChange(group: string) {
|
||||
const groups = [...this.groups];
|
||||
const index = groups.findIndex(item => item == group);
|
||||
|
||||
if (index !== -1) groups.splice(index, 1);
|
||||
else groups.push(group);
|
||||
setQueryParams({ groups });
|
||||
@@ -43,6 +44,7 @@ export class CrdList extends React.Component {
|
||||
[sortBy.version]: (crd: CustomResourceDefinition) => crd.getVersion(),
|
||||
[sortBy.scope]: (crd: CustomResourceDefinition) => crd.getScope(),
|
||||
};
|
||||
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="CrdList"
|
||||
@@ -58,8 +60,10 @@ export class CrdList extends React.Component {
|
||||
renderHeaderTitle={<Trans>Custom Resources</Trans>}
|
||||
customizeHeader={() => {
|
||||
let placeholder = <Trans>All groups</Trans>;
|
||||
|
||||
if (selectedGroups.length == 1) placeholder = <><Trans>Group</Trans>: {selectedGroups[0]}</>;
|
||||
if (selectedGroups.length >= 2) placeholder = <><Trans>Groups</Trans>: {selectedGroups.join(", ")}</>;
|
||||
|
||||
return {
|
||||
// todo: move to global filters
|
||||
filters: (
|
||||
@@ -71,6 +75,7 @@ export class CrdList extends React.Component {
|
||||
controlShouldRenderValue={false}
|
||||
formatOptionLabel={({ value: group }: SelectOption) => {
|
||||
const isSelected = selectedGroups.includes(group);
|
||||
|
||||
return (
|
||||
<div className="flex gaps align-center">
|
||||
<Icon small material="folder"/>
|
||||
|
||||
@@ -53,6 +53,7 @@ export class CrdResourceDetails extends React.Component<Props> {
|
||||
|
||||
renderStatus(crd: CustomResourceDefinition, columns: AdditionalPrinterColumnsV1[]) {
|
||||
const showStatus = !columns.find(column => column.name == "Status") && crd.status?.conditions;
|
||||
|
||||
if (!showStatus) {
|
||||
return null;
|
||||
}
|
||||
@@ -77,6 +78,7 @@ export class CrdResourceDetails extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { props: { object }, crd } = this;
|
||||
|
||||
if (!object || !crd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ export class CrdResources extends React.Component<Props> {
|
||||
disposeOnUnmount(this, [
|
||||
autorun(() => {
|
||||
const { store } = this;
|
||||
|
||||
if (store && !store.isLoading && !store.isLoaded) {
|
||||
store.loadAll();
|
||||
}
|
||||
@@ -37,16 +38,19 @@ export class CrdResources extends React.Component<Props> {
|
||||
|
||||
@computed get crd() {
|
||||
const { group, name } = this.props.match.params;
|
||||
|
||||
return crdStore.getByGroup(group, name);
|
||||
}
|
||||
|
||||
@computed get store() {
|
||||
if (!this.crd) return null;
|
||||
|
||||
return apiManager.getStore(this.crd.getResourceApiBase());
|
||||
}
|
||||
|
||||
render() {
|
||||
const { crd, store } = this;
|
||||
|
||||
if (!crd) return null;
|
||||
const isNamespaced = crd.isNamespaced();
|
||||
const extraColumns = crd.getPrinterColumns(false); // Cols with priority bigger than 0 are shown in details
|
||||
@@ -55,6 +59,7 @@ export class CrdResources extends React.Component<Props> {
|
||||
[sortBy.namespace]: (item: KubeObject) => item.getNs(),
|
||||
[sortBy.age]: (item: KubeObject) => item.metadata.creationTimestamp,
|
||||
};
|
||||
|
||||
extraColumns.forEach(column => {
|
||||
sortingCallbacks[column.name] = (item: KubeObject) => jsonPath.value(item, column.jsonPath.slice(1));
|
||||
});
|
||||
@@ -74,6 +79,7 @@ export class CrdResources extends React.Component<Props> {
|
||||
isNamespaced && { title: <Trans>Namespace</Trans>, className: "namespace", sortBy: sortBy.namespace },
|
||||
...extraColumns.map(column => {
|
||||
const { name } = column;
|
||||
|
||||
return {
|
||||
title: name,
|
||||
className: name.toLowerCase(),
|
||||
|
||||
@@ -38,17 +38,22 @@ export class CRDStore extends KubeObjectStore<CustomResourceDefinition> {
|
||||
|
||||
@computed get groups() {
|
||||
const groups: Record<string, CustomResourceDefinition[]> = {};
|
||||
|
||||
return this.items.reduce((groups, crd) => {
|
||||
const group = crd.getGroup();
|
||||
|
||||
if (!groups[group]) groups[group] = [];
|
||||
groups[group].push(crd);
|
||||
|
||||
return groups;
|
||||
}, groups);
|
||||
}
|
||||
|
||||
getByGroup(group: string, pluralName: string) {
|
||||
const crdInGroup = this.groups[group];
|
||||
|
||||
if (!crdInGroup) return null;
|
||||
|
||||
return crdInGroup.find(crd => crd.getPluralName() === pluralName);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user