Skip to content

Commit

Permalink
recfuture popup prevention
Browse files Browse the repository at this point in the history
This was a really tough one.  Thanks to Nick Georgieff for guiding me and
helping me debug this.
  • Loading branch information
Todd Bruner committed May 4, 2020
1 parent 69b4587 commit 12e67c6
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 79 deletions.
22 changes: 6 additions & 16 deletions lib/Scot/App/Responder/RecFutureProxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -315,23 +315,13 @@ sub store_entry {

if ( $entryid ) {
# entry exists, post a reply
my $entry = $entry_col->find_iid($entryid);

if ( defined $entry ) {
$parent = $entry->id;
}
my $entry = $entry_col->find_iid($entryid);
$entry->update({
'$set' => {
body => $html,
}
});
}
# need to create an entry

my $entry = $entry_col->create({
body => $html,
target => {
id => $href->{id},
type => 'entity',
},
parent => $parent,
class => 'entry',
});

}

Expand Down
14 changes: 7 additions & 7 deletions lib/Scot/Controller/Api.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2311,16 +2311,16 @@ sub recfuture {
});
my $entity = $mongo->collection('Entity')->find_iid($id);

$self->env->mq->send("/topic/scot",{
action => "created",
$self->env->mq->send("/topic/scot", {
action => "updated",
data => {
who => $req_href->{user},
type=> "entry",
id => $entry->id,
target => $entry->target,
},
who => $self->session('user'),
type => 'entity',
id => $id,
}
});


$self->env->mq->send("/queue/recfuture",{
action => "lookup",
data => {
Expand Down
20 changes: 15 additions & 5 deletions lib/Scot/Util/Enrichments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ sub BUILD {
isa => 'HashRef',
)
);
$log->debug("creating attribute $name with value ",
{ filter => \&Dumper, value => $href} );
$self->$name($href);
}
else {
Expand Down Expand Up @@ -137,13 +139,12 @@ sub enrich {

$log->debug("Looking for enrichment: $enricher_name.");

my $enricher;
try {
$enricher = $self->$enricher_name;
my $enricher = try {
$self->$enricher_name;
}
catch {
$log->error("$enricher_name does not have a defined attribute by same name in enrichments");
next NAME;
return undef;
};

unless ( $enricher ) {
Expand All @@ -155,7 +156,7 @@ sub enrich {
next NAME;
}

# $log->debug("Enricher Hash is ",{filter=>\&Dumper, value=>$enricher});
$log->debug("Enricher Hash is ",{filter=>\&Dumper, value=>$enricher});

if ( ref($enricher) eq "HASH" ) {

Expand All @@ -173,6 +174,10 @@ sub enrich {
title => $enricher->{title},
},
};
if ( defined $enricher->{nopopup} ) {
$data->{$enricher_name}->{data}->{nopopup} = $enricher->{nopopup};
$log->debug("enricher now ",{filter=>\&Dumper, value=>$data});
}
$update_count++;
}
}
Expand All @@ -182,8 +187,13 @@ sub enrich {
data => {
url => sprintf($enricher->{url}, $value),
title => $enricher->{title},

},
};
if ( defined $enricher->{nopopup} ) {
$data->{$enricher_name}->{data}->{nopopup} = $enricher->{nopopup};
$log->debug("enricher now ",{filter=>\&Dumper, value=>$data});
}
$update_count++;
}
}
Expand Down
8 changes: 4 additions & 4 deletions public/asset-manifest.json

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

2 changes: 1 addition & 1 deletion public/index.html

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

30 changes: 0 additions & 30 deletions public/precache-manifest.028d2d4be7a5f5f954f317d49d8c93a0.js

This file was deleted.

2 changes: 1 addition & 1 deletion public/service-worker.js

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

2 changes: 0 additions & 2 deletions public/static/js/main.dcce07af.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion public/static/js/main.dcce07af.chunk.js.map

This file was deleted.

7 changes: 4 additions & 3 deletions scot-ui/src/detail/selected_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ export default class SelectedEntry extends React.Component {
}
};

linkWarningToggle = (href) => {
linkWarningToggle = (href,nopop=false) => {
if (this.state.isMounted) {
if (this.state.linkWarningToolbar === false) {
this.setState({ linkWarningToolbar: true, link: href });
this.setState({ linkWarningToolbar: true, link: href, nopop: nopop });
} else {
this.setState({ linkWarningToolbar: false });
this.setState({ linkWarningToolbar: false, nopop: nopop });
}
}
};
Expand Down Expand Up @@ -464,6 +464,7 @@ export default class SelectedEntry extends React.Component {
<LinkWarning
linkWarningToggle={this.linkWarningToggle}
link={this.state.link}
nopop={this.state.nopop}
/>
) : null}
</div>
Expand Down
7 changes: 4 additions & 3 deletions scot-ui/src/detail/selected_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ export default class SelectedHeader extends React.Component {
}
};

linkWarningToggle = href => {
linkWarningToggle = (href, nopop=false) => {
if (this.state.linkWarningToolbar === false) {
this.setState({ linkWarningToolbar: true, link: href });
this.setState({ linkWarningToolbar: true, link: href, nopop: nopop });
} else {
this.setState({ linkWarningToolbar: false });
this.setState({ linkWarningToolbar: false, nopop: nopop });
}
};

Expand Down Expand Up @@ -1015,6 +1015,7 @@ export default class SelectedHeader extends React.Component {
<LinkWarning
linkWarningToggle={this.linkWarningToggle}
link={this.state.link}
nopop={this.state.nopop}
/>
) : null}
{this.state.viewedByHistoryToolbar ? (
Expand Down
14 changes: 8 additions & 6 deletions scot-ui/src/modal/entity_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,9 @@ class EntityBody extends React.Component {
}
};

linkOnClickIntercept = e => {
this.props.linkWarningToggle(e.target.id);
linkOnClickIntercept = (e) => {

this.props.linkWarningToggle(e.target.id, e.target.dataset.nopop);
};

componentDidMount() {
Expand Down Expand Up @@ -1125,14 +1126,15 @@ class EntityBody extends React.Component {
} else if (entityData[prop].type === "link") {
//added this because we dont need two buttons -2019 bryce
if (entityData[prop].data.title !== "Lookup in Likaboss") {
const nopop = ( entityData[prop].data.nopopup ) ? true : false;
console.log(entityData[prop].data);
entityEnrichmentLinkArr.push(
<Button
bsSize="xsmall"
id={entityData[prop].data.url}
{ prop.nopopup == 1 ? null :
onMouseDown={this.linkOnClickIntercept}
target="_blank"
}
data-nopop={nopop}
onMouseDown={this.linkOnClickIntercept}
target="_blank"
>
{entityData[prop].data.title}
</Button>
Expand Down
10 changes: 10 additions & 0 deletions scot-ui/src/modal/link_warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ export default class LinkWarning extends React.Component {
this.props.linkWarningToggle();
};

apiOnly = () => {
this.props.linkWarningToggle();
fetch(this.props.link);
alert("Request Submitted. Refresh entity display to see results");
};

componentWillMount = () => {
if ( this.props.nopop === "true" ) {
this.apiOnly();
return;
}
let myDomain = window.location.href;
let reg = new RegExp(
/((https?|ftp):\/\/[a-zA-Z0-9\-_\.]+\.)?([a-zA-Z0-9\-_\.]+\.([a-zA-Z]{1,63}))/,
Expand Down

0 comments on commit 12e67c6

Please sign in to comment.