Unverified Commit 506cf6d6 authored by Tao Feng's avatar Tao Feng Committed by GitHub

feat: redirect dashboard group to search filter after clicking (#655)

Signed-off-by: 's avatarTao Feng <fengtao04@gmail.com>
parent ee0474fd
...@@ -99,8 +99,8 @@ exports[`strict null compilation`] = { ...@@ -99,8 +99,8 @@ exports[`strict null compilation`] = {
[255, 6, 11, "No overload matches this call.\\n The last overload gave the following error.\\n Type \'(() => SubmitSearchRequest) | null\' is not assignable to type \'ActionCreator<any>\'.\\n Type \'null\' is not assignable to type \'ActionCreator<any>\'.", "2296208050"], [255, 6, 11, "No overload matches this call.\\n The last overload gave the following error.\\n Type \'(() => SubmitSearchRequest) | null\' is not assignable to type \'ActionCreator<any>\'.\\n Type \'null\' is not assignable to type \'ActionCreator<any>\'.", "2296208050"],
[270, 4, 18, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is not assignable to parameter of type \'DispatchFromProps\'.\\n Type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is missing the following properties from type \'DispatchFromProps\': submitSearch, onInputChange, onSelectInlineResult", "2926224796"] [270, 4, 18, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is not assignable to parameter of type \'DispatchFromProps\'.\\n Type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is missing the following properties from type \'DispatchFromProps\': submitSearch, onInputChange, onSelectInlineResult", "2926224796"]
], ],
"js/components/common/Table/index.tsx:2645527205": [ "js/components/common/Table/index.tsx:2588109192": [
[190, 22, 13, "Type \'unknown\' is not assignable to type \'ReactNode\'.\\n Type \'unknown\' is not assignable to type \'ReactPortal\'.", "971959308"] [189, 22, 13, "Type \'unknown\' is not assignable to type \'ReactNode\'.\\n Type \'unknown\' is not assignable to type \'ReactPortal\'.", "971959308"]
], ],
"js/components/common/Tags/TagInput/index.tsx:3754832290": [ "js/components/common/Tags/TagInput/index.tsx:3754832290": [
[63, 22, 6, "Type \'undefined\' is not assignable to type \'GetAllTagsRequest\'.", "1979467425"], [63, 22, 6, "Type \'undefined\' is not assignable to type \'GetAllTagsRequest\'.", "1979467425"],
...@@ -265,10 +265,10 @@ exports[`strict null compilation`] = { ...@@ -265,10 +265,10 @@ exports[`strict null compilation`] = {
"js/pages/DashboardPage/DashboardOwnerEditor/index.spec.tsx:4125678807": [ "js/pages/DashboardPage/DashboardOwnerEditor/index.spec.tsx:4125678807": [
[29, 19, 11, "Type \'{ manager_id: null; manager_fullname: null; manager_email: null; profile_url: string; role_name: null; display_name: null; github_username: null; team_name: null; last_name: null; full_name: null; ... 6 more ...; user_id: string; }\' is not assignable to type \'User\'.\\n Types of property \'display_name\' are incompatible.\\n Type \'null\' is not assignable to type \'string\'.", "2041815528"] [29, 19, 11, "Type \'{ manager_id: null; manager_fullname: null; manager_email: null; profile_url: string; role_name: null; display_name: null; github_username: null; team_name: null; last_name: null; full_name: null; ... 6 more ...; user_id: string; }\' is not assignable to type \'User\'.\\n Types of property \'display_name\' are incompatible.\\n Type \'null\' is not assignable to type \'string\'.", "2041815528"]
], ],
"js/pages/DashboardPage/index.spec.tsx:644863281": [ "js/pages/DashboardPage/index.spec.tsx:3245519479": [
[53, 4, 8, "Argument of type \'Partial<Location<{} | null | undefined>> | undefined\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.\\n Type \'undefined\' is not assignable to type \'Partial<Location<{} | null | undefined>>\'.", "2700611480"], [53, 4, 8, "Argument of type \'Partial<Location<{} | null | undefined>> | undefined\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.\\n Type \'undefined\' is not assignable to type \'Partial<Location<{} | null | undefined>>\'.", "2700611480"],
[212, 10, 18, "Type \'null\' is not assignable to type \'number\'.", "2901767208"], [213, 10, 18, "Type \'null\' is not assignable to type \'number\'.", "2901767208"],
[213, 10, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"] [214, 10, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
], ],
"js/pages/ProfilePage/index.spec.tsx:4086464143": [ "js/pages/ProfilePage/index.spec.tsx:4086464143": [
[41, 6, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.", "2087897566"] [41, 6, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.", "2087897566"]
......
...@@ -36,7 +36,7 @@ export type FilterOptions = { [id: string]: boolean }; ...@@ -36,7 +36,7 @@ export type FilterOptions = { [id: string]: boolean };
export interface FilterReducerState { export interface FilterReducerState {
[ResourceType.dashboard]?: ResourceFilterReducerState; [ResourceType.dashboard]?: ResourceFilterReducerState;
[ResourceType.table]: ResourceFilterReducerState; [ResourceType.table]?: ResourceFilterReducerState;
} }
export interface ResourceFilterReducerState { export interface ResourceFilterReducerState {
......
...@@ -58,6 +58,7 @@ const setup = ( ...@@ -58,6 +58,7 @@ const setup = (
statusCode: 200, statusCode: 200,
dashboard: dashboardMetadata, dashboard: dashboardMetadata,
getDashboard: jest.fn(), getDashboard: jest.fn(),
searchDashboardGroup: jest.fn(),
...routerProps, ...routerProps,
...propOverrides, ...propOverrides,
}; };
......
...@@ -11,6 +11,8 @@ import { getDashboard } from 'ducks/dashboard/reducer'; ...@@ -11,6 +11,8 @@ import { getDashboard } from 'ducks/dashboard/reducer';
import { GetDashboardRequest } from 'ducks/dashboard/types'; import { GetDashboardRequest } from 'ducks/dashboard/types';
import { GlobalState } from 'ducks/rootReducer'; import { GlobalState } from 'ducks/rootReducer';
import { logClick } from 'ducks/utilMethods'; import { logClick } from 'ducks/utilMethods';
import { UpdateSearchStateRequest } from 'ducks/search/types';
import { updateSearchState } from 'ducks/search/reducer';
import Breadcrumb from 'components/common/Breadcrumb'; import Breadcrumb from 'components/common/Breadcrumb';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon'; import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
...@@ -65,6 +67,7 @@ export interface DispatchFromProps { ...@@ -65,6 +67,7 @@ export interface DispatchFromProps {
searchIndex?: string; searchIndex?: string;
source?: string; source?: string;
}) => GetDashboardRequest; }) => GetDashboardRequest;
searchDashboardGroup: (dashboardGroup: string) => UpdateSearchStateRequest;
} }
export type DashboardPageProps = RouteComponentProps<MatchProps> & export type DashboardPageProps = RouteComponentProps<MatchProps> &
...@@ -100,6 +103,15 @@ export class DashboardPage extends React.Component< ...@@ -100,6 +103,15 @@ export class DashboardPage extends React.Component<
} }
} }
searchGroup = (e) => {
const { dashboard, searchDashboardGroup } = this.props;
logClick(e, {
target_type: 'dashboard_group',
label: dashboard.group_name,
});
searchDashboardGroup(dashboard.group_name);
};
mapStatusToBoolean = (status: string): boolean => { mapStatusToBoolean = (status: string): boolean => {
if (status === LAST_RUN_SUCCEEDED) { if (status === LAST_RUN_SUCCEEDED) {
return true; return true;
...@@ -181,15 +193,14 @@ export class DashboardPage extends React.Component< ...@@ -181,15 +193,14 @@ export class DashboardPage extends React.Component<
/> />
<div className="body-2"> <div className="body-2">
Dashboard in&nbsp; Dashboard in&nbsp;
<a <button
id="dashboard-group-link" type="button"
onClick={logClick} className="btn btn-link body-2"
href={dashboard.group_url} data-type="dashboard-group-link"
target="_blank" onClick={this.searchGroup}
rel="noopener noreferrer"
> >
{dashboard.group_name} {dashboard.group_name}
</a> </button>
</div> </div>
</div> </div>
{/* <div className="header-section header-links">links here</div> */} {/* <div className="header-section header-links">links here</div> */}
...@@ -316,6 +327,17 @@ export class DashboardPage extends React.Component< ...@@ -316,6 +327,17 @@ export class DashboardPage extends React.Component<
} }
} }
function searchDashboardGroup(
dashboardGroup: string
): UpdateSearchStateRequest {
return updateSearchState({
filters: {
[ResourceType.dashboard]: { group_name: dashboardGroup },
},
submitSearch: true,
});
}
export const mapStateToProps = (state: GlobalState) => { export const mapStateToProps = (state: GlobalState) => {
return { return {
isLoading: state.dashboard.isLoading, isLoading: state.dashboard.isLoading,
...@@ -325,7 +347,7 @@ export const mapStateToProps = (state: GlobalState) => { ...@@ -325,7 +347,7 @@ export const mapStateToProps = (state: GlobalState) => {
}; };
export const mapDispatchToProps = (dispatch: any) => { export const mapDispatchToProps = (dispatch: any) => {
return bindActionCreators({ getDashboard }, dispatch); return bindActionCreators({ getDashboard, searchDashboardGroup }, dispatch);
}; };
export default connect<StateFromProps, DispatchFromProps>( export default connect<StateFromProps, DispatchFromProps>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment