You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by GitBox <gi...@apache.org> on 2020/06/22 01:46:00 UTC

[GitHub] [guacamole-client] necouchman commented on a change in pull request #530: GUACAMOLE-103: Implement common redirect form field.

necouchman commented on a change in pull request #530:
URL: https://github.com/apache/guacamole-client/pull/530#discussion_r443282420



##########
File path: guacamole-ext/src/main/java/org/apache/guacamole/form/RedirectField.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.form;
+
+import java.net.URI;
+
+/**
+ * A Guacamole field that redirects a user to another page.
+ */
+public class RedirectField extends Field {
+
+    /**
+     * The encoded URL of the redirect.
+     */
+    private final URI redirectUrl;
+    
+    /**
+     * The message that will be displayed for the user during the redirect
+     * process.  This will be processed through Guacamole's translation system.
+     */
+    private final String redirectMsg;
+
+    /**
+     * Creates a new field which facilitates redirection of the user
+     * to another page.
+     *
+     * @param name
+     *     The name of this field.
+     * 
+     * @param redirectUrl
+     *     The URL to which the user should be redirected.
+     * 
+     * @param redirectMsg
+     *     The message to display during the redirect, which will be processed
+     *     through Guacamole's translation system.
+     */
+    public RedirectField(String name, URI redirectUrl, String redirectMsg) {
+
+        // Init base field properties
+        super(name, Field.Type.REDIRECT);
+
+        // Store the URL to which the user will be redirected.
+        this.redirectUrl = redirectUrl;
+        this.redirectMsg = redirectMsg;
+
+    }
+
+    /**
+     * Returns the URL of the redirect.
+     * 
+     * @return
+     *     The URL of the redirect.
+     */
+    public String getRedirectUrl() {
+        return redirectUrl.toString();
+    }
+    
+    /**
+     * Returns the message that will be displayed for the user while the
+     * redirect takes place.
+     * 
+     * @return
+     *     The message to display for the user.
+     */
+    public String getRedirectMsg() {
+        return redirectMsg;
+    }

Review comment:
       Totally good with this, just might need a little guidance on the best way to leverage this in a `Field` situation.  Based on the above note, the `redirectMsg` (now `redirectMessage`) variable is directly available in the scope.  But, if I move over to `Translatable` and `getTranslatableMessage()`, what's the best way to rework the AngularJS side such that this message will be properly displayed and run through the translation system?  I'm trying to follow examples in the existing code, so maybe I'll figure it out...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org