Skip to content

Commit

Permalink
[dashboard] add org image warning to start workspace page
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Sep 21, 2023
1 parent 8392ca0 commit 8d6c410
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { StartPage, StartPhase, StartWorkspaceError } from "./StartPage";
import ConnectToSSHModal from "../workspaces/ConnectToSSHModal";
import Alert from "../components/Alert";
import { workspacesService } from "../service/public-api";
import { useDefaultWorkspaceImageQuery } from "../data/workspaces/default-workspace-image-query";

const sessionId = v4();

Expand Down Expand Up @@ -708,6 +709,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
<button>Open Workspace</button>
</a>
</div>
<OrgDefaultWorkspaceWarningView workspaceId={this.state.workspaceInstance.workspaceId} />
</div>
);
break;
Expand Down Expand Up @@ -806,3 +808,16 @@ function ImageBuildView(props: ImageBuildViewProps) {
</StartPage>
);
}

function OrgDefaultWorkspaceWarningView(props: { workspaceId: string }) {
const { data: imageInfo } = useDefaultWorkspaceImageQuery(props.workspaceId);
if (imageInfo?.source === "installation") {
return null;
}
return (
<Alert className="w-96 mt-4" type="warning">
A custom <span className="font-medium">default workspace image</span> is set for this organization. Contact
an organization owner or specify a different image in <code>.gitpod.yml</code>.
</Alert>
);
}
6 changes: 3 additions & 3 deletions components/dashboard/src/teams/TeamSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function TeamSettingsPage() {
function OrgSettingsForm(props: { org?: OrganizationInfo }) {
const { org } = props;
const { data: settings, isLoading } = useOrgSettingsQuery();
const { data: globalDefaultImage } = useDefaultWorkspaceImageQuery();
const { data: imageInfo } = useDefaultWorkspaceImageQuery();
const updateTeamSettings = useUpdateOrgSettingsMutation();

const [showImageEditModal, setShowImageEditModal] = useState(false);
Expand Down Expand Up @@ -229,14 +229,14 @@ function OrgSettingsForm(props: { org?: OrganizationInfo }) {
<WorkspaceImageButton
disabled={!org?.isOwner}
settings={settings}
defaultWorkspaceImage={globalDefaultImage?.image}
defaultWorkspaceImage={imageInfo?.image}
onClick={() => setShowImageEditModal(true)}
/>

{showImageEditModal && (
<OrgDefaultWorkspaceImageModal
settings={settings}
globalDefaultImage={globalDefaultImage?.image}
globalDefaultImage={imageInfo?.image}
onClose={() => setShowImageEditModal(false)}
/>
)}
Expand Down

0 comments on commit 8d6c410

Please sign in to comment.