-
Notifications
You must be signed in to change notification settings - Fork 1
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
✨ Added restart for app #88
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { GearSix, LinkBreak, Link as LinkIcon } from '@jengaicons/react'; | ||
import { | ||
GearSix, | ||
LinkBreak, | ||
Link as LinkIcon, | ||
Repeat, | ||
} from '@jengaicons/react'; | ||
import { Link, useOutletContext, useParams } from '@remix-run/react'; | ||
import { generateKey, titleCase } from '~/components/utils'; | ||
import { | ||
|
@@ -47,7 +52,7 @@ type OnAction = ({ | |
action, | ||
item, | ||
}: { | ||
action: 'delete' | 'edit' | 'intercept' | 'remove_intercept'; | ||
action: 'delete' | 'edit' | 'intercept' | 'remove_intercept' | 'restart'; | ||
item: BaseType; | ||
}) => void; | ||
|
||
|
@@ -83,14 +88,26 @@ const ExtraButton = ({ onAction, item }: IExtraButton) => { | |
options = [ | ||
{ | ||
label: 'Intercept', | ||
icon: <LinkIcon size={iconSize} />, | ||
icon: <Repeat size={iconSize} />, | ||
type: 'item', | ||
onClick: () => onAction({ action: 'intercept', item }), | ||
key: 'intercept', | ||
}, | ||
...options, | ||
]; | ||
} | ||
|
||
options = [ | ||
{ | ||
label: 'Restart', | ||
icon: <LinkIcon size={iconSize} />, | ||
type: 'item', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (llm): It appears that the 'Restart' action is using the 'LinkIcon', which might not accurately represent the action. Consider using a more appropriate icon to enhance clarity and user experience. |
||
onClick: () => onAction({ action: 'restart', item }), | ||
key: 'restart', | ||
}, | ||
...options, | ||
]; | ||
|
||
return <ResourceExtraAction options={options} />; | ||
}; | ||
|
||
|
@@ -240,13 +257,39 @@ const AppsResources = ({ items = [] }: Omit<IResource, 'onAction'>) => { | |
} | ||
} | ||
}; | ||
|
||
const restartApp = async (item: BaseType) => { | ||
if (!environment || !project) { | ||
throw new Error('Environment is required!.'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (llm): The error message 'Environment is required!.' contains an unnecessary punctuation mark. Consider removing the extra period for grammatical correctness. |
||
|
||
try { | ||
const { errors } = await api.restartApp({ | ||
appName: parseName(item), | ||
envName: environment, | ||
projectName: project, | ||
}); | ||
|
||
if (errors) { | ||
throw errors[0]; | ||
} | ||
toast.success('App restarted successfully'); | ||
reload(); | ||
} catch (error) { | ||
handleError(error); | ||
} | ||
}; | ||
|
||
const props: IResource = { | ||
items, | ||
onAction: ({ action, item }) => { | ||
switch (action) { | ||
case 'intercept': | ||
interceptApp(item, true); | ||
break; | ||
case 'restart': | ||
restartApp(item); | ||
break; | ||
case 'remove_intercept': | ||
interceptApp(item, false); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,29 @@ import { | |
ConsoleUpdateAppMutationVariables, | ||
ConsoleInterceptAppMutation, | ||
ConsoleInterceptAppMutationVariables, | ||
ConsoleRestartAppQuery, | ||
ConsoleRestartAppQueryVariables, | ||
} from '~/root/src/generated/gql/server'; | ||
|
||
export type IApp = NN<ConsoleGetAppQuery['core_getApp']>; | ||
export type IApps = NN<ConsoleListAppsQuery['core_listApps']>; | ||
|
||
export const appQueries = (executor: IExecutor) => ({ | ||
restartApp: executor( | ||
gql` | ||
query Query($projectName: String!, $envName: String!, $appName: String!) { | ||
core_restartApp( | ||
projectName: $projectName | ||
envName: $envName | ||
appName: $appName | ||
) | ||
} | ||
`, | ||
{ | ||
transformer: (data: ConsoleRestartAppQuery) => data.core_restartApp, | ||
vars: (_: ConsoleRestartAppQueryVariables) => {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (llm): The 'vars' function for 'restartApp' is defined but does not seem to be used. If this is intentional for future use or extensibility, consider adding a comment to clarify its purpose and avoid confusion. |
||
} | ||
), | ||
createApp: executor( | ||
gql` | ||
mutation Core_createApp( | ||
|
@@ -38,7 +55,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleCreateAppMutation) => data.core_createApp, | ||
vars(_: ConsoleCreateAppMutationVariables) { }, | ||
vars(_: ConsoleCreateAppMutationVariables) {}, | ||
} | ||
), | ||
|
||
|
@@ -62,7 +79,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
transformer: (data: ConsoleUpdateAppMutation) => { | ||
return data.core_updateApp; | ||
}, | ||
vars(_: ConsoleUpdateAppMutationVariables) { }, | ||
vars(_: ConsoleUpdateAppMutationVariables) {}, | ||
} | ||
), | ||
interceptApp: executor( | ||
|
@@ -86,7 +103,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
{ | ||
transformer: (data: ConsoleInterceptAppMutation) => | ||
data.core_interceptApp, | ||
vars(_: ConsoleInterceptAppMutationVariables) { }, | ||
vars(_: ConsoleInterceptAppMutationVariables) {}, | ||
} | ||
), | ||
deleteApp: executor( | ||
|
@@ -105,7 +122,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleDeleteAppMutation) => data.core_deleteApp, | ||
vars(_: ConsoleDeleteAppMutationVariables) { }, | ||
vars(_: ConsoleDeleteAppMutationVariables) {}, | ||
} | ||
), | ||
getApp: executor( | ||
|
@@ -252,7 +269,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
transformer(data: ConsoleGetAppQuery) { | ||
return data.core_getApp; | ||
}, | ||
vars(_: ConsoleGetAppQueryVariables) { }, | ||
vars(_: ConsoleGetAppQueryVariables) {}, | ||
} | ||
), | ||
listApps: executor( | ||
|
@@ -397,7 +414,7 @@ export const appQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleListAppsQuery) => data.core_listApps, | ||
vars(_: ConsoleListAppsQueryVariables) { }, | ||
vars(_: ConsoleListAppsQueryVariables) {}, | ||
} | ||
), | ||
}); |
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.
suggestion (llm): The icon for the 'Restart' action seems to be a repeat icon, which might not intuitively convey the action of restarting. Consider using an icon that more closely represents the restart action to improve user experience.