Display notice instead of hide when Slack integration unavailable

This commit is contained in:
Tom Moor
2021-10-14 21:49:35 -07:00
parent 8c1979465f
commit 4f34b69cfa
2 changed files with 80 additions and 66 deletions

View File

@ -30,9 +30,7 @@ export default function SettingsRoutes() {
<Route exact path="/settings/shares" component={Shares} /> <Route exact path="/settings/shares" component={Shares} />
<Route exact path="/settings/tokens" component={Tokens} /> <Route exact path="/settings/tokens" component={Tokens} />
<Route exact path="/settings/notifications" component={Notifications} /> <Route exact path="/settings/notifications" component={Notifications} />
{env.SLACK_KEY && (
<Route exact path="/settings/integrations/slack" component={Slack} /> <Route exact path="/settings/integrations/slack" component={Slack} />
)}
{isHosted && ( {isHosted && (
<Route exact path="/settings/integrations/zapier" component={Zapier} /> <Route exact path="/settings/integrations/zapier" component={Zapier} />
)} )}

View File

@ -39,6 +39,7 @@ function Slack() {
return ( return (
<Scene title="Slack" icon={<SlackIcon color="currentColor" />}> <Scene title="Slack" icon={<SlackIcon color="currentColor" />}>
<Heading>Slack</Heading> <Heading>Slack</Heading>
{error === "access_denied" && ( {error === "access_denied" && (
<Notice> <Notice>
<Trans> <Trans>
@ -62,9 +63,13 @@ function Slack() {
components={{ em: <Code /> }} components={{ em: <Code /> }}
/> />
</HelpText> </HelpText>
{env.SLACK_KEY ? (
<>
<p> <p>
{commandIntegration ? ( {commandIntegration ? (
<Button onClick={commandIntegration.delete}>{t("Disconnect")}</Button> <Button onClick={commandIntegration.delete}>
{t("Disconnect")}
</Button>
) : ( ) : (
<SlackButton <SlackButton
scopes={["commands", "links:read", "links:write"]} scopes={["commands", "links:read", "links:write"]}
@ -79,7 +84,8 @@ function Slack() {
<HelpText> <HelpText>
<Trans> <Trans>
Connect Outline collections to Slack channels and messages will be Connect Outline collections to Slack channels and messages will be
automatically posted to Slack when documents are published or updated. automatically posted to Slack when documents are published or
updated.
</Trans> </Trans>
</HelpText> </HelpText>
@ -128,6 +134,16 @@ function Slack() {
); );
})} })}
</List> </List>
</>
) : (
<Notice>
<Trans>
The Slack integration is currently disabled. Please set the
associated environment variables and restart the server to enable
the integration.
</Trans>
</Notice>
)}
</Scene> </Scene>
); );
} }