Skip to content

Commit

Permalink
SAK-48362 roster. Add profile connections buttons back (sakaiproject#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Apr 19, 2024
1 parent 28ac3d7 commit 241fe97
Show file tree
Hide file tree
Showing 19 changed files with 334 additions and 163 deletions.
16 changes: 16 additions & 0 deletions library/src/skins/default/src/sass/modules/button/_base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
html {
--sui-btn-color: var(--button-text-color);
--sui-btn-bg-color: var(--button-background);
--sui-btn-hover-bg-color: var(--button-hover-background);
--sui-btn-border-width: #{$btn-border-width};
--sui-btn-border-radius: #{$btn-border-radius};
--sui-btn-border-color: var(--button-border-color);
--sui-btn-hover-border-color: var(--button-hover-border-color);
--sui-btn-padding: #{$btn-padding-y} #{$btn-padding-x};
--sui-btn-box-shadow: var(--button-shadow);
--sui-btn-hover-box-shadow: var(--button-hover-shadow);
--sui-btn-font-family: #{$btn-font-family};
--sui-btn-font-size: #{$btn-font-size};
--sui-btn-line-height: #{$btn-line-height};
--sui-btn-font-weight: #{$btn-font-weight};
}

This file was deleted.

2 changes: 1 addition & 1 deletion library/src/skins/default/src/sass/tool.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ $jumbotron-heading-font-size: $h4-font-size;

@import "base/rtl";

@import "modules/button/base";
@import "modules/tool/quicklinks/quicklinks_variables";
@import "modules/tool/quicklinks/base";
@import "modules/tool/timeout-alert/base";
Expand All @@ -188,7 +189,6 @@ $jumbotron-heading-font-size: $h4-font-size;
@import "modules/tool/jumptotop/base";
@import "modules/tool/submission-messager/base";
@import "modules/tool/grader/base";
@import "modules/tool/button/base";
@import "modules/tool/dashboard/base";
@import "modules/tool/courselist/base";
@import "modules/tool/coursecard/base";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public interface ProfileConnectionsLogic {

/**
* Gets a list of BasicOnlinePersons that are connected to this user
* Gets a list of BasicConnection that are connected to this user
*
* @param userUuid uuid of the user to retrieve the list of connections for
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public Object getUnreadMessagesCount(EntityReference ref) {
}
}

@EntityCustomAction(action="requestFriend",viewKey=EntityView.VIEW_SHOW)
@EntityCustomAction(action="requestFriend", viewKey=EntityView.VIEW_SHOW)
public Object requestFriend(EntityReference ref,Map<String,Object> params) {

if(!sakaiProxy.isLoggedIn()) {
Expand All @@ -320,11 +320,11 @@ public Object requestFriend(EntityReference ref,Map<String,Object> params) {
String friendId = (String) params.get("friendId");

//get list of connections
if(!connectionsLogic.requestFriend(uuid, friendId)) {
if (!connectionsLogic.requestFriend(uuid, friendId)) {
throw new EntityException("Error requesting friend connection for " + ref.getId(), ref.getReference());
}
else
} else {
return Messages.getString("Label.friend.requested");
}
}

@EntityCustomAction(action="removeFriend",viewKey=EntityView.VIEW_SHOW)
Expand Down
3 changes: 3 additions & 0 deletions roster2/tool/src/handlebars/members_cards.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
label="{{tr 'profile_picture_alt'}} {{displayName}}"
site-id="{{siteId}}"
classes="roster-photo"
{{#if ../viewPicture}}
profile-popup="on"
{{/if}}
{{#if official}}
official
{{/if}}
Expand Down
3 changes: 3 additions & 0 deletions roster2/tool/src/handlebars/members_table.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
label="{{tr 'profile_picture_alt'}} {{displayName}}"
site-id="{{siteId}}"
classes="roster-photo"
{{#if ../viewPicture}}
profile-popup="on"
{{/if}}
{{#if official}}
official
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public class ProfileRestBean {
public String profileUrl;
public boolean hasPronunciationRecording;
public String studentNumber;
public int connectionStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
******************************************************************************/
package org.sakaiproject.webapi.controllers;

import org.sakaiproject.profile2.logic.ProfileConnectionsLogic;
import org.sakaiproject.profile2.logic.ProfileLinkLogic;
import org.sakaiproject.profile2.logic.ProfileLogic;
import org.sakaiproject.profile2.model.UserProfile;
Expand Down Expand Up @@ -44,14 +45,15 @@ public class ProfileController extends AbstractSakaiApiController {
@Autowired(required = false)
private CandidateDetailProvider candidateDetailProvider;

@Autowired private ProfileConnectionsLogic profileConnectionsLogic;
@Autowired private ProfileLinkLogic profileLinkLogic;
@Autowired private ProfileLogic profileLogic;
@Autowired private UserDirectoryService userDirectoryService;

@GetMapping(value = "/users/{userId}/profile", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProfileRestBean> getUserProfile(@PathVariable String userId) throws UserNotDefinedException {

checkSakaiSession();
String currentUserId = checkSakaiSession().getUserId();

if (StringUtils.equals(userId, "blank")) {
return ResponseEntity.noContent().build();
Expand All @@ -71,6 +73,7 @@ public ResponseEntity<ProfileRestBean> getUserProfile(@PathVariable String userI
bean.pronunciation = userProfile.getPhoneticPronunciation();
bean.profileUrl = profileLinkLogic.getInternalDirectUrlToUserProfile(userId);
bean.hasPronunciationRecording = profileLogic.getUserNamePronunciation(userId) != null;
bean.connectionStatus = profileConnectionsLogic.getConnectionStatus(currentUserId, userId);

if (candidateDetailProvider != null) {
try {
Expand Down
7 changes: 7 additions & 0 deletions webcomponents/bundle/src/main/bundle/profile.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
accept_connection=Accept Connection
connect=Connect
connection=Connection
connection_requested=Connection requested
email=Email
ignore_connection=Ignore Connection
loading=Loading ....
name_pronunciation=Name Pronunciation
remove_connection=Remove Connection
student_number=Student Number
view_full_profile=View full profile
1 change: 1 addition & 0 deletions webcomponents/tool/src/main/frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## temp folders
/.tmp/
bundles
/coverage/
coverage/
/storybook-static/
Expand Down
6 changes: 3 additions & 3 deletions webcomponents/tool/src/main/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class SakaiButton extends LitElement {
static styles = css`
button {
text-align: center;
padding: var(--sakai-button-padding);
padding: var(--sui-btn-padding);
border: 1px solid var(--button-border-color);
border-radius: var(--sakai-button-border-radius);
border-radius: var(--sui-btn-border-radius);
background: var(--button-background);
font-family: "Open Sans",sans-serif;
font-size: 1em;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { SakaiElement } from './src/SakaiElement.js';
export { SakaiShadowElement } from './src/SakaiShadowElement.js';
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
import { LitElement } from "lit";
import { loadProperties, tr } from "@sakai-ui/sakai-i18n";
import { SakaiShadowElement } from "@sakai-ui/sakai-element";

export class SakaiElement extends LitElement {

/**
* Convenience wrapper for sakai-18n.tr.
*
* Example:
*
* confirm_coolness=This is {} cool
* let translated = mySakaiElementSubclass.tr("confirm_coolness", ["really"]);
*
* @param {string} key The i18n key we want to translate
* @params {(string[]|Object)} options This can either be an array of replacement strings, or an object
* which contains token names to values, as well as options like debug: true.
* @param {boolean} [forceBundle=this.bundle] The bundle to use in preference to this.bundle
*/
tr(key, options, forceBundle) {
return tr(forceBundle || this.bundle, key, options);
}
export class SakaiElement extends SakaiShadowElement {

createRenderRoot() {

Expand All @@ -27,30 +9,4 @@ export class SakaiElement extends LitElement {
// custom elements, not full blown web components
return this;
}

loadTranslations(options) {

if (typeof options === "string") {
this.bundle = options;
} else {
this.bundle = options.bundle;
}

// Pass the call on to the imported function
return loadProperties(options);
}

setSetting(component, name, value) {

const currentString = localStorage.getItem(`${component}-settings`);
const settings = currentString ? JSON.parse(currentString) : {};
settings[name] = value;
localStorage.setItem(`${component}-settings`, JSON.stringify(settings));
}

getSetting(component, name) {

const currentString = localStorage.getItem(`${component}-settings`);
return !currentString ? null : JSON.parse(currentString)[name];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { css, LitElement } from "lit";
import { loadProperties, tr } from "@sakai-ui/sakai-i18n";

export class SakaiShadowElement extends LitElement {

/**
* Convenience wrapper for sakai-18n.tr.
*
* Example:
*
* confirm_coolness=This is {} cool
* let translated = mySakaiElementSubclass.tr("confirm_coolness", ["really"]);
*
* @param {string} key The i18n key we want to translate
* @params {(string[]|Object)} options This can either be an array of replacement strings, or an object
* which contains token names to values, as well as options like debug: true.
* @param {boolean} [forceBundle=this.bundle] The bundle to use in preference to this.bundle
*/
tr(key, options, forceBundle) {
return tr(forceBundle || this.bundle, key, options);
}

loadTranslations(options) {

if (typeof options === "string") {
this.bundle = options;
} else {
this.bundle = options.bundle;
}

// Pass the call on to the imported function
return loadProperties(options);
}

setSetting(component, name, value) {

const currentString = localStorage.getItem(`${component}-settings`);
const settings = currentString ? JSON.parse(currentString) : {};
settings[name] = value;
localStorage.setItem(`${component}-settings`, JSON.stringify(settings));
}

getSetting(component, name) {

const currentString = localStorage.getItem(`${component}-settings`);
return !currentString ? null : JSON.parse(currentString)[name];
}

static styles = css`
button {
color: var(--sui-btn-color);
background: var(--sui-btn-bg-color);
padding: var(--sui-btn-padding);
border-radius: var(--sui-btn-border-radius);
border-width: var(--sui-btn-border-width);
border-color: var(--sui-btn-border-color);
box-shadow: var(--sui-btn-box-shadow);
font-family: var(--sui-btn-font-family);
font-size: var(--sui-btn-font-size);
font-weight: var(--sui-btn-font-weight);
line-height: var(--sui-btn-line-height);
}
button:hover {
background: var(--sui-btn-hover-bg-color);
border-color: var(--sui-btn-hover-border-color);
box-shadow: var(--sui-btn-hover-box-shadow);
}
`;
}
Loading

0 comments on commit 241fe97

Please sign in to comment.