Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide shorten url button #5539

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/plugins/share/public/components/url_panel_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ interface State {
export class UrlPanelContent extends Component<Props, State> {
private mounted?: boolean;
private shortUrlCache?: string;
shouldRenderShortUrl: boolean = true;

constructor(props: Props) {
super(props);
Expand All @@ -106,7 +107,16 @@ export class UrlPanelContent extends Component<Props, State> {
this.mounted = false;
}

public componentDidMount() {
public async componentDidMount() {
try {
await shortenUrl(this.getSnapshotUrl(), {
basePath: this.props.basePath,
post: this.props.post,
});
} catch (err) {
this.shouldRenderShortUrl = false;
}

this.mounted = true;
this.setUrl();

Expand Down Expand Up @@ -393,7 +403,8 @@ export class UrlPanelContent extends Component<Props, State> {
private renderShortUrlSwitch = () => {
if (
this.state.exportUrlAs === ExportUrlAsType.EXPORT_URL_AS_SAVED_OBJECT ||
!this.props.allowShortUrl
!this.props.allowShortUrl ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that a dashboards-plugin can assign this value? IMO it would be better for a plugin to supply this value of whether to render or not render the component instead of relying on catching an exception.

!this.shouldRenderShortUrl
) {
return;
}
Expand Down