Skip to content

Commit

Permalink
Show Slack integration only for published and workspace assistants (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric authored Mar 5, 2024
1 parent bd36af4 commit 2257de5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
82 changes: 43 additions & 39 deletions front/components/assistant/Sharing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function SharingButton({
newScope,
setNewScope,
baseUrl,
showSlackIntegration,
slackDataSource,
slackChannelSelected,
setNewLinkedSlackChannels,
Expand All @@ -119,6 +120,7 @@ export function SharingButton({
newScope: NonGlobalScope;
setNewScope: (scope: NonGlobalScope) => void;
baseUrl: string;
showSlackIntegration: boolean;
slackDataSource: DataSourceType | null;
slackChannelSelected: SlackChannel[];
setNewLinkedSlackChannels: (channels: SlackChannel[]) => void;
Expand Down Expand Up @@ -193,48 +195,50 @@ export function SharingButton({
</div>
</div>

<div className="flex flex-row justify-between">
<div>
<div className="text-base font-bold text-element-800">
Slack integration
</div>
<div className="text-sm text-element-700">
{slackChannelSelected.length === 0 ? (
<>Set as default assistant for specific channels.</>
) : (
<>
Default assistant for{" "}
{slackChannelSelected
.map((c) => c.slackChannelName)
.join(", ")}
</>
)}
</div>
{showSlackIntegration && (
<div className="flex flex-row justify-between">
<div>
<div className="text-base font-bold text-element-800">
Slack integration
</div>
<div className="text-sm text-element-700">
{slackChannelSelected.length === 0 ? (
<>Set as default assistant for specific channels.</>
) : (
<>
Default assistant for{" "}
{slackChannelSelected
.map((c) => c.slackChannelName)
.join(", ")}
</>
)}
</div>

<div className="pt-3">
{slackChannelSelected.length > 0 && (
<Button
size="xs"
variant="secondary"
label="Manage channels"
onClick={() => setSlackDrawerOpened(true)}
/>
)}
<div className="pt-3">
{slackChannelSelected.length > 0 && (
<Button
size="xs"
variant="secondary"
label="Manage channels"
onClick={() => setSlackDrawerOpened(true)}
/>
)}
</div>
</div>
<div className="">
<SliderToggle
selected={slackChannelSelected.length > 0}
onClick={() => {
if (slackChannelSelected.length > 0) {
setNewLinkedSlackChannels([]);
} else {
setSlackDrawerOpened(true);
}
}}
/>
</div>
</div>
<div className="">
<SliderToggle
selected={slackChannelSelected.length > 0}
onClick={() => {
if (slackChannelSelected.length > 0) {
setNewLinkedSlackChannels([]);
} else {
setSlackDrawerOpened(true);
}
}}
/>
</div>
</div>
)}
{agentConfigurationId && (
<div className="flex flex-row justify-between">
<div>
Expand Down
4 changes: 4 additions & 0 deletions front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ export default function AssistantBuilder({
}
);

const showSlackIntegration =
builderState.scope === "workspace" || builderState.scope === "published";

const [edited, setEdited] = useState(defaultIsEdited ?? false);
const [isSavingOrDeleting, setIsSavingOrDeleting] = useState(false);
const [submitEnabled, setSubmitEnabled] = useState(false);
Expand Down Expand Up @@ -434,6 +437,7 @@ export default function AssistantBuilder({
<Tab tabs={tabs} variant="stepper" />
<div className="self-end pt-0.5">
<SharingButton
showSlackIntegration={showSlackIntegration}
slackDataSource={slackDataSource || null}
owner={owner}
agentConfigurationId={agentConfigurationId}
Expand Down

0 comments on commit 2257de5

Please sign in to comment.