Skip to content

Commit

Permalink
ui: add bluesky and mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrc committed Dec 3, 2024
1 parent 46c5c6b commit 51423b4
Show file tree
Hide file tree
Showing 68 changed files with 459 additions and 198 deletions.
14 changes: 14 additions & 0 deletions backend/inspirehep/submissions/marshmallow/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Author(Schema):
status = fields.Raw()
arxiv_categories = fields.Raw()
websites = fields.Raw()
bluesky = fields.Raw()
mastodon = fields.Raw()
twitter = fields.Raw()
blog = fields.Raw()
linkedin = fields.Raw()
Expand Down Expand Up @@ -63,6 +65,12 @@ def before_dump(self, data):
),
"emails": get_value(data, "email_addresses", default=missing),
"status": get_value(data, "status", default=missing),
"bluesky": self.get_first_or_missing(
get_values_for_schema(data.get("ids", []), "BLUESKY")
),
"mastodon": self.get_first_or_missing(
get_values_for_schema(data.get("ids", []), "MASTODON")
),
"twitter": self.get_first_or_missing(
get_values_for_schema(data.get("ids", []), "TWITTER")
),
Expand Down Expand Up @@ -160,6 +168,12 @@ def build_author(self, data):
status = data.get("status")
author.set_status(status)

bluesky = data.get("bluesky")
author.add_bluesky(bluesky)

mastodon = data.get("mastodon")
author.add_mastodon(mastodon)

twitter = data.get("twitter")
author.add_twitter(twitter)

Expand Down
94 changes: 68 additions & 26 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Flask = ">=1.0.2"
msgpack = "==0.6.2"

python = ">=3.11,<3.12"
inspire-schemas = "^61.5.32"
inspire-schemas = "^61.6.0"
inspire-utils = "^3.0.61"
inspire-service-orcid = {git = "https://github.com/inspirehep/inspire-service-orcid.git", rev = "1a0e762e58bc9cac65f7665b9831993c017fd8bb"}
inspire-json-merger = "^11.0.37"
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint": "./node_modules/eslint/bin/eslint.js ./src --ext \"**/*.{js,jsx,ts,tsx}\" --config .eslintrc"
},
"dependencies": {
"@ant-design/icons": "^4.0.0",
"@ant-design/icons": "^5.5.1",
"@babel/runtime": "7.0.0-beta.55",
"@craco/craco": "6.4.3",
"@sentry/browser": "^5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`AssignDrawer renders assign authors search 1`] = `
<Button
data-test-id="assign-button"
disabled={true}
icon={<ForwardRef(SelectOutlined) />}
icon={<SelectOutlined />}
onClick={[Function]}
type="primary"
>
Expand Down
29 changes: 29 additions & 0 deletions ui/src/authors/components/AuthorBlueskyAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { Tooltip } from 'antd';

import Icon from '@ant-design/icons';
import UserAction from '../../common/components/UserAction';
import LinkWithTargetBlank from '../../common/components/LinkWithTargetBlank';
import EventTracker from '../../common/components/EventTracker';
import { ReactComponent as blueskyLogo } from '../../common/assets/bluesky.svg';

const AuthorBlueskyAction = ({ bluesky }: { bluesky: string }) => {
const href = `//bsky.app/profile/${bluesky}`;
return (
<UserAction>
<EventTracker
eventCategory="Author detail"
eventAction="Link"
eventId="Bluesky"
>
<LinkWithTargetBlank href={href}>
<Tooltip title="Bluesky">
<Icon component={blueskyLogo} style={{ color: 'rgb(95,95,95)' }} />
</Tooltip>
</LinkWithTargetBlank>
</EventTracker>
</UserAction>
);
};

export default AuthorBlueskyAction;
30 changes: 30 additions & 0 deletions ui/src/authors/components/AuthorMastodonAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { Tooltip } from 'antd';

import Icon from '@ant-design/icons';
import UserAction from '../../common/components/UserAction';
import LinkWithTargetBlank from '../../common/components/LinkWithTargetBlank';
import EventTracker from '../../common/components/EventTracker';
import { ReactComponent as mastodonLogo } from '../../common/assets/mastodon.svg';

const AuthorMastodonAction = ({ mastodon }: { mastodon: string }) => {
const [user, host] = mastodon ? mastodon.split('@') : [];
const href = `//${host}/@${user}`;
return (
<UserAction>
<EventTracker
eventCategory="Author detail"
eventAction="Link"
eventId="Mastodon"
>
<LinkWithTargetBlank href={href}>
<Tooltip title="Mastodon">
<Icon component={mastodonLogo} />
</Tooltip>
</LinkWithTargetBlank>
</EventTracker>
</UserAction>
);
};

export default AuthorMastodonAction;
26 changes: 13 additions & 13 deletions ui/src/authors/components/AuthorTwitterAction.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import React from 'react';
import { TwitterOutlined } from '@ant-design/icons';
import { XOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';

import UserAction from '../../common/components/UserAction';
import LinkWithTargetBlank from '../../common/components/LinkWithTargetBlank';
import EventTracker from '../../common/components/EventTracker';

const AuthorTwitterAction = ({ twitter }: { twitter: string }) => {
const href = `//twitter.com/${twitter}`;
const href = `//x.com/${twitter}`;
return (
<UserAction>
<Tooltip title="Twitter">
<EventTracker
eventCategory="Author detail"
eventAction="Link"
eventId="Twitter"
>
<LinkWithTargetBlank href={href}>
<TwitterOutlined />
</LinkWithTargetBlank>
</EventTracker>
</Tooltip>
<EventTracker
eventCategory="Author detail"
eventAction="Link"
eventId="Twitter"
>
<LinkWithTargetBlank href={href}>
<Tooltip title="X / Twitter">
<XOutlined />
</Tooltip>
</LinkWithTargetBlank>
</EventTracker>
</UserAction>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports[`AssignAction renders 1`] = `
data-test-id="btn-claim"
>
<IconText
icon={<ForwardRef(FileDoneOutlined) />}
icon={<FileDoneOutlined />}
text="claim"
/>
</Button>
Expand Down Expand Up @@ -150,7 +150,7 @@ exports[`AssignAction renders disabled 1`] = `
data-test-id="btn-claim"
>
<IconText
icon={<ForwardRef(FileDoneOutlined) />}
icon={<FileDoneOutlined />}
text="claim"
/>
</Button>
Expand Down Expand Up @@ -230,7 +230,7 @@ exports[`AssignAction renders plural form if numberOfSelected is more than 1 1`]
data-test-id="btn-claim"
>
<IconText
icon={<ForwardRef(FileDoneOutlined) />}
icon={<FileDoneOutlined />}
text="claim"
/>
</Button>
Expand Down Expand Up @@ -310,7 +310,7 @@ exports[`AssignAction renders singular form if numberOfSelected is 1 1`] = `
data-test-id="btn-claim"
>
<IconText
icon={<ForwardRef(FileDoneOutlined) />}
icon={<FileDoneOutlined />}
text="claim"
/>
</Button>
Expand Down
Loading

0 comments on commit 51423b4

Please sign in to comment.