Skip to content

Commit

Permalink
Use command label as window title if invocation target is a modal dia…
Browse files Browse the repository at this point in the history
…log. Also tidy up UI and plug another localization hole in the ShareLinkToView component.

Fixes #1012
  • Loading branch information
jumpinjackie committed Nov 22, 2019
1 parent 03005e7 commit 894eb22
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/actions/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ async function initFromWebLayoutAsync(webLayout: WebLayout, opts: IInitAsyncOpti
targetFrame: cmd.TargetFrame,
parameters: (cmd.AdditionalParameter || []).map(p => {
return { name: p.Key, value: p.Value };
})
}),
title: cmd.Label
});
} else if (isSearchCommand(cmd)) {
registerCommand(cmd.Name, {
Expand All @@ -610,7 +611,7 @@ async function initFromWebLayoutAsync(webLayout: WebLayout, opts: IInitAsyncOpti
resultColumns: cmd.ResultColumns,
filter: cmd.Filter,
matchLimit: cmd.MatchLimit,
title: cmd.Label,
title: cmd.Label
});
}
cmdsByKey[cmd.Name] = cmd;
Expand Down Expand Up @@ -748,7 +749,7 @@ async function initFromAppDefAsync(appDef: ApplicationDefinition, opts: IInitAsy
resultColumns: cmd.ResultColumns,
filter: cmd.Filter,
matchLimit: cmd.MatchLimit,
title: cmd.Title,
title: (cmd.Title || (isUIWidget(widget) ? widget.Label : undefined)),
target: convertToCommandTarget(cmd.Target),
targetFrame: cmd.Target
});
Expand All @@ -761,7 +762,8 @@ async function initFromAppDefAsync(appDef: ApplicationDefinition, opts: IInitAsy
targetFrame: cmd.Target,
parameters: (cmd.AdditionalParameter || []).map((p: any) => {
return { name: p.Key, value: p.Value };
})
}),
title: isUIWidget(widget) ? widget.Label : undefined
});
break;
}
Expand Down
9 changes: 8 additions & 1 deletion src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export interface ICommand {
icon?: string;
iconClass?: string;
//tooltip?: string;
//label?: string;
/**
* @since 0.12.8
*/
title?: string;
/**
* Indicates if this command is enabled based on the given application state
*
Expand Down Expand Up @@ -242,6 +245,10 @@ export interface IInvokeUrlCommand extends ITargetedCommand {
*/
icon?: string;
iconClass?: string;
/**
* @since 0.12.8
*/
title?: string;
/**
* The URL to invoke
*
Expand Down
6 changes: 4 additions & 2 deletions src/api/registry/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export function registerCommand(name: string, cmdDef: ICommand | IInvokeUrlComma
cmd = {
icon: cmdDef.icon,
iconClass: cmdDef.iconClass,
title: cmdDef.title,
enabled: (state) => {
if (cmdDef.disableIfSelectionEmpty === true) {
return CommandConditions.hasSelection(state);
Expand All @@ -362,14 +363,15 @@ export function registerCommand(name: string, cmdDef: ICommand | IInvokeUrlComma
if (map) {
const params = mergeInvokeUrlParameters(cmdDef.parameters, parameters);
const url = ensureParameters(cmdDef.url, map.Name, map.SessionId, config.locale, true, params);
openUrlInTarget(name, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
openUrlInTarget(name, cmdDef, config.capabilities.hasTaskPane, dispatch, url, cmd.title);
}
}
};
} else if (isSearchCommand(cmdDef)) {
cmd = {
icon: cmdDef.icon,
iconClass: cmdDef.iconClass,
title: cmdDef.title,
enabled: () => true,
selected: () => false,
invoke: (dispatch: ReduxDispatch, getState: () => IApplicationState, viewer: IMapViewer, parameters?: any) => {
Expand All @@ -388,7 +390,7 @@ export function registerCommand(name: string, cmdDef: ICommand | IInvokeUrlComma
+ `&limit=${cmdDef.matchLimit}`
+ `&properties=${(cmdDef.resultColumns.Column || []).map(col => col.Property).join(",")}`
+ `&propNames=${(cmdDef.resultColumns.Column || []).map(col => col.Name).join(",")}`;
openUrlInTarget(name, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
openUrlInTarget(name, cmdDef, config.capabilities.hasTaskPane, dispatch, url, cmd.title);
}
}
};
Expand Down
16 changes: 9 additions & 7 deletions src/containers/share-link-to-view.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { connect } from "react-redux";
import {
import {
IApplicationState
} from '../api/common';
import { addUrlProps } from 'react-url-query';
Expand Down Expand Up @@ -48,10 +48,10 @@ function mapStateToProps(state: Readonly<IApplicationState>): Partial<IShareLink
}

function mapDispatchToProps(): Partial<IShareLinkToViewContainerDispatch> {
return { };
return {};
}

function NOOP() {}
function NOOP() { }

/**
* @since 0.11
Expand Down Expand Up @@ -90,10 +90,12 @@ export class ShareLinkToViewContainer extends React.Component<ShareLinkToViewCon
return <div>
<TextArea fill={true} rows={16} readOnly value={shareUrl} onChange={NOOP} />
<br />
<Checkbox checked={this.state.showSession} label="Include Session ID" onChange={this.onShowSessionChanged} />
<CopyToClipboard text={shareUrl} onCopy={this.onCopied}>
<button className="pt-button">{tr("SHARE_LINK_COPY_CLIPBOARD", this.props.locale)}</button>
</CopyToClipboard>
<div style={{ padding: 15 }}>
<Checkbox checked={this.state.showSession} label={tr("SHARE_LINK_INCLUDE_SESSION", this.props.locale)} onChange={this.onShowSessionChanged} />
<CopyToClipboard text={shareUrl} onCopy={this.onCopied}>
<button className="pt-button">{tr("SHARE_LINK_COPY_CLIPBOARD", this.props.locale)}</button>
</CopyToClipboard>
</div>
</div>;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/strings/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ const STRINGS_EN: ILocalizedMessages = {
"OL_ATTRIBUTION_TIP": "Attributions",
"OL_OVERVIEWMAP_TIP": "Overview Map",
"OL_RESET_ROTATION_TIP": "Reset Rotation",
"FEATURE_TOOLTIP_URL_HELP_TEXT": "Click for more information"
"FEATURE_TOOLTIP_URL_HELP_TEXT": "Click for more information",
"SHARE_LINK_INCLUDE_SESSION": "Include Session ID"
};

export default STRINGS_EN;
1 change: 1 addition & 0 deletions src/strings/msgdef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,5 @@ export interface ILocalizedMessages {
OL_OVERVIEWMAP_TIP: string;
OL_RESET_ROTATION_TIP: string;
FEATURE_TOOLTIP_URL_HELP_TEXT: string;
SHARE_LINK_INCLUDE_SESSION: string;
}
3 changes: 2 additions & 1 deletion viewer/strings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@
"OL_ATTRIBUTION_TIP": "Zuschreibungen",
"OL_OVERVIEWMAP_TIP": "Übersichtskarte",
"OL_RESET_ROTATION_TIP": "Drehung zurücksetzen",
"FEATURE_TOOLTIP_URL_HELP_TEXT": "Klicken Sie hier, um weitere Informationen zu erhalten"
"FEATURE_TOOLTIP_URL_HELP_TEXT": "Klicken Sie hier, um weitere Informationen zu erhalten",
"SHARE_LINK_INCLUDE_SESSION": "Sitzungs-ID einschließen"
}

0 comments on commit 894eb22

Please sign in to comment.