-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Conversation
public/app/core/store.ts
Outdated
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', | ||
}; |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} | ||
/> |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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} | |||
/> |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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(); | ||
}} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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))); | |||
}} | |||
> |
There was a problem hiding this comment.
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.
}, | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
public/app/core/store.ts
Outdated
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; |
There was a problem hiding this comment.
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(); | ||
}} |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
* 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) ...
* 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)
* 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)
This PR adds fixes to Rich history based on users feedback. See list of fixes below:
Fixed:
Separate PRs:
Discussed with Andrej. We are probably going to look at this later (when we move history to database). Needs more research/thought regarding implementation.