mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 15:52:40 +02:00
refactor: update button rendering logic in connector views to improve loading state handling
This commit is contained in:
parent
1b87719a92
commit
7f32dd068f
4 changed files with 19 additions and 33 deletions
|
|
@ -144,18 +144,14 @@ export const ConnectorConnectView: FC<ConnectorConnectViewProps> = ({
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleFormSubmit}
|
onClick={handleFormSubmit}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className="text-xs sm:text-sm min-w-[140px] disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none"
|
className="relative text-xs sm:text-sm min-w-[140px] disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none"
|
||||||
>
|
>
|
||||||
{isSubmitting ? (
|
<span className={isSubmitting ? "opacity-0" : ""}>
|
||||||
<>
|
{connectorType === "MCP_CONNECTOR"
|
||||||
<Spinner size="sm" className="mr-2" />
|
? "Connect"
|
||||||
Connecting
|
: `Connect ${getConnectorTypeDisplay(connectorType)}`}
|
||||||
</>
|
</span>
|
||||||
) : connectorType === "MCP_CONNECTOR" ? (
|
{isSubmitting && <Spinner size="sm" className="absolute" />}
|
||||||
"Connect"
|
|
||||||
) : (
|
|
||||||
`Connect ${getConnectorTypeDisplay(connectorType)}`
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -369,16 +369,10 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleDisconnectConfirm}
|
onClick={handleDisconnectConfirm}
|
||||||
disabled={isDisconnecting}
|
disabled={isDisconnecting}
|
||||||
className="text-xs sm:text-sm flex-1 sm:flex-initial h-10 sm:h-auto py-2 sm:py-2"
|
className="relative text-xs sm:text-sm flex-1 sm:flex-initial h-10 sm:h-auto py-2 sm:py-2"
|
||||||
>
|
>
|
||||||
{isDisconnecting ? (
|
<span className={isDisconnecting ? "opacity-0" : ""}>Confirm Disconnect</span>
|
||||||
<>
|
{isDisconnecting && <Spinner size="sm" className="absolute" />}
|
||||||
<Spinner size="sm" className="mr-2" />
|
|
||||||
Disconnecting
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
"Confirm Disconnect"
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|
@ -415,10 +409,10 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
|
||||||
<Button
|
<Button
|
||||||
onClick={onSave}
|
onClick={onSave}
|
||||||
disabled={isSaving || isDisconnecting}
|
disabled={isSaving || isDisconnecting}
|
||||||
className="text-xs sm:text-sm flex-1 sm:flex-initial h-12 sm:h-auto py-3 sm:py-2"
|
className="relative text-xs sm:text-sm flex-1 sm:flex-initial h-12 sm:h-auto py-3 sm:py-2"
|
||||||
>
|
>
|
||||||
{isSaving && <Spinner size="sm" className="mr-2" />}
|
<span className={isSaving ? "opacity-0" : ""}>Save Changes</span>
|
||||||
Save Changes
|
{isSaving && <Spinner size="sm" className="absolute" />}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs sm:text-sm font-medium">
|
<span className="text-xs sm:text-sm font-medium">
|
||||||
{isConnecting ? "Connecting" : buttonText}
|
{buttonText}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -335,16 +335,12 @@ export const YouTubeCrawlerView: FC<YouTubeCrawlerViewProps> = ({ searchSpaceId,
|
||||||
<Button
|
<Button
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
disabled={isSubmitting || isFetchingPlaylist || videoTags.length === 0}
|
disabled={isSubmitting || isFetchingPlaylist || videoTags.length === 0}
|
||||||
className="text-xs sm:text-sm min-w-[140px] disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none"
|
className="relative text-xs sm:text-sm min-w-[140px] disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none"
|
||||||
>
|
>
|
||||||
{isSubmitting ? (
|
<span className={isSubmitting ? "opacity-0" : ""}>
|
||||||
<>
|
{t("submit")}
|
||||||
<Spinner size="sm" className="mr-2" />
|
</span>
|
||||||
{t("processing")}
|
{isSubmitting && <Spinner size="sm" className="absolute" />}
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
t("submit")
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue