Skip to content

Commit

Permalink
Merge pull request buildbot#7155 from p12tic/fixes
Browse files Browse the repository at this point in the history
Miscellaneous fixes
  • Loading branch information
p12tic authored Oct 11, 2023
2 parents aea339e + b48a5db commit 3bc2181
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def __init__(self, rtype, master):
if hasattr(self, "isCollection"):
warn_deprecated("3.10.0", "Endpoint.isCollection has been deprecated, "
"please set \"kind\" attribute instead. "
"isRaw = True is equivalent to kind = EndpointKind.COLLECTION")
if self.isRaw:
"isCollection = True is equivalent to kind = EndpointKind.COLLECTION")
if self.isCollection:
self.kind = EndpointKind.COLLECTION

def get(self, resultSpec, kwargs):
Expand Down
6 changes: 4 additions & 2 deletions master/buildbot/data/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
from buildbot.data import types


def project_db_to_data(dbdict):
def project_db_to_data(dbdict, active=None):
return {
"projectid": dbdict["id"],
"name": dbdict["name"],
"slug": dbdict["slug"],
"description": dbdict["description"],
"description_format": dbdict["description_format"],
"description_html": dbdict["description_html"],
"active": active,
}


Expand Down Expand Up @@ -76,7 +77,7 @@ def get(self, result_spec, kwargs):
if dbdict["id"] not in ids_active
]

return [project_db_to_data(dbdict) for dbdict in dbdicts]
return [project_db_to_data(dbdict, active=active) for dbdict in dbdicts]

def get_kwargs_from_graphql(self, parent, resolve_info, args):
return {}
Expand All @@ -97,6 +98,7 @@ class EntityType(types.Entity):
projectid = types.Integer()
name = types.Identifier(70)
slug = types.Identifier(70)
active = types.NoneOk(types.Boolean())
description = types.NoneOk(types.String())
description_format = types.NoneOk(types.String())
description_html = types.NoneOk(types.String())
Expand Down
24 changes: 24 additions & 0 deletions master/buildbot/test/unit/www/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
from twisted.internet import defer
from twisted.trial import unittest

from buildbot.data.base import Endpoint
from buildbot.data.base import EndpointKind
from buildbot.data.exceptions import InvalidQueryParameter
from buildbot.test.fake import endpoint
from buildbot.test.reactor import TestReactorMixin
from buildbot.test.util import www
from buildbot.test.util.warnings import assertProducesWarning
from buildbot.util import bytes2unicode
from buildbot.util import unicode2bytes
from buildbot.warnings import DeprecatedApiWarning
from buildbot.www import authz
from buildbot.www import graphql
from buildbot.www import rest
Expand Down Expand Up @@ -975,3 +978,24 @@ def test_complex(self):
def test_text(self):
self.assertEqual(
rest.ContentTypeParser(b"text/plain; Charset=UTF-8").gettype(), "text/plain")


class EndpointKindMigrationTest(unittest.TestCase):

def test_is_raw(self):
class TestEndpoint(Endpoint):
isRaw = True

with assertProducesWarning(DeprecatedApiWarning,
message_pattern=r"Endpoint.isRaw has been deprecated"):
ep = TestEndpoint(mock.Mock(), mock.Mock())
self.assertEqual(ep.kind, EndpointKind.RAW)

def test_is_collection(self):
class TestEndpoint(Endpoint):
isCollection = True

with assertProducesWarning(DeprecatedApiWarning,
message_pattern=r"Endpoint.isCollection has been deprecated"):
ep = TestEndpoint(mock.Mock(), mock.Mock())
self.assertEqual(ep.kind, EndpointKind.COLLECTION)
2 changes: 1 addition & 1 deletion www/react-base/src/components/LogViewer/LogViewerText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const LogViewerText = observer(({log, downloadInitiateOverscanRowCount, d
}

const searchInputRef = useRef<HTMLInputElement>(null);
useHotkeys('Ctrl+F', () => { searchInputRef.current?.focus(); }, {preventDefault: true});
useHotkeys('Mod+F', () => { searchInputRef.current?.focus(); }, {preventDefault: true});

const outerElementType = useMemo(() => forwardRef<HTMLDivElement>((props, ref) => (
<div ref={ref} onMouseDown={checkSelection} onMouseUp={checkSelection} {...props}/>
Expand Down
3 changes: 3 additions & 0 deletions www/react-data-module/src/data/classes/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Project extends BaseClass {
@observable description_html!: string|null;
@observable slug!: string[];
@observable name!: string;
@observable active!: boolean|null;

constructor(accessor: IDataAccessor, endpoint: string, object: any) {
super(accessor, endpoint, String(object.projectid));
Expand All @@ -33,6 +34,7 @@ export class Project extends BaseClass {
this.description = object.description;
this.description_format = object.description_format;
this.description_html = object.description_html;
this.active = object.active;
}

toObject() {
Expand All @@ -41,6 +43,7 @@ export class Project extends BaseClass {
name: this.name,
slug: this.slug,
description: this.description,
active: this.active,
};
}

Expand Down

0 comments on commit 3bc2181

Please sign in to comment.