Failed or Canceled Export Retry Button #2975
Failed or Canceled Export Retry Button #2975
Conversation
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.
core/src/modules/ops/export.ts
Outdated
@@ -175,7 +175,7 @@ export namespace ExportOps { | |||
saveExports = true | |||
) { | |||
const where: WhereOptions<Export> = { | |||
state: "failed", | |||
state: { [Op.in]: ["failed", "canceled"] }, |
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.
@pedroslopez This is a change in existing functionality, I'm unsure if it's a problem.
I can move this logic out so retried canceled exports tell it explicitly to run them.
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.
Yeah, this could affect the existing "retry failed" functionality. After #2818, we are now canceling older exports if there are multiple for the same record/destination (test case here). This means that these intentionally canceled ones would also be retried when doing it by date range.
Seeing this and the date range thing makes me think that perhaps this is a different method, ExportOps.retryExportById
or similar. To ensure this new one and the existing one are retrying in the same way we could break out the actual updating of the export into a separate function and share that.
@@ -31,15 +31,15 @@ export namespace CLS { | |||
* Wrap an Async function f in such a way that all enqueued afterCommit / enqueueTasks during invocation will be run afterwords | |||
* Returns the return value of function f | |||
*/ | |||
export interface CLSWrapMethod { | |||
export interface CLSWrapMethod<T = any> { |
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.
Generics!
ui/ui-components/client/client.ts
Outdated
public async requestAction<A extends Action>( | ||
verb: Method = "get", | ||
path: string, | ||
data: Partial<ParamsFrom<A>>, // TODO: Make ParamsFrom handle required |
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.
Once this handles required we can use this to type input params in the Client!
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.
We can use this to handle type inputs on the client anyway, but it'll be better.
import EnterpriseLink from "../GrouparooLink"; | ||
import LoadingTable from "../LoadingTable"; | ||
import Pagination from "../Pagination"; | ||
import { ExportGroupsDiff, ExportRecordPropertiesDiff } from "./Diff"; |
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.
Sorted imports, no negative effects seen.
style={{ cursor: "pointer" }} | ||
onClick={() => retryExport(_export, index)} | ||
/> | ||
) : null} |
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.
@bleonard If you get a chance to look over things, this is what this looks like.
Retry Export | ||
</LoadingButton>, | ||
]} | ||
> |
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.
Moved to Edmundo's managed card 👌
const [_export, setExport] = useState(props._export); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const retryExport = useCallback(async () => { |
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.
A lot of this logic seems to be repeated in two files. I wonder if we could encapsulate part, if not all of this logic, maybe in a hook?
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 think the best option may be to extract the meat of the function and just export that. Otherwise you'll end up passing in all the hook setters, etc. I'll move it, lemme know what you think!
core/src/modules/ops/export.ts
Outdated
@@ -175,7 +175,7 @@ export namespace ExportOps { | |||
saveExports = true | |||
) { | |||
const where: WhereOptions<Export> = { | |||
state: "failed", | |||
state: { [Op.in]: ["failed", "canceled"] }, |
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.
Yeah, this could affect the existing "retry failed" functionality. After #2818, we are now canceling older exports if there are multiple for the same record/destination (test case here). This means that these intentionally canceled ones would also be retried when doing it by date range.
Seeing this and the date range thing makes me think that perhaps this is a different method, ExportOps.retryExportById
or similar. To ensure this new one and the existing one are retrying in the same way we could break out the actual updating of the export into a separate function and share that.
…exports. Additionally, adds some new functionality to client to type input parameters.
b9d4e0f
to
c42a06e
Compare
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.
👍🏼
core/src/actions/exports.ts
Outdated
}: { | ||
params: ParamsFrom<ExportsRetryFailedById>; | ||
}) { | ||
console.log(params); |
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.
console.log
@@ -314,7 +314,7 @@ export class Export extends CommonModel<Export> { | |||
} | |||
} | |||
|
|||
static async retryFailed( | |||
static retryFailed( |
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.
Doesn't need to be async since we're not awaiting anything.
ui/ui-components/client/client.ts
Outdated
public async requestAction<A extends Action>( | ||
verb: Method = "get", | ||
path: string, | ||
data: Partial<ParamsFrom<A>>, // TODO: Make ParamsFrom handle required |
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.
We can use this to handle type inputs on the client anyway, but it'll be better.
@krishnaglick I feel that this PR is now doing too much: Both the feature change and the action cleanup. |
I can pull it out, but it did catch a bug. This is definitely a larger PR but I'm pretty sure it didn't break anything since it's just a type-inference fix. |
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, just one suggestion on keeping the names consistent.
Change description
Description here
Checklists
Development
Impact
Please explain any security, performance, migration, or other impacts if relevant:
Code review