-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84372ba
commit e5d98b0
Showing
9 changed files
with
134 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
public/react/SettingsSidebar/components/IssueSource/components/StatusSelect/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default } from "./ExcludedStatusSelect"; | ||
export * from "./ExcludedStatusSelect"; |
1 change: 1 addition & 0 deletions
1
public/react/SettingsSidebar/components/IssueSource/hooks/useJQL/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./useJQL"; |
47 changes: 47 additions & 0 deletions
47
public/react/SettingsSidebar/components/IssueSource/hooks/useJQL/useJQL.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useState } from "react"; | ||
import { value } from "../../../../../../can"; | ||
import routeData from "../../../../../../canjs/routing/route-data"; | ||
import { useCanObservable } from "../../../../../hooks/useCanObservable"; | ||
|
||
export const useJQL = () => { | ||
const jqlFromRouteData = useCanObservable(value.from<string>(routeData, "jql")); | ||
const childJQLFromRouteData = useCanObservable(value.from<string>(routeData, "childJQL")); | ||
const loadChildren = useCanObservable(value.from<boolean>(routeData, "loadChildren")); | ||
const statusesToExcludeFromRouteData = useCanObservable( | ||
value.from<string[]>(routeData, "statusesToExclude") | ||
); | ||
|
||
const [statusesToExclude, setStatusesToExclude] = useState<string[]>( | ||
statusesToExcludeFromRouteData | ||
); | ||
const [jql, setJql] = useState(jqlFromRouteData); | ||
const [childJQL, setChildJQL] = useState(childJQLFromRouteData); | ||
|
||
console.log({ jql, loadChildren, childJQL, statusesToExclude }); | ||
|
||
const applyJql = () => { | ||
routeData.assign({ | ||
jql, | ||
childJQL, | ||
statusesToExclude, | ||
}); | ||
}; | ||
|
||
const statusesDiffer = | ||
statusesToExclude.some((filter) => !statusesToExcludeFromRouteData.includes(filter)) || | ||
statusesToExcludeFromRouteData.some((filter) => !statusesToExclude.includes(filter)); | ||
|
||
return { | ||
loadChildren, | ||
jql, | ||
setJql, | ||
childJQL, | ||
setChildJQL, | ||
applyJql, | ||
statusesToExclude, | ||
setStatusesToExclude, | ||
applyButtonEnabled: | ||
!loadChildren && | ||
(jql !== jqlFromRouteData || childJQL !== childJQLFromRouteData || statusesDiffer), | ||
}; | ||
}; |
1 change: 1 addition & 0 deletions
1
public/react/SettingsSidebar/components/IssueSource/hooks/useRawIssueRequestData/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./useRawIssueRequestData"; |
38 changes: 38 additions & 0 deletions
38
...ingsSidebar/components/IssueSource/hooks/useRawIssueRequestData/useRawIssueRequestData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { CanPromise } from "../../../../../hooks/useCanObservable"; | ||
import type { JiraIssue } from "../../../../../../jira/shared/types"; | ||
import type { OidcJiraIssue } from "../../../../../../jira-oidc-helpers/types"; | ||
|
||
import { value } from "../../../../../../can"; | ||
import routeData from "../../../../../../canjs/routing/route-data"; | ||
import { useCanObservable } from "../../../../../hooks/useCanObservable"; | ||
|
||
export const useRawIssuesRequestData = () => { | ||
const issuesPromise = useCanObservable<CanPromise<JiraIssue[] | OidcJiraIssue[]>>( | ||
value.from(routeData, "rawIssuesRequestData.issuesPromise") | ||
); | ||
|
||
const issuesPromisePending = useCanObservable<boolean>( | ||
value.from(routeData, "rawIssuesRequestData.issuesPromise.isPending") | ||
); | ||
const issuesPromiseResolved = useCanObservable<boolean>( | ||
value.from(routeData, "rawIssuesRequestData.issuesPromise.isResolved") | ||
); | ||
const issuesPromiseValueLength = useCanObservable<number>( | ||
value.from(routeData, "rawIssuesRequestData.issuesPromise.value.length") | ||
); | ||
const issuesReceived = useCanObservable<number>( | ||
value.from(routeData, "rawIssuesRequestData.progressData.issuesReceived") | ||
); | ||
const issuesRequested = useCanObservable<number>( | ||
value.from(routeData, "rawIssuesRequestData.progressData.issuesRequested") | ||
); | ||
|
||
return { | ||
issuesPromise, | ||
isLoading: issuesPromisePending, | ||
isSuccess: issuesPromiseResolved, | ||
numberOfIssues: issuesPromiseValueLength, | ||
receivedChunks: issuesReceived, | ||
totalChunks: issuesRequested, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters