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

Rich History: UX adjustments and fixes #22729

Merged
merged 22 commits into from
Mar 17, 2020
Merged

Conversation

ivanahuckova
Copy link
Member

@ivanahuckova ivanahuckova commented Mar 11, 2020

This PR adds fixes to Rich history based on users feedback. See list of fixes below:

Fixed:

  • Replace datasources with data sources
  • Sort queries (show current value)
  • Fix handle color for light theme
  • Add closing button to drawer
  • Fix inactive closing button when live-tailing
  • Opening animation
  • Remove toggling of tab bars
  • When commenting, clicking on button triggers sending the query
  • Remove interpolation and stitching of keys
  • Confirmation before clearing history
  • Adjust height of clickable buttons on query card (they have currently the same height as card)
  • The time filter slider doesn't resize with the window when you use the handlebar – I think it would be nice if it would do that as much as possible
  • If “today” and “a week ago” can’t be positioned to the side of the slider, there should be more spacing between

Separate PRs:

  • Add documentation PR merged
  • Add test coverage open PR ready to be reviewed
  • UX fixes (based on user feedback) open PR
  • Add error handling for store
  • Add method "getQueryDisplayText" to most used datasources (elastic, graphite)
  • Sync open query history tabs when opened in different windows (always update after change) ->
    Discussed with Andrej. We are probably going to look at this later (when we move history to database). Needs more research/thought regarding implementation.

@ivanahuckova ivanahuckova changed the title Rich History: Fixes Rich History: UX adjustments and fixes Mar 11, 2020
return false;
}
try {
this.set(key, json);
} catch (error) {
// Likely hitting storage quota
console.error(`Could not save item in localStorage: ${key}. [${error}]`);
appEvents.emit(AppEvents.alertError, [`Could not save item in localStorage: ${key}. [${error}]`]);
return false;
}
return true;
Copy link
Member Author

Choose a reason for hiding this comment

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

Add error handling. Has to be done here, as store is not throwing errors and therefore if we add try-catch block to addQueryToRichHistory it is not going to work.

Copy link
Member

Choose a reason for hiding this comment

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

I would still like to lift this one level up. So I would rather have this function throw the error, handle it in the both the RichHistory helpers and in LocalStorageValueProvider where this is used. That way LocalStorageValueProvider can still keep the console.log as we don't know if the emit is appropriate there, and add the emit to rich history where we know we want it. We can do it in separate PR.

activeDatasourceOnly: `${RICH_HISTORY_KEY}.activeDatasourceOnly`,
retentionPeriod: 'grafana.explore.richHistory.retentionPeriod',
starredTabAsFirstTab: 'grafana.explore.richHistory.starredTabAsFirstTab',
activeDatasourceOnly: 'grafana.explore.richHistory.activeDatasourceOnly',
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove interpolation and stitching of keys for easier search-ability.

return newHistory;
} else {
return richHistory;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Error handling - if object is not saved in store, it returns false. Therefore we need to return newHistory if saving was successful and previous history if it wasn't successful.

@@ -322,7 +322,6 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
['explore-active-button']: showRichHistory,
})}
onClick={this.toggleShowRichHistory}
disabled={isLive}
Copy link
Member Author

@ivanahuckova ivanahuckova Mar 13, 2020

Choose a reason for hiding this comment

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

If live-tailing is active, don't disable button to open and close Rich history.

width={width}
exploreId={exploreId}
onClose={this.toggleShowRichHistory}
/>
Copy link
Member Author

@ivanahuckova ivanahuckova Mar 13, 2020

Choose a reason for hiding this comment

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

Pass function toggleShowRichHistory, so we can add closing button to Rich history drawer.

deleteRichHistory: () => void;
onClose: () => void;
}
Copy link
Member Author

@ivanahuckova ivanahuckova Mar 13, 2020

Choose a reason for hiding this comment

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

New props:

  • height 0 so the slider can adjust its height based on height of drawer.
  • onClose - to close rich history drawer by new x button

@@ -166,6 +166,7 @@ class UnThemedRichHistory extends PureComponent<RichHistoryProps, RichHistorySta
onChangeSortOrder={this.onChangeSortOrder}
onSelectDatasourceFilters={this.onSelectDatasourceFilters}
exploreId={exploreId}
height={height}
/>
Copy link
Member Author

Choose a reason for hiding this comment

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

To adjust slider's height

@@ -205,8 +206,7 @@ class UnThemedRichHistory extends PureComponent<RichHistoryProps, RichHistorySta
icon: 'gicon gicon-preferences',
};

let tabs = starredTabAsFirstTab ? [StarredTab, QueriesTab, SettingsTab] : [QueriesTab, StarredTab, SettingsTab];

let tabs = [QueriesTab, StarredTab, SettingsTab];
return (
Copy link
Member Author

@ivanahuckova ivanahuckova Mar 13, 2020

Choose a reason for hiding this comment

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

Remove switching of tab bars based on active tab.

}}
onClick={e => {
e.stopPropagation();
}}
Copy link
Member Author

Choose a reason for hiding this comment

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

Add stop propagation, as clicking on comment and comment buttons also triggered adding queries to query fields.

Copy link
Member

Choose a reason for hiding this comment

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

This seems weird is it a bug in the form elements?

const handleDots = theme.isLight ? theme.colors.gray70 : theme.colors.gray33;
const handleDotsHover = theme.isLight ? theme.colors.gray33 : theme.colors.dark7;
const handleBackgroundHover = theme.isLight ? theme.colors.gray70 : theme.colors.gray33;
const handleDotsHover = theme.isLight ? theme.colors.gray5 : theme.colors.dark7;

Copy link
Member Author

Choose a reason for hiding this comment

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

More semantic naming.

@@ -118,13 +120,18 @@ function RichHistoryContainer(props: Props) {
maxHeight="100vh"
maxWidth={drawerWidth}
minWidth={drawerWidth}
onResize={(e, dir, ref) => {
setHeight(Number(ref.style.height.slice(0, -2)));
}}
>
Copy link
Member Author

Choose a reason for hiding this comment

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

On drawer resize, get the height of the drawer. It is only stored in style.

},
});
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Add Are you sure you want to permanently delete your query history modal before deleting history.

appEvents.emit(AppEvents.alertSuccess, ['Query history deleted']);
}}
>
<Forms.Button variant="destructive" onClick={onDelete}>
Clear query history
Copy link
Member Author

Choose a reason for hiding this comment

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

Add notification that history was successfully deleted.

return false;
}
try {
this.set(key, json);
} catch (error) {
// Likely hitting storage quota
console.error(`Could not save item in localStorage: ${key}. [${error}]`);
appEvents.emit(AppEvents.alertError, [`Could not save item in localStorage: ${key}. [${error}]`]);
return false;
}
return true;
Copy link
Member

Choose a reason for hiding this comment

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

I would still like to lift this one level up. So I would rather have this function throw the error, handle it in the both the RichHistory helpers and in LocalStorageValueProvider where this is used. That way LocalStorageValueProvider can still keep the console.log as we don't know if the emit is appropriate there, and add the emit to rich history where we know we want it. We can do it in separate PR.

}}
onClick={e => {
e.stopPropagation();
}}
Copy link
Member

Choose a reason for hiding this comment

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

This seems weird is it a bug in the form elements?


useEffect(() => {
setComment(query.comment);
}, [query.comment]);
Copy link
Member

Choose a reason for hiding this comment

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

This feels weird. If we are changing the comment in this component who would change the comment outside of the component?

Copy link
Member Author

Choose a reason for hiding this comment

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

This feels weird. If we are changing the comment in this component who would change the comment outside of the component?

yep, weird. I have super over-complicated it. I just looked at it in a fresh perspective and it is fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

This seems weird is it a bug in the form elements?

