mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
make the whole plugin card clickable and moved spinner to upper right corner
This commit is contained in:
@@ -46,7 +46,8 @@ type Props = {
|
|||||||
contentRight?: React.Node,
|
contentRight?: React.Node,
|
||||||
footerLeft: React.Node,
|
footerLeft: React.Node,
|
||||||
footerRight: React.Node,
|
footerRight: React.Node,
|
||||||
link: string,
|
link?: string,
|
||||||
|
action?: () => void,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
classes: any
|
classes: any
|
||||||
@@ -54,9 +55,11 @@ type Props = {
|
|||||||
|
|
||||||
class CardColumn extends React.Component<Props> {
|
class CardColumn extends React.Component<Props> {
|
||||||
createLink = () => {
|
createLink = () => {
|
||||||
const { link } = this.props;
|
const { link, action } = this.props;
|
||||||
if (link) {
|
if (link) {
|
||||||
return <Link className="overlay-column" to={link} />;
|
return <Link className="overlay-column" to={link} />;
|
||||||
|
} else if (action) {
|
||||||
|
return <a className="overlay-column" onClick={e => {e.preventDefault(); action();}} href="#" />;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ const styles = {
|
|||||||
link: {
|
link: {
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
pointerEvents: "all"
|
pointerEvents: "all"
|
||||||
|
},
|
||||||
|
spinner: {
|
||||||
|
position: "absolute",
|
||||||
|
right: 0,
|
||||||
|
top: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,19 +54,14 @@ class PluginEntry extends React.Component<Props, State> {
|
|||||||
return <small className="level-item">{plugin.author}</small>;
|
return <small className="level-item">{plugin.author}</small>;
|
||||||
};
|
};
|
||||||
|
|
||||||
createFooterLeft = (plugin: Plugin) => {
|
isInstallable = () => {
|
||||||
|
const { plugin } = this.props;
|
||||||
|
return plugin._links && plugin._links.install && plugin._links.install.href;
|
||||||
|
};
|
||||||
|
|
||||||
|
createFooterLeft = () => {
|
||||||
const { classes } = this.props;
|
const { classes } = this.props;
|
||||||
if (plugin.pending) {
|
if (this.isInstallable()) {
|
||||||
return (
|
|
||||||
<span className="level-item">
|
|
||||||
<i className="fas fa-spinner fa-spin has-text-info" />
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
} else if (
|
|
||||||
plugin._links &&
|
|
||||||
plugin._links.install &&
|
|
||||||
plugin._links.install.href
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={classNames(classes.link, "level-item")}
|
className={classNames(classes.link, "level-item")}
|
||||||
@@ -73,11 +73,23 @@ class PluginEntry extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
createPendingSpinner = () => {
|
||||||
|
const { plugin, classes } = this.props;
|
||||||
|
if (plugin.pending) {
|
||||||
|
return (
|
||||||
|
<span className={classes.spinner}>
|
||||||
|
<i className="fas fa-spinner fa-spin has-text-info" />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { plugin, refresh } = this.props;
|
const { plugin, refresh } = this.props;
|
||||||
const { showModal } = this.state;
|
const { showModal } = this.state;
|
||||||
const avatar = this.createAvatar(plugin);
|
const avatar = this.createAvatar(plugin);
|
||||||
const footerLeft = this.createFooterLeft(plugin);
|
const footerLeft = this.createFooterLeft();
|
||||||
const footerRight = this.createFooterRight(plugin);
|
const footerRight = this.createFooterRight(plugin);
|
||||||
|
|
||||||
const modal = showModal ? (
|
const modal = showModal ? (
|
||||||
@@ -88,14 +100,14 @@ class PluginEntry extends React.Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
// TODO: Add link to plugin page below
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CardColumn
|
<CardColumn
|
||||||
link="#"
|
action={this.isInstallable() ? this.toggleModal : null}
|
||||||
avatar={avatar}
|
avatar={avatar}
|
||||||
title={plugin.displayName ? plugin.displayName : plugin.name}
|
title={plugin.displayName ? plugin.displayName : plugin.name}
|
||||||
description={plugin.description}
|
description={plugin.description}
|
||||||
|
contentRight={this.createPendingSpinner()}
|
||||||
footerLeft={footerLeft}
|
footerLeft={footerLeft}
|
||||||
footerRight={footerRight}
|
footerRight={footerRight}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user