No, it is expected behaviour. You cave a clickable card - when you click on the card, it adds query to query editor (we might change this behaviour and instead of clickable card we add the button). And on that card we add buttons and textarea. So if you click on them, it bubbles up and also runs the function to add query to query editor. So we need to add stop propagation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would still like to lift this one level up. So I would rather have this function throw the error, handle it in the both the RichHistory helpers and in LocalStorageValueProvider where this is used. That way LocalStorageValueProvider can still keep the console.log as we don't know if the emit is appropriate there, and add the emit to rich history where we know we want it. We can do it in separate PR.

I have removed it from this PR, I will open then a new PR with just error handling of store.

Copy link
Member

@aocenas aocenas left a comment

Choose a reason for hiding this comment

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

looks good

@ivanahuckova ivanahuckova merged commit 5446900 into master Mar 17, 2020
@ivanahuckova ivanahuckova deleted the ivana/rich-history-fixes branch March 17, 2020 15:06
@ivanahuckova ivanahuckova self-assigned this Mar 17, 2020
@ivanahuckova ivanahuckova added this to the 6.7 milestone Mar 17, 2020
bergquist added a commit that referenced this pull request Mar 18, 2020
* master: (113 commits)
  AlertNotifications: Translate notifications IDs to UIDs in Rule builder (#19882)
  CircleCI: Don't build Storybook on PR (#22865)
  Graphite: Rollup Indicator (#22738)
  Plugins: Return jsondetails as an json object instead of raw json on datasource healthchecks. (#22859)
  Backend plugins: Exclude plugin metrics in Grafana's metrics endpoint (#22857)
  Graphite: Fixed issue with query editor and next select metric now showing after selecting metric node  (#22856)
  Webpack: Fix webpack for enterprise (#22863)
  Metrics: Storybook documented components  (#22854)
  Search: Improve tags layout , #22804 (#22830)
  Stackdriver: Fix GCE auth bug when creating new data source (#22836)
  @grafana/runtime: Add cancellation of queries to DataSourceWithBackend (#22818)
  Rich history: Test coverage (#22852)
  Chore: Support Volta in package.json (#22849)
  CircleCI: Skip enterprise builds for forked PRs (#22851)
  Toolkit: docker image for plugin CI process (#22790)
  Revert "Explore: Add test coverage for Rich history (#22722)" (#22850)
  Datasource config was not mapped for datasource healthcheck (#22848)
  upgrades plugin sdk to 0.30.0 (#22846)
  Explore: Add test coverage for Rich history (#22722)
  Rich History: UX adjustments and fixes (#22729)
  ...
aknuds1 pushed a commit that referenced this pull request Mar 19, 2020
* Initial commit

* Fix spelling of data sources

* Display sorting value for starred and query tab

* Fix handle color for light theme

* Add close button and fix animation

* Remove toggling of tabs

* Stop event propagation when clicking on comment buttons

* Add title for card functionality

* Remove interpolation for easier searchability of variables

* Improve syncing of comments and starred

* Add modal to check if user wants to permanently delete history

* Fix the height of the query card buttons

* Adjust slider's width based on drawer width

* Add spacing between slider and legend

* Semantic variable naming

* Fix disabled button when live tailing

* Add error handling

* Remove unused imports

* Fix starring, remove useEffect

* Remove emiting of appEvents.alertError in store

* Remove unused imports

(cherry picked from commit 5446900)
@marefr marefr mentioned this pull request Mar 19, 2020
aknuds1 pushed a commit that referenced this pull request Mar 19, 2020
* Initial commit

* Fix spelling of data sources

* Display sorting value for starred and query tab

* Fix handle color for light theme

* Add close button and fix animation

* Remove toggling of tabs

* Stop event propagation when clicking on comment buttons

* Add title for card functionality

* Remove interpolation for easier searchability of variables

* Improve syncing of comments and starred

* Add modal to check if user wants to permanently delete history

* Fix the height of the query card buttons

* Adjust slider's width based on drawer width

* Add spacing between slider and legend

* Semantic variable naming

* Fix disabled button when live tailing

* Add error handling

* Remove unused imports

* Fix starring, remove useEffect

* Remove emiting of appEvents.alertError in store

* Remove unused imports

(cherry picked from commit 5446900)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